From: noah morrison Date: Thu, 9 Apr 2015 21:24:49 +0000 (-0400) Subject: Move SyntaxError handling into cli_main X-Git-Url: https://git.devinivas.org/?a=commitdiff_plain;h=bde91d20aa09c33ba2855894b3d1474b526a1fc4;p=chevron.git Move SyntaxError handling into cli_main Makes a little more sense there, as it's only meant to handle exceptions if you're using the command line version. --- diff --git a/chevron/main.py b/chevron/main.py index 8615ff0..1a7a5b4 100755 --- a/chevron/main.py +++ b/chevron/main.py @@ -26,11 +26,7 @@ def main(template, data={}, **kwargs): } args.update(kwargs) - try: - return render(**args) - except SyntaxError as e: - print('Chevron: syntax error') - print(' ' + '\n '.join(e.args[0].split('\n'))) + return render(**args) def cli_main(): @@ -81,10 +77,12 @@ def cli_main(): args = vars(parser.parse_args()) - result = main(**args) - if result is None: + try: + print(main(**args)) + except SyntaxError as e: + print('Chevron: syntax error') + print(' ' + '\n '.join(e.args[0].split('\n'))) exit(1) - print(result) if __name__ == '__main__': cli_main()