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-22 04:56:02 +00:00
|
|
|
# when you install scripts with entry_points in a setup.py, the resulting
|
2017-04-22 05:43:00 +00:00
|
|
|
# executable just calls main() and you have to look up sys.argv yourself. I
|
|
|
|
# like to explicitly take an argv in my actual main, hence the weird
|
|
|
|
# indirection. could probably be better.
|
2017-04-22 04:56:02 +00:00
|
|
|
def _main(argv):
|
2017-04-22 05:43:00 +00:00
|
|
|
with open(argv[1], 'r', encoding='utf-8') as f:
|
|
|
|
template = f.read()
|
2017-04-22 04:29:55 +00:00
|
|
|
data = json.loads(sys.stdin.read())
|
|
|
|
sys.stdout.write(render(template, data))
|
2015-10-05 23:41:42 +00:00
|
|
|
|
2017-04-22 04:56:02 +00:00
|
|
|
def main():
|
|
|
|
_main(sys.argv)
|
|
|
|
|
2015-10-05 23:41:42 +00:00
|
|
|
if __name__ == '__main__':
|
2017-04-22 04:56:02 +00:00
|
|
|
exit(_main(sys.argv))
|
2015-10-05 23:41:42 +00:00
|
|
|
|