381 self.trUtf8("Error: {0}").format(str(msg))\ |
381 self.trUtf8("Error: {0}").format(str(msg))\ |
382 .rstrip()[1:-1], False, False) |
382 .rstrip()[1:-1], False, False) |
383 progress += 1 |
383 progress += 1 |
384 continue |
384 continue |
385 |
385 |
|
386 stats = {} |
386 flags = Utilities.extractFlags(source) |
387 flags = Utilities.extractFlags(source) |
387 ext = os.path.splitext(file)[1] |
388 ext = os.path.splitext(file)[1] |
388 if fixIssues: |
389 if fixIssues: |
389 from .Pep8Fixer import Pep8Fixer |
390 from .Pep8Fixer import Pep8Fixer |
390 fixer = Pep8Fixer(self.__project, file, source, |
391 fixer = Pep8Fixer(self.__project, file, source, |
407 select=includeMessages, |
408 select=includeMessages, |
408 ignore=excludeMessages, |
409 ignore=excludeMessages, |
409 max_line_length=maxLineLength, |
410 max_line_length=maxLineLength, |
410 hang_closing=hangClosing, |
411 hang_closing=hangClosing, |
411 ) |
412 ) |
412 report.errors.sort(key=lambda a: a[1]) |
413 errors = report.errors[:] |
|
414 stats.update(report.counters) |
413 # TODO: add PEP-257 check for Py2 |
415 # TODO: add PEP-257 check for Py2 |
414 else: |
416 else: |
415 if includeMessages: |
417 if includeMessages: |
416 select = [s.strip() for s in includeMessages.split(',') |
418 select = [s.strip() for s in includeMessages.split(',') |
417 if s.strip()] |
419 if s.strip()] |
431 ignore=ignore, |
433 ignore=ignore, |
432 max_line_length=maxLineLength, |
434 max_line_length=maxLineLength, |
433 hang_closing=hangClosing, |
435 hang_closing=hangClosing, |
434 ) |
436 ) |
435 report = styleGuide.check_files([file]) |
437 report = styleGuide.check_files([file]) |
436 report.errors.sort(key=lambda a: a[1]) |
438 stats.update(report.counters) |
437 |
439 |
438 # check PEP-257 |
440 # check PEP-257 |
439 pep257Checker = Pep257Checker( |
441 pep257Checker = Pep257Checker( |
440 source, file, select, ignore, [], repeatMessages, |
442 source, file, select, ignore, [], repeatMessages, |
441 maxLineLength=maxLineLength) |
443 maxLineLength=maxLineLength) |
442 pep257Checker.run() |
444 pep257Checker.run() |
443 pep257Checker.errors.sort(key=lambda a: a[1]) |
445 stats.update(pep257Checker.counters) |
|
446 |
|
447 errors = report.errors + pep257Checker.errors |
444 |
448 |
445 deferredFixes = {} |
449 deferredFixes = {} |
446 for error in report.errors + pep257Checker.errors: |
450 for error in errors: |
447 fname, lineno, position, text = error |
451 fname, lineno, position, text = error |
448 if lineno > len(source): |
452 if lineno > len(source): |
449 lineno = len(source) |
453 lineno = len(source) |
450 if "__IGNORE_WARNING__" not in Utilities.extractLineFlags( |
454 if "__IGNORE_WARNING__" not in Utilities.extractLineFlags( |
451 source[lineno - 1].strip()): |
455 source[lineno - 1].strip()): |
477 text = "\n" + self.trUtf8("Fix: {0}").format(msg) |
481 text = "\n" + self.trUtf8("Fix: {0}").format(msg) |
478 self.__modifyFixedResultItem(itm, text, True) |
482 self.__modifyFixedResultItem(itm, text, True) |
479 else: |
483 else: |
480 self.__modifyFixedResultItem(itm, "", False) |
484 self.__modifyFixedResultItem(itm, "", False) |
481 fixer.saveFile(encoding) |
485 fixer.saveFile(encoding) |
482 stats = {} |
|
483 stats.update(report.counters) |
|
484 stats.update(pep257Checker.counters) |
|
485 self.__updateStatistics(stats, fixer) |
486 self.__updateStatistics(stats, fixer) |
486 progress += 1 |
487 progress += 1 |
487 finally: |
488 finally: |
488 # reenable updates of the list |
489 # reenable updates of the list |
489 self.resultList.setSortingEnabled(True) |
490 self.resultList.setSortingEnabled(True) |