fix mustache entry_points thing

master
nathaniel smith 2017-04-21 21:56:02 -07:00
parent b74fdc94e6
commit 021b7615eb
1 changed files with 8 additions and 3 deletions

View File

@ -15,11 +15,16 @@ def slurp(file_path):
pass
return contents
def main(argv):
# when you install scripts with entry_points in a setup.py, the resulting
# 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.
def _main(argv):
template = slurp(argv[1])
data = json.loads(sys.stdin.read())
sys.stdout.write(render(template, data))
if __name__ == '__main__':
exit(main(sys.argv))
def main():
_main(sys.argv)
if __name__ == '__main__':
exit(_main(sys.argv))