OLD | NEW |
1 # Copyright (c) 2003-2013 LOGILAB S.A. (Paris, FRANCE). | 1 # Copyright (c) 2003-2013 LOGILAB S.A. (Paris, FRANCE). |
2 # This program is free software; you can redistribute it and/or modify it under | 2 # This program is free software; you can redistribute it and/or modify it under |
3 # the terms of the GNU General Public License as published by the Free Software | 3 # the terms of the GNU General Public License as published by the Free Software |
4 # Foundation; either version 2 of the License, or (at your option) any later | 4 # Foundation; either version 2 of the License, or (at your option) any later |
5 # version. | 5 # version. |
6 # | 6 # |
7 # This program is distributed in the hope that it will be useful, but WITHOUT | 7 # This program is distributed in the hope that it will be useful, but WITHOUT |
8 # ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS | 8 # ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS |
9 # FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. | 9 # FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. |
10 # | 10 # |
11 # You should have received a copy of the GNU General Public License along with | 11 # You should have received a copy of the GNU General Public License along with |
12 # this program; if not, write to the Free Software Foundation, Inc., | 12 # this program; if not, write to the Free Software Foundation, Inc., |
13 # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. | 13 # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. |
14 """HTML reporter""" | 14 """HTML reporter""" |
15 | 15 |
16 import sys | 16 import sys |
17 from cgi import escape | 17 from cgi import escape |
18 | 18 |
19 from logilab.common.ureports import HTMLWriter, Section, Table | 19 from logilab.common.ureports import HTMLWriter, Section, Table |
20 | 20 |
21 from pylint.interfaces import IReporter | 21 from pylint.interfaces import IReporter |
22 from pylint.reporters import BaseReporter, Message | 22 from pylint.reporters import BaseReporter |
23 | 23 |
24 | 24 |
25 class HTMLReporter(BaseReporter): | 25 class HTMLReporter(BaseReporter): |
26 """report messages and layouts in HTML""" | 26 """report messages and layouts in HTML""" |
27 | 27 |
28 __implements__ = IReporter | 28 __implements__ = IReporter |
29 name = 'html' | 29 name = 'html' |
30 extension = 'html' | 30 extension = 'html' |
31 | 31 |
32 def __init__(self, output=sys.stdout): | 32 def __init__(self, output=sys.stdout): |
33 BaseReporter.__init__(self, output) | 33 BaseReporter.__init__(self, output) |
34 self.msgs = [] | 34 self.msgs = [] |
35 | 35 |
36 def add_message(self, msg_id, location, msg): | 36 def handle_message(self, msg): |
37 """manage message of different type and in the context of path""" | 37 """manage message of different type and in the context of path""" |
38 msg = Message(self, msg_id, location, msg) | |
39 self.msgs += (msg.category, msg.module, msg.obj, | 38 self.msgs += (msg.category, msg.module, msg.obj, |
40 str(msg.line), str(msg.column), escape(msg.msg)) | 39 str(msg.line), str(msg.column), escape(msg.msg)) |
41 | 40 |
42 def set_output(self, output=None): | 41 def set_output(self, output=None): |
43 """set output stream | 42 """set output stream |
44 | 43 |
45 messages buffered for old output is processed first""" | 44 messages buffered for old output is processed first""" |
46 if self.out and self.msgs: | 45 if self.out and self.msgs: |
47 self._display(Section()) | 46 self._display(Section()) |
48 BaseReporter.set_output(self, output) | 47 BaseReporter.set_output(self, output) |
(...skipping 12 matching lines...) Expand all Loading... |
61 sect = Section('Messages') | 60 sect = Section('Messages') |
62 layout.append(sect) | 61 layout.append(sect) |
63 sect.append(Table(cols=6, children=msgs, rheaders=1)) | 62 sect.append(Table(cols=6, children=msgs, rheaders=1)) |
64 self.msgs = [] | 63 self.msgs = [] |
65 HTMLWriter().format(layout, self.out) | 64 HTMLWriter().format(layout, self.out) |
66 | 65 |
67 | 66 |
68 def register(linter): | 67 def register(linter): |
69 """Register the reporter classes with the linter.""" | 68 """Register the reporter classes with the linter.""" |
70 linter.register_reporter(HTMLReporter) | 69 linter.register_reporter(HTMLReporter) |
OLD | NEW |