This repository has been archived on 2019-12-12. You can view files and clone it, but cannot push or open issues/pull-requests.
tildetown-scripts/tildetown/mustache.py

26 lines
510 B
Python
Raw Normal View History

#!/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
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__':
exit(main(sys.argv))
2015-10-05 23:41:42 +00:00