Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1)

Side by Side Diff: third_party/pylint/reporters/html.py

Issue 10447014: Add pylint to depot_tools. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/tools/depot_tools
Patch Set: Fix unittests. Created 8 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « third_party/pylint/reporters/guireporter.py ('k') | third_party/pylint/reporters/text.py » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 # Copyright (c) 2003-2006 Sylvain Thenault (thenault@gmail.com).
2 # Copyright (c) 2003-2011 LOGILAB S.A. (Paris, FRANCE).
3 # This program is free software; you can redistribute it and/or modify it under
4 # the terms of the GNU General Public License as published by the Free Software
5 # Foundation; either version 2 of the License, or (at your option) any later
6 # version.
7 #
8 # This program is distributed in the hope that it will be useful, but WITHOUT
9 # ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
10 # FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
11 #
12 # You should have received a copy of the GNU General Public License along with
13 # this program; if not, write to the Free Software Foundation, Inc.,
14 # 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
15 """HTML reporter"""
16
17 import sys
18 from cgi import escape
19
20 from logilab.common.ureports import HTMLWriter, Section, Table
21
22 from pylint.interfaces import IReporter
23 from pylint.reporters import BaseReporter
24
25
26 class HTMLReporter(BaseReporter):
27 """report messages and layouts in HTML"""
28
29 __implements__ = IReporter
30 extension = 'html'
31
32 def __init__(self, output=sys.stdout):
33 BaseReporter.__init__(self, output)
34 self.msgs = []
35
36 def add_message(self, msg_id, location, msg):
37 """manage message of different type and in the context of path"""
38 module, obj, line, col_offset = location[1:]
39 if self.include_ids:
40 sigle = msg_id
41 else:
42 sigle = msg_id[0]
43 self.msgs += [sigle, module, obj, str(line), str(col_offset), escape(msg )]
44
45 def set_output(self, output=None):
46 """set output stream
47
48 messages buffered for old output is processed first"""
49 if self.out and self.msgs:
50 self._display(Section())
51 BaseReporter.set_output(self, output)
52
53 def _display(self, layout):
54 """launch layouts display
55
56 overridden from BaseReporter to add insert the messages section
57 (in add_message, message is not displayed, just collected so it
58 can be displayed in an html table)
59 """
60 if self.msgs:
61 # add stored messages to the layout
62 msgs = ['type', 'module', 'object', 'line', 'col_offset', 'message']
63 msgs += self.msgs
64 sect = Section('Messages')
65 layout.append(sect)
66 sect.append(Table(cols=6, children=msgs, rheaders=1))
67 self.msgs = []
68 HTMLWriter().format(layout, self.out)
69
OLDNEW
« no previous file with comments | « third_party/pylint/reporters/guireporter.py ('k') | third_party/pylint/reporters/text.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698