This repository has been archived on 2019-12-12. You can view files and clone it, but cannot push or open issues/pull-requests.
2017-04-22 04:29:55 +00:00
|
|
|
#!/usr/bin/env python3
|
|
|
|
import json
|
|
|
|
import sys
|
2015-10-05 23:41:42 +00:00
|
|
|
|
|
|
|
from pystache import render
|
|
|
|
|
2017-04-21 05:00:25 +00:00
|
|
|
def slurp(file_path):
|
|
|
|
contents = None
|
|
|
|
try:
|
|
|
|
with open(file_path, 'r', encoding="utf-8") as f:
|
|
|
|
contents = f.read()
|
|
|
|
except FileNotFoundError:
|
|
|
|
pass
|
|
|
|
except UnicodeDecodeError:
|
|
|
|
pass
|
|
|
|
return contents
|
|
|
|
|
2017-04-22 04:29:55 +00:00
|
|
|
def main(argv):
|
|
|
|
template = slurp(argv[1])
|
|
|
|
data = json.loads(sys.stdin.read())
|
|
|
|
sys.stdout.write(render(template, data))
|
2015-10-05 23:41:42 +00:00
|
|
|
|
|
|
|
if __name__ == '__main__':
|
2017-04-22 04:29:55 +00:00
|
|
|
exit(main(sys.argv))
|
2015-10-05 23:41:42 +00:00
|
|
|
|