Commits

Anonymous committed 4415984

Cleanup the API, by providing a new report_order method to ReportsHandlerMixIn, which is overriden by PyLinter for consistent output.

  • Participants
  • Parent commits 9536251

Comments (0)

Files changed (2)

     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):
     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'])
 
 
     """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):
         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
         """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