test :
python pep8.py --testsuite testsuite
-multitest :
- python2.4 pep8.py --testsuite testsuite
- python2.5 pep8.py --testsuite testsuite
- python2.6 pep8.py --testsuite testsuite
-
selftest :
- python pep8.py --repeat pep8.py
-
+ python pep8.py --repeat --statistics pep8.py
doctest :
python pep8.py --doctest
-
alltest : test selftest doctest
+
+multitest :
+ python2.3 pep8.py --testsuite testsuite
+ python2.4 pep8.py --testsuite testsuite
+ python2.5 pep8.py --testsuite testsuite
+ python2.6 pep8.py --testsuite testsuite
+ python3.0 pep8.py --testsuite testsuite
+ python3.1 pep8.py --testsuite testsuite
+ python2.3 pep8.py --repeat --statistics pep8.py
+ python2.4 pep8.py --repeat --statistics pep8.py
+ python2.5 pep8.py --repeat --statistics pep8.py
+ python2.6 pep8.py --repeat --statistics pep8.py
+ python3.0 pep8.py --repeat --statistics pep8.py
+ python3.1 pep8.py --repeat --statistics pep8.py
import os
import sys
import re
+import types
import time
import inspect
import tokenize
"""Print a message."""
# print >> sys.stderr, options.prog + ': ' + text
# print >> sys.stderr, text
- print text
+ print(text)
def find_checks(argument_name):
starts with argument_name.
"""
checks = []
- function_type = type(find_checks)
- for name, function in globals().iteritems():
- if type(function) is function_type:
+ for name, function in globals().items():
+ if isinstance(function, types.FunctionType):
args = inspect.getargspec(function)[0]
if len(args) >= 1 and args[0].startswith(argument_name):
checks.append((name, function, args))
def __init__(self, filename):
self.filename = filename
- self.lines = file(filename).readlines()
+ self.lines = open(filename).readlines()
self.physical_checks = find_checks('physical_line')
self.logical_checks = find_checks('logical_line')
options.counters['physical lines'] = \
self.previous_indent_level = self.indent_level
self.indent_level = expand_indent(indent)
if options.verbose >= 2:
- print self.logical_line[:80].rstrip()
+ print(self.logical_line[:80].rstrip())
for name, check, argument_names in self.logical_checks:
if options.verbose >= 3:
- print ' ', name
+ print(' ', name)
result = self.run_check(check, argument_names)
if result is not None:
offset, text = result
- if type(offset) is tuple:
+ if isinstance(offset, tuple):
original_number, original_offset = offset
else:
for token_offset, token in self.mapping:
prefix='E4' matches all errors that have to do with imports
"""
stats = []
- keys = options.messages.keys()
+ keys = list(options.messages.keys())
keys.sort()
for key in keys:
if key.startswith(prefix):
def get_count(prefix=''):
"""Return the total count of errors and warnings."""
- keys = options.messages.keys()
+ keys = list(options.messages.keys())
count = 0
for key in keys:
if key.startswith(prefix):
def print_statistics(prefix=''):
"""Print overall statistics (number of errors and warnings)."""
for line in get_statistics(prefix):
- print line
+ print(line)
def print_benchmark(elapsed):
"""
Print benchmark numbers.
"""
- print '%-7.2f %s' % (elapsed, 'seconds elapsed')
+ print('%-7.2f %s' % (elapsed, 'seconds elapsed'))
keys = ['directories', 'files',
'logical lines', 'physical lines']
for key in keys:
if key in options.counters:
- print '%-7d %s per second (%d total)' % (
+ print('%-7d %s per second (%d total)' % (
options.counters[key] / elapsed, key,
- options.counters[key])
+ options.counters[key]))
def process_options(arglist=None):
if options.benchmark:
print_benchmark(elapsed)
if options.count:
- print get_count()
+ print(get_count())
if __name__ == '__main__':