diff options
author | Florent Xicluna <florent.xicluna@gmail.com> | 2013-02-09 17:08:24 +0100 |
---|---|---|
committer | Florent Xicluna <florent.xicluna@gmail.com> | 2013-02-09 17:08:24 +0100 |
commit | d7f9a49f6bfcb45d0f82256aaca7e4a373e54d63 (patch) | |
tree | 2f05edae18c9217eeac1fd94cc4eed475ac95c70 | |
parent | 823c2291c33df3f45193f31dca63a6583a30c78a (diff) | |
download | pep8-d7f9a49f6bfcb45d0f82256aaca7e4a373e54d63.tar.gz |
Re-order the lines for the StandardReport
-rw-r--r-- | CHANGES.txt | 2 | ||||
-rwxr-xr-x | pep8.py | 22 |
2 files changed, 20 insertions, 4 deletions
diff --git a/CHANGES.txt b/CHANGES.txt index b80a15a..f5ff3ff 100644 --- a/CHANGES.txt +++ b/CHANGES.txt @@ -17,6 +17,8 @@ Changelog * Fix UnboundLocalError when using ``# noqa`` with continued lines. (Issue #158) +* Re-order the lines for the ``StandardReport``. + 1.4.1 (2013-01-18) ------------------ @@ -1507,15 +1507,29 @@ class StandardReport(BaseReport): self._show_source = options.show_source self._show_pep8 = options.show_pep8 + def init_file(self, filename, lines, expected, line_offset): + """Signal a new file.""" + self._deferred_print = [] + return super(StandardReport, self).init_file( + filename, lines, expected, line_offset) + def error(self, line_number, offset, text, check): """Report an error, according to options.""" code = super(StandardReport, self).error(line_number, offset, text, check) if code and (self.counters[code] == 1 or self._repeat): + self._deferred_print.append( + (line_number, offset, code, text[5:], check.__doc__)) + return code + + def get_file_results(self): + """Print the result and return the overall count for this file.""" + self._deferred_print.sort() + for line_number, offset, code, text, doc in self._deferred_print: print(self._fmt % { 'path': self.filename, 'row': self.line_offset + line_number, 'col': offset + 1, - 'code': code, 'text': text[5:], + 'code': code, 'text': text, }) if self._show_source: if line_number > len(self.lines): @@ -1524,9 +1538,9 @@ class StandardReport(BaseReport): line = self.lines[line_number - 1] print(line.rstrip()) print(' ' * offset + '^') - if self._show_pep8: - print(check.__doc__.lstrip('\n').rstrip()) - return code + if self._show_pep8 and doc: + print(doc.lstrip('\n').rstrip()) + return self.file_errors class DiffReport(StandardReport): |