guireporter.py 990 B

123456789101112131415161718192021222324252627282930313233343536
  1. """ reporter used by gui.py """
  2. import sys
  3. from pylint.interfaces import IReporter
  4. from pylint.reporters import BaseReporter
  5. from logilab.common.ureports import TextWriter
  6. class GUIReporter(BaseReporter):
  7. """saves messages"""
  8. __implements__ = IReporter
  9. extension = ''
  10. def __init__(self, gui, output=sys.stdout):
  11. """init"""
  12. BaseReporter.__init__(self, output)
  13. self.msgs = []
  14. self.gui = gui
  15. def add_message(self, msg_id, location, msg):
  16. """manage message of different type and in the context of path"""
  17. module, obj, line, col_offset = location[1:]
  18. if self.include_ids:
  19. sigle = msg_id
  20. else:
  21. sigle = msg_id[0]
  22. full_msg = [sigle, module, obj, str(line), msg]
  23. self.msgs += [[sigle, module, obj, str(line)]]
  24. self.gui.msg_queue.put(full_msg)
  25. def _display(self, layout):
  26. """launch layouts display"""
  27. TextWriter().format(layout, self.out)