From 2eec485a6500d5f40308c2651a0ada47d4f97bfc Mon Sep 17 00:00:00 2001 From: INADA Naoki Date: Sat, 27 Dec 2014 18:03:53 +0900 Subject: [PATCH 1/2] flush() for each print() --- flake8/reporter.py | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) diff --git a/flake8/reporter.py b/flake8/reporter.py index 9a14602..eba7f1f 100644 --- a/flake8/reporter.py +++ b/flake8/reporter.py @@ -93,3 +93,34 @@ class BaseQReport(pep8.BaseReport): class QueueReport(pep8.StandardReport, BaseQReport): """Standard Queue Report.""" + + 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, + }) + # stdout is block buffered when not stdout.isatty(). + # line can be broken where buffer boundary since other processes + # write to same file. + # flush() after print() to avoid buffer boundary. + # Typical buffer size is 8192. line written safely when + # len(line) < 8192. + sys.stdout.flush() + if self._show_source: + if line_number > len(self.lines): + line = '' + else: + line = self.lines[line_number - 1] + print(line.rstrip()) + sys.stdout.flush() + print(re.sub(r'\S', ' ', line[:offset]) + '^') + sys.stdout.flush() + if self._show_pep8 and doc: + print(' ' + doc.strip()) + sys.stdout.flush() + return self.file_errors From 776b93a72bca3fd8242d50f671294b00c4f170b1 Mon Sep 17 00:00:00 2001 From: INADA Naoki Date: Sat, 27 Dec 2014 19:25:30 +0900 Subject: [PATCH 2/2] Fix missing import --- flake8/reporter.py | 1 + 1 file changed, 1 insertion(+) diff --git a/flake8/reporter.py b/flake8/reporter.py index eba7f1f..5cf17e4 100644 --- a/flake8/reporter.py +++ b/flake8/reporter.py @@ -2,6 +2,7 @@ # Adapted from a contribution of Johan Dahlin import collections +import re import sys try: import multiprocessing