UtilitiesPython2/CodeStyleChecker.py

changeset 2984
031cceaa8b01
parent 2983
f2f33024b001
child 3034
7ce719013078
equal deleted inserted replaced
2983:f2f33024b001 2984:031cceaa8b01
118 ignore = [i.strip() for i in ignore.split(',') 118 ignore = [i.strip() for i in ignore.split(',')
119 if i.strip()] 119 if i.strip()]
120 else: 120 else:
121 ignore = [] 121 ignore = []
122 122
123 # check PEP-8 123 # check coding style
124 styleGuide = pep8.StyleGuide( 124 styleGuide = pep8.StyleGuide(
125 reporter=CodeStyleReport, 125 reporter=CodeStyleReport,
126 repeat=repeat, 126 repeat=repeat,
127 select=select, 127 select=select,
128 ignore=ignore, 128 ignore=ignore,
129 max_line_length=max_line_length, 129 max_line_length=max_line_length,
130 hang_closing=hang_closing, 130 hang_closing=hang_closing,
131 ) 131 )
132 report = styleGuide.check_files([filename]) 132 report = styleGuide.check_files([filename])
133 133
134 # check PEP-257 134 # check documentation style
135 pep257Checker = DocStyleChecker( 135 docStyleChecker = DocStyleChecker(
136 source, filename, select, ignore, [], repeat, 136 source, filename, select, ignore, [], repeat,
137 maxLineLength=max_line_length, docType=docType) 137 maxLineLength=max_line_length, docType=docType)
138 pep257Checker.run() 138 docStyleChecker.run()
139 139
140 140
141 errors = report.errors + pep257Checker.errors 141 errors = report.errors + docStyleChecker.errors
142 142
143 if len(errors) > 0: 143 if len(errors) > 0:
144 errors.sort(key=lambda a: a[1]) 144 errors.sort(key=lambda a: a[1])
145 for error in errors: 145 for error in errors:
146 fname, lineno, position, code, args = error 146 fname, lineno, position, code, args = error
154 print a 154 print a
155 print "PEP8_STATISTICS" 155 print "PEP8_STATISTICS"
156 for key in report.counters: 156 for key in report.counters:
157 if key.startswith(("E", "N", "W")): 157 if key.startswith(("E", "N", "W")):
158 print key, report.counters[key] 158 print key, report.counters[key]
159 for key in pep257Checker.counters: 159 for key in docStyleChecker.counters:
160 if key.startswith("D"): 160 if key.startswith("D"):
161 print key, pep257Checker.counters[key] 161 print key, docStyleChecker.counters[key]
162 else: 162 else:
163 print "NO_PEP8" 163 print "NO_PEP8"
164 print filename 164 print filename
165 165
166 # 166 #

eric ide

mercurial