3 # WARNING! Do not edit! https://waf.io/book/index.html#_obtaining_the_waf_file
8 # written by Sylvain Rouquette, 2011
16 To add the pep8 tool to the waf file:
17 $ ./waf-light --tools=compat15,pep8
18 or, if you have waf >= 1.6.2
19 $ ./waf update --files=pep8
22 Then add this to your wscript:
24 [at]extension('.py', 'wscript')
25 def run_pep8(self, node):
26 self.create_task('Pep8', node)
31 from waflib import Task, Options
33 pep8 = __import__('pep8')
36 class Pep8(Task.Task):
38 lock = threading.Lock()
40 def check_options(self):
43 pep8.options = Options.options
44 pep8.options.prog = 'pep8'
45 excl = pep8.options.exclude.split(',')
46 pep8.options.exclude = [s.rstrip('/') for s in excl]
47 if pep8.options.filename:
48 pep8.options.filename = pep8.options.filename.split(',')
49 if pep8.options.select:
50 pep8.options.select = pep8.options.select.split(',')
52 pep8.options.select = []
53 if pep8.options.ignore:
54 pep8.options.ignore = pep8.options.ignore.split(',')
55 elif pep8.options.select:
56 # Ignore all checks which are not explicitly selected
57 pep8.options.ignore = ['']
58 elif pep8.options.testsuite or pep8.options.doctest:
59 # For doctest and testsuite, all checks are required
60 pep8.options.ignore = []
62 # The default choice: ignore controversial checks
63 pep8.options.ignore = pep8.DEFAULT_IGNORE.split(',')
64 pep8.options.physical_checks = pep8.find_checks('physical_line')
65 pep8.options.logical_checks = pep8.find_checks('logical_line')
66 pep8.options.counters = dict.fromkeys(pep8.BENCHMARK_KEYS, 0)
67 pep8.options.messages = {}
72 pep8.input_file(self.inputs[0].abspath())
73 return 0 if not pep8.get_count() else -1
77 opt.add_option('-q', '--quiet', default=0, action='count',
78 help="report only file names, or nothing with -qq")
79 opt.add_option('-r', '--repeat', action='store_true',
80 help="show all occurrences of the same error")
81 opt.add_option('--exclude', metavar='patterns',
82 default=pep8.DEFAULT_EXCLUDE,
83 help="exclude files or directories which match these "
84 "comma separated patterns (default: %s)" %
87 opt.add_option('--filename', metavar='patterns', default='*.py',
88 help="when parsing directories, only check filenames "
89 "matching these comma separated patterns (default: "
91 opt.add_option('--select', metavar='errors', default='',
92 help="select errors and warnings (e.g. E,W6)")
93 opt.add_option('--ignore', metavar='errors', default='',
94 help="skip errors and warnings (e.g. E4,W)")
95 opt.add_option('--show-source', action='store_true',
96 help="show source code for each error")
97 opt.add_option('--show-pep8', action='store_true',
98 help="show text of PEP 8 for each error")
99 opt.add_option('--statistics', action='store_true',
100 help="count errors and warnings")
101 opt.add_option('--count', action='store_true',
102 help="print total number of errors and warnings "
103 "to standard error and set exit code to 1 if "
105 opt.add_option('--benchmark', action='store_true',
106 help="measure processing speed")
107 opt.add_option('--testsuite', metavar='dir',
108 help="run regression tests from dir")
109 opt.add_option('--doctest', action='store_true',
110 help="run doctest on myself")