diff options
author | Guido van Rossum <guido@python.org> | 1998-03-26 19:23:43 (GMT) |
---|---|---|
committer | Guido van Rossum <guido@python.org> | 1998-03-26 19:23:43 (GMT) |
commit | 97df7f867964b98be76e198b0cccaabbf035f330 (patch) | |
tree | ea37c34437061dd711c1c5e7797ed6b71e2e53ee /Tools/scripts | |
parent | 70c7f48b9b324c3242b2726772c1c3d88c9e26a3 (diff) | |
download | cpython-97df7f867964b98be76e198b0cccaabbf035f330.zip cpython-97df7f867964b98be76e198b0cccaabbf035f330.tar.gz cpython-97df7f867964b98be76e198b0cccaabbf035f330.tar.bz2 |
Add -q option that *just* prints the filename.
Diffstat (limited to 'Tools/scripts')
-rwxr-xr-x | Tools/scripts/tabpolice.py | 20 |
1 files changed, 13 insertions, 7 deletions
diff --git a/Tools/scripts/tabpolice.py b/Tools/scripts/tabpolice.py index e65eb01..22005e1 100755 --- a/Tools/scripts/tabpolice.py +++ b/Tools/scripts/tabpolice.py @@ -5,20 +5,24 @@ import os import sys import getopt -import string import tokenize verbose = 0 +quiet = 0 def main(): - global verbose + global verbose, quiet try: - opts, args = getopt.getopt(sys.argv[1:], "v") + opts, args = getopt.getopt(sys.argv[1:], "qv") except getopt.error, msg: print msg for o, a in opts: if o == '-v': verbose = verbose + 1 + quiet = 0 + if o == '-q': + quiet = 1 + verbose = 0 for arg in args: check(arg) @@ -61,7 +65,12 @@ def check(file): print "%s: Token Error: %s" % (`file`, str(msg)) f.close() - if tokens != alttokens: + if tokens == alttokens: + if verbose: + print "%s: Clean bill of health." % `file` + elif quiet: + print file + else: badline = 0 n, altn = len(tokens), len(alttokens) for i in range(max(n, altn)): @@ -86,9 +95,6 @@ def check(file): print "offending line:", `line` else: print file, badline, `line` - else: - if verbose: - print "%s: Clean bill of health." % `file` if __name__ == '__main__': main() |