From 021b7615eb92e8318f050501ca900e8148a0c2cb Mon Sep 17 00:00:00 2001 From: nathaniel smith Date: Fri, 21 Apr 2017 21:56:02 -0700 Subject: [PATCH] fix mustache entry_points thing --- tildetown/mustache.py | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/tildetown/mustache.py b/tildetown/mustache.py index be13ea8..0c3f322 100644 --- a/tildetown/mustache.py +++ b/tildetown/mustache.py @@ -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))