From 3e3db7fcff9d577f4d91d6529838fd123bf6840d Mon Sep 17 00:00:00 2001 From: Jussi Pakkanen Date: Mon, 25 Mar 2013 00:59:46 +0200 Subject: Guard against DOS line endings. --- run_tests.py | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/run_tests.py b/run_tests.py index 1cfb42f..c7a7309 100755 --- a/run_tests.py +++ b/run_tests.py @@ -93,13 +93,16 @@ def run_tests(): def check_file(fname): linenum = 0 - for line in open(fname).readlines(): - if '\t' in line: + for line in open(fname, 'rb').readlines(): + if b'\t' in line: print("File %s contains a literal tab on line %d. Only spaces are permitted." % (fname, linenum)) sys.exit(1) - linenum += 1 + if b'\r' in line: + print("File %s contains DOS line ending on line %d. Only unix-style line endings are permitted." % (fname, linenum)) + sys.exit(1) + linenum += 1 -def check_tabs(): +def check_format(): for (root, dirs, files) in os.walk('.'): for file in files: if file.endswith('.py') or file.endswith('.build'): @@ -110,5 +113,5 @@ if __name__ == '__main__': script_dir = os.path.split(__file__)[0] if script_dir != '': os.chdir(script_dir) - check_tabs() + check_format() run_tests() -- cgit v1.1