From 84263dd78d58db71f30dd33d5558919d36f47da2 Mon Sep 17 00:00:00 2001 From: nathaniel smith Date: Fri, 21 Apr 2017 22:43:00 -0700 Subject: [PATCH] sigh --- tildetown/mustache.py | 18 +++++------------- 1 file changed, 5 insertions(+), 13 deletions(-) diff --git a/tildetown/mustache.py b/tildetown/mustache.py index 0c3f322..75eed52 100644 --- a/tildetown/mustache.py +++ b/tildetown/mustache.py @@ -4,21 +4,13 @@ import sys from pystache import render -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 - # 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. +# 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]) + with open(argv[1], 'r', encoding='utf-8') as f: + template = f.read() data = json.loads(sys.stdin.read()) sys.stdout.write(render(template, data))