Show More
@@ -251,7 +251,7 b' def getblame(f):' | |||||
251 | return lines |
|
251 | return lines | |
252 |
|
252 | |||
253 | def checkfile(f, logfunc=_defaultlogger.log, maxerr=None, warnings=False, |
|
253 | def checkfile(f, logfunc=_defaultlogger.log, maxerr=None, warnings=False, | |
254 | blame=False): |
|
254 | blame=False, debug=False): | |
255 | """checks style and portability of a given file |
|
255 | """checks style and portability of a given file | |
256 |
|
256 | |||
257 | :f: filepath |
|
257 | :f: filepath | |
@@ -265,13 +265,21 b' def checkfile(f, logfunc=_defaultlogger.' | |||||
265 | blamecache = None |
|
265 | blamecache = None | |
266 | result = True |
|
266 | result = True | |
267 | for name, match, filters, pats in checks: |
|
267 | for name, match, filters, pats in checks: | |
|
268 | if debug: | |||
|
269 | print name, f | |||
268 | fc = 0 |
|
270 | fc = 0 | |
269 | if not re.match(match, f): |
|
271 | if not re.match(match, f): | |
|
272 | if debug: | |||
|
273 | print "Skipping %s for %s it doesn't match %s" % ( | |||
|
274 | name, match, f) | |||
270 | continue |
|
275 | continue | |
271 | fp = open(f) |
|
276 | fp = open(f) | |
272 | pre = post = fp.read() |
|
277 | pre = post = fp.read() | |
273 | fp.close() |
|
278 | fp.close() | |
274 | if "no-" + "check-code" in pre: |
|
279 | if "no-" + "check-code" in pre: | |
|
280 | if debug: | |||
|
281 | print "Skipping %s for %s it has no- and check-code" % ( | |||
|
282 | name, f) | |||
275 | break |
|
283 | break | |
276 | for p, r in filters: |
|
284 | for p, r in filters: | |
277 | post = re.sub(p, r, post) |
|
285 | post = re.sub(p, r, post) | |
@@ -281,8 +289,13 b' def checkfile(f, logfunc=_defaultlogger.' | |||||
281 | pats = pats[0] |
|
289 | pats = pats[0] | |
282 | # print post # uncomment to show filtered version |
|
290 | # print post # uncomment to show filtered version | |
283 | z = enumerate(zip(pre.splitlines(), post.splitlines(True))) |
|
291 | z = enumerate(zip(pre.splitlines(), post.splitlines(True))) | |
|
292 | if debug: | |||
|
293 | print "Checking %s for %s" % (name, f) | |||
284 | for n, l in z: |
|
294 | for n, l in z: | |
285 | if "check-code" + "-ignore" in l[0]: |
|
295 | if "check-code" + "-ignore" in l[0]: | |
|
296 | if debug: | |||
|
297 | print "Skipping %s for %s:%s (check-code -ignore)" % ( | |||
|
298 | name, f, n) | |||
286 | continue |
|
299 | continue | |
287 | for p, msg in pats: |
|
300 | for p, msg in pats: | |
288 | if re.search(p, l[1]): |
|
301 | if re.search(p, l[1]): | |
@@ -312,8 +325,10 b' if __name__ == "__main__":' | |||||
312 | help="max warnings per file") |
|
325 | help="max warnings per file") | |
313 | parser.add_option("-b", "--blame", action="store_true", |
|
326 | parser.add_option("-b", "--blame", action="store_true", | |
314 | help="use annotate to generate blame info") |
|
327 | help="use annotate to generate blame info") | |
|
328 | parser.add_option("", "--debug", action="store_true", | |||
|
329 | help="show debug information") | |||
315 |
|
330 | |||
316 | parser.set_defaults(per_file=15, warnings=False, blame=False) |
|
331 | parser.set_defaults(per_file=15, warnings=False, blame=False, debug=False) | |
317 | (options, args) = parser.parse_args() |
|
332 | (options, args) = parser.parse_args() | |
318 |
|
333 | |||
319 | if len(args) == 0: |
|
334 | if len(args) == 0: | |
@@ -324,6 +339,6 b' if __name__ == "__main__":' | |||||
324 | for f in check: |
|
339 | for f in check: | |
325 | ret = 0 |
|
340 | ret = 0 | |
326 | if not checkfile(f, maxerr=options.per_file, warnings=options.warnings, |
|
341 | if not checkfile(f, maxerr=options.per_file, warnings=options.warnings, | |
327 | blame=options.blame): |
|
342 | blame=options.blame, debug=options.debug): | |
328 | ret = 1 |
|
343 | ret = 1 | |
329 | sys.exit(ret) |
|
344 | sys.exit(ret) |
General Comments 0
You need to be logged in to leave comments.
Login now