mirror of
https://github.com/python/cpython.git
synced 2025-09-26 18:29:57 +00:00
Add -q option that *just* prints the filename.
This commit is contained in:
parent
70c7f48b9b
commit
97df7f8679
1 changed files with 13 additions and 7 deletions
|
@ -5,20 +5,24 @@
|
||||||
import os
|
import os
|
||||||
import sys
|
import sys
|
||||||
import getopt
|
import getopt
|
||||||
import string
|
|
||||||
import tokenize
|
import tokenize
|
||||||
|
|
||||||
verbose = 0
|
verbose = 0
|
||||||
|
quiet = 0
|
||||||
|
|
||||||
def main():
|
def main():
|
||||||
global verbose
|
global verbose, quiet
|
||||||
try:
|
try:
|
||||||
opts, args = getopt.getopt(sys.argv[1:], "v")
|
opts, args = getopt.getopt(sys.argv[1:], "qv")
|
||||||
except getopt.error, msg:
|
except getopt.error, msg:
|
||||||
print msg
|
print msg
|
||||||
for o, a in opts:
|
for o, a in opts:
|
||||||
if o == '-v':
|
if o == '-v':
|
||||||
verbose = verbose + 1
|
verbose = verbose + 1
|
||||||
|
quiet = 0
|
||||||
|
if o == '-q':
|
||||||
|
quiet = 1
|
||||||
|
verbose = 0
|
||||||
for arg in args:
|
for arg in args:
|
||||||
check(arg)
|
check(arg)
|
||||||
|
|
||||||
|
@ -61,7 +65,12 @@ def check(file):
|
||||||
print "%s: Token Error: %s" % (`file`, str(msg))
|
print "%s: Token Error: %s" % (`file`, str(msg))
|
||||||
f.close()
|
f.close()
|
||||||
|
|
||||||
if tokens != alttokens:
|
if tokens == alttokens:
|
||||||
|
if verbose:
|
||||||
|
print "%s: Clean bill of health." % `file`
|
||||||
|
elif quiet:
|
||||||
|
print file
|
||||||
|
else:
|
||||||
badline = 0
|
badline = 0
|
||||||
n, altn = len(tokens), len(alttokens)
|
n, altn = len(tokens), len(alttokens)
|
||||||
for i in range(max(n, altn)):
|
for i in range(max(n, altn)):
|
||||||
|
@ -86,9 +95,6 @@ def check(file):
|
||||||
print "offending line:", `line`
|
print "offending line:", `line`
|
||||||
else:
|
else:
|
||||||
print file, badline, `line`
|
print file, badline, `line`
|
||||||
else:
|
|
||||||
if verbose:
|
|
||||||
print "%s: Clean bill of health." % `file`
|
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
main()
|
main()
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue