summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNed Batchelder <ned@nedbatchelder.com>2012-07-21 22:49:42 -0400
committerNed Batchelder <ned@nedbatchelder.com>2012-07-21 22:49:42 -0400
commitd19d09b450e11ee25ef53a1a4c6c050ba1dd8015 (patch)
tree937e4998a660fbe125187600812594774262339f
parent01bc0aa57d44acf7c5eb146299d9fca8f214f31b (diff)
downloadpython-coveragepy-d19d09b450e11ee25ef53a1a4c6c050ba1dd8015.tar.gz
Make the file checker fancy enough to not complain about bom.py
-rw-r--r--igor.py15
1 files changed, 12 insertions, 3 deletions
diff --git a/igor.py b/igor.py
index 059169d..89d4a49 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"])