15 import pep8 |
15 import pep8 |
16 from Pep8NamingCheckerPy2 import Pep8NamingChecker |
16 from Pep8NamingCheckerPy2 import Pep8NamingChecker |
17 |
17 |
18 # register the name checker |
18 # register the name checker |
19 pep8.register_check(Pep8NamingChecker, Pep8NamingChecker.Codes) |
19 pep8.register_check(Pep8NamingChecker, Pep8NamingChecker.Codes) |
|
20 |
|
21 from Pep257CheckerPy2 import Pep257Checker |
20 |
22 |
21 |
23 |
22 class Pep8Report(pep8.BaseReport): |
24 class Pep8Report(pep8.BaseReport): |
23 """ |
25 """ |
24 Class implementing a special report to be used with our dialog. |
26 Class implementing a special report to be used with our dialog. |
110 if ignore: |
112 if ignore: |
111 ignore = [i.strip() for i in ignore.split(',') |
113 ignore = [i.strip() for i in ignore.split(',') |
112 if i.strip()] |
114 if i.strip()] |
113 else: |
115 else: |
114 ignore = [] |
116 ignore = [] |
|
117 |
|
118 # check PEP-8 |
115 styleGuide = pep8.StyleGuide( |
119 styleGuide = pep8.StyleGuide( |
116 reporter=Pep8Report, |
120 reporter=Pep8Report, |
117 repeat=repeat, |
121 repeat=repeat, |
118 select=select, |
122 select=select, |
119 ignore=ignore, |
123 ignore=ignore, |
120 max_line_length=max_line_length, |
124 max_line_length=max_line_length, |
121 hang_closing=hang_closing, |
125 hang_closing=hang_closing, |
122 ) |
126 ) |
123 report = styleGuide.check_files([filename]) |
127 report = styleGuide.check_files([filename]) |
124 report.errors.sort(key=lambda a: a[1]) |
128 |
125 if len(report.errors) > 0: |
129 # check PEP-257 |
126 report.errors.sort(key=lambda a: a[1]) |
130 pep257Checker = Pep257Checker( |
127 for error in report.errors: |
131 source, file, select, ignore, [], repeat, |
|
132 maxLineLength=max_line_length) |
|
133 pep257Checker.run() |
|
134 |
|
135 |
|
136 errors = report.errors + pep257Checker.errors |
|
137 |
|
138 if len(errors) > 0: |
|
139 errors.sort(key=lambda a: a[1]) |
|
140 for error in errors: |
128 fname, lineno, position, code, args = error |
141 fname, lineno, position, code, args = error |
129 print "PEP8" |
142 print "PEP8" |
130 print fname |
143 print fname |
131 print lineno |
144 print lineno |
132 print position |
145 print position |