From e58fe9e2ca898f90afda50a859c4719db36669e3 Mon Sep 17 00:00:00 2001 From: Ned Batchelder Date: Sat, 21 Jul 2012 22:49:42 -0400 Subject: Make the file checker fancy enough to not complain about bom.py --- igor.py | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) (limited to 'igor.py') diff --git a/igor.py b/igor.py index 059169d3..89d4a496 100644 --- a/igor.py +++ b/igor.py @@ -52,8 +52,14 @@ def do_check_eol(args): """Check files for incorrect newlines and trailing whitespace.""" ignore_dirs = ['.svn', '.hg', '.tox'] + checked = set([]) def check_file(fname, crlf=True, trail_white=True): + fname = os.path.relpath(fname) + if fname in checked: + return + checked.add(fname) + for n, line in enumerate(open(fname, "rb")): if crlf: if "\r" in line: @@ -61,6 +67,8 @@ def do_check_eol(args): return if trail_white: line = line[:-1] + if not crlf: + line = line.rstrip('\r') if line.rstrip() != line: print("%s@%d: trailing whitespace found" % (fname, n+1)) return @@ -73,12 +81,13 @@ def do_check_eol(args): if fnmatch.fnmatch(fname, p): check_file(fname, **kwargs) break - for pattern in ignore_dirs: - if pattern in dirs: - dirs.remove(pattern) + for dir_name in ignore_dirs: + if dir_name in dirs: + dirs.remove(dir_name) check_files("coverage", ["*.py", "*.c"]) check_files("coverage/htmlfiles", ["*.html", "*.css", "*.js"]) + check_file("test/farm/html/src/bom.py", crlf=False) check_files("test", ["*.py"]) check_files("test", ["*,cover"], trail_white=False) check_files("test/js", ["*.js", "*.html"]) -- cgit v1.2.1