diff options
| author | cpopa <devnull@localhost> | 2014-08-19 14:42:04 +0300 |
|---|---|---|
| committer | cpopa <devnull@localhost> | 2014-08-19 14:42:04 +0300 |
| commit | 45fbd61f07d7b689a108632d719717473118c245 (patch) | |
| tree | 0a4e1c01a2d7a93c40ae16dc90bd8f1a8dd0593c | |
| parent | 073c0c5140776a1f530f3a83bc3f1c3629776723 (diff) | |
| download | pylint-45fbd61f07d7b689a108632d719717473118c245.tar.gz | |
Cleanup the API, by providing a new report_order method to ReportsHandlerMixIn, which is overriden by PyLinter for consistent output.
| -rw-r--r-- | lint.py | 12 | ||||
| -rw-r--r-- | utils.py | 24 |
2 files changed, 19 insertions, 17 deletions
@@ -420,6 +420,18 @@ class PyLinter(OptionsManagerMixIn, MessagesHandlerMixIn, ReportsHandlerMixIn, def register_reporter(self, reporter_class): self._reporters[reporter_class.name] = reporter_class + def report_order(self): + reports = sorted(self._reports, key=lambda x: getattr(x, 'name', '')) + try: + # Remove the current reporter and add it + # at the end of the list. + reports.pop(reports.index(self)) + except ValueError: + pass + else: + reports.append(self) + return reports + # checkers manipulation methods ############################################ def register_checker(self, checker): @@ -80,8 +80,8 @@ class WarningScope(object): NODE = 'node-based-msg' _MsgBase = collections.namedtuple( - '_MsgBase', - ['msg_id', 'symbol', 'msg', 'C', 'category', 'confidence', + '_MsgBase', + ['msg_id', 'symbol', 'msg', 'C', 'category', 'confidence', 'abspath', 'module', 'obj', 'line', 'column']) @@ -89,7 +89,7 @@ class Message(_MsgBase): """This class represent a message to be issued by the reporters""" def __new__(cls, msg_id, symbol, location, msg, confidence): return _MsgBase.__new__( - cls, msg_id, symbol, msg, msg_id[0], MSG_TYPES[msg_id[0]], + cls, msg_id, symbol, msg, msg_id[0], MSG_TYPES[msg_id[0]], confidence, *location) def format(self, template): @@ -675,21 +675,11 @@ class ReportsHandlerMixIn(object): self._reports = {} self._reports_state = {} - @property - def _sorted_reports(self): + def report_order(self): """ Return a list of reports, sorted in the order - of their reporting priority. + in which they must be called. """ - reports = sorted(self._reports, key=lambda x: getattr(x, 'name', '')) - try: - # Remove the current reporter and add it - # at the end of the list. - reports.pop(reports.index(self)) - except ValueError: - pass - else: - reports.append(self) - return reports + return list(self._reports) def register_report(self, reportid, r_title, r_cb, checker): """register a report @@ -722,7 +712,7 @@ class ReportsHandlerMixIn(object): """render registered reports""" sect = Section('Report', '%s statements analysed.'% (self.stats['statement'])) - for checker in self._sorted_reports: + for checker in self.report_order(): for reportid, r_title, r_cb in self._reports[checker]: if not self.report_is_enabled(reportid): continue |
