From be29a24a800f3fefaa2c1ed8ac4760364107b9ae Mon Sep 17 00:00:00 2001 From: mailchuck Date: Wed, 20 Apr 2016 15:34:23 +0200 Subject: [PATCH] Syntax check script for Windows I use this as a pre-commit hook on Windows --- compiletest.py | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) create mode 100644 compiletest.py diff --git a/compiletest.py b/compiletest.py new file mode 100644 index 00000000..91df6c5e --- /dev/null +++ b/compiletest.py @@ -0,0 +1,20 @@ +#!/usr/bin/python2.7 + +import ctypes +import fnmatch +import os +import sys +import traceback + +matches = [] +for root, dirnames, filenames in os.walk('src'): + for filename in fnmatch.filter(filenames, '*.py'): + matches.append(os.path.join(root, filename)) + +for filename in matches: + source = open(filename, 'r').read() + '\n' + try: + compile(source, filename, 'exec') + except Exception as e: + ctypes.windll.user32.MessageBoxA(0, traceback.format_exc(), "Exception in " + filename, 1) + sys.exit(1) \ No newline at end of file