summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGuido van Rossum <guido@python.org>1998-03-24 04:58:04 (GMT)
committerGuido van Rossum <guido@python.org>1998-03-24 04:58:04 (GMT)
commit3db0e3713cd59d1c922002056f11ae5caf02805c (patch)
treee01ddd4a06e542761f23f4a806132e16fae224e8
parent031c6315e23d41e253c914eceffd30afe8a0f2cd (diff)
downloadcpython-3db0e3713cd59d1c922002056f11ae5caf02805c.zip
cpython-3db0e3713cd59d1c922002056f11ae5caf02805c.tar.gz
cpython-3db0e3713cd59d1c922002056f11ae5caf02805c.tar.bz2
Report first line with inconsistent tab usage.
-rwxr-xr-xTools/scripts/tabpolice.py28
1 files changed, 24 insertions, 4 deletions
diff --git a/Tools/scripts/tabpolice.py b/Tools/scripts/tabpolice.py
index 9236b71..e65eb01 100755
--- a/Tools/scripts/tabpolice.py
+++ b/Tools/scripts/tabpolice.py
@@ -51,10 +51,10 @@ def check(file):
print "%s: Token Error: %s" % (`file`, str(msg))
if verbose > 1:
- print "checking", `file`, "with tabsize 4..."
+ print "checking", `file`, "with tabsize 1..."
f.seek(0)
alttokens = []
- tokenize.tabsize = 4
+ tokenize.tabsize = 1
try:
tokenize.tokenize(f.readline, alttokens.append)
except tokenize.TokenError, msg:
@@ -62,10 +62,30 @@ def check(file):
f.close()
if tokens != alttokens:
+ badline = 0
+ n, altn = len(tokens), len(alttokens)
+ for i in range(max(n, altn)):
+ if i >= n:
+ x = None
+ else:
+ x = tokens[i]
+ if i >= altn:
+ y = None
+ else:
+ y = alttokens[i]
+ if x != y:
+ if x:
+ kind, token, start, end, line = x
+ else:
+ kind, token, start, end, line = y
+ badline = start[0]
+ break
if verbose:
- print "%s: *** Trouble in tab city! ***" % `file`
+ print "%s: *** Line %d: trouble in tab city! ***" % (
+ `file`, badline)
+ print "offending line:", `line`
else:
- print file
+ print file, badline, `line`
else:
if verbose:
print "%s: Clean bill of health." % `file`