Files
deb-python-trollius/check.py
Victor Stinner 684f3be000 Python issue #23208: Add BaseEventLoop._current_handle
In debug mode, BaseEventLoop._run_once() now sets the
BaseEventLoop._current_handle attribute to the handle currently executed.
In release mode or when no handle is executed, the attribute is None.

BaseEventLoop.default_exception_handler() displays the traceback of the current
handle if available.
2015-01-26 10:52:45 +01:00

46 lines
1.0 KiB
Python

"""Search for lines >= 80 chars or with trailing whitespace."""
import os
import sys
def main():
args = sys.argv[1:] or os.curdir
for arg in args:
if os.path.isdir(arg):
for dn, dirs, files in os.walk(arg):
for fn in sorted(files):
if fn.endswith('.py'):
process(os.path.join(dn, fn))
dirs[:] = [d for d in dirs if d[0] != '.']
dirs.sort()
else:
process(arg)
def isascii(x):
try:
x.encode('ascii')
return True
except UnicodeError:
return False
def process(fn):
try:
f = open(fn)
except IOError as err:
print(err)
return
try:
for i, line in enumerate(f):
line = line.rstrip('\n')
sline = line.rstrip()
if len(line) >= 80 or line != sline or not isascii(line):
print('{}:{:d}:{}{}'.format(
fn, i+1, sline, '_' * (len(line) - len(sline))))
finally:
f.close()
main()