diff options
author | Florent Xicluna <florent.xicluna@gmail.com> | 2012-06-12 15:13:23 +0200 |
---|---|---|
committer | Florent Xicluna <florent.xicluna@gmail.com> | 2012-06-12 15:13:23 +0200 |
commit | 362c76e182a5a60d70ccc8c33a03dc18bc4b27e5 (patch) | |
tree | 33c556cd722b823c861caecd3a4d023a5415e232 | |
parent | d1b19b7cbe10e5598c5b618cc6d078e3b022c7be (diff) | |
download | pep8-362c76e182a5a60d70ccc8c33a03dc18bc4b27e5.tar.gz |
The report initialization belongs to the report.
-rwxr-xr-x | pep8.py | 27 |
1 files changed, 14 insertions, 13 deletions
@@ -145,7 +145,6 @@ KEYWORD_REGEX = re.compile(r'(?:[^\s])(\s*)\b(?:%s)\b(\s*)' % OPERATOR_REGEX = re.compile(r'(?:[^\s])(\s*)(?:[-+*/|!<=>%&^]+)(\s*)') LAMBDA_REGEX = re.compile(r'\blambda\b') - WHITESPACE = frozenset(' \t') BINARY_OPERATORS = frozenset([ '**=', '*=', '+=', '-=', '!=', '<>', @@ -1195,7 +1194,6 @@ class Checker(object): self.lines = lines self.report = report or options.report self.report_error = self.report.error - self.report.counters['physical lines'] += len(self.lines) def readline(self): """ @@ -1276,7 +1274,7 @@ class Checker(object): """ Build a line from tokens and run all logical checks on it. """ - self.report.counters['logical lines'] += 1 + self.report.count_logical_line() self.build_tokens_line() first_line = self.lines[self.mapping[0][1][2][0] - 1] indent = first_line[:self.mapping[0][1][2][1]] @@ -1320,7 +1318,7 @@ class Checker(object): """ Run all checks on the input file. """ - self.report_setfile(expected, line_offset) + self.report.init_file(self.filename, self.lines, expected, line_offset) self.line_number = 0 self.indent_char = None self.indent_level = 0 @@ -1370,15 +1368,6 @@ class Checker(object): self.tokens = [] return self.report.file_errors - def report_setfile(self, expected, line_offset): - report = self.report - report.filename = self.filename - report.lines = self.lines - report.file_errors = 0 - report.expected = expected or () - report.line_offset = line_offset - report.counters['files'] += 1 - class BasicReport(object): print_filename = False @@ -1404,6 +1393,18 @@ class BasicReport(object): del self.counters[key] self.messages = {} + def init_file(self, filename, lines, expected, line_offset): + self.filename = filename + self.lines = lines + self.expected = expected or () + self.line_offset = line_offset + self.file_errors = 0 + self.counters['files'] += 1 + self.counters['physical lines'] += len(lines) + + def count_logical_line(self): + self.counters['logical lines'] += 1 + def error(self, line_number, offset, text, check): """ Report an error, according to options. |