closes #73941: HTML reports badly formatted since col_offset addition, which was only partially added to the report

authorSylvain Thénault <sylvain.thenault@logilab.fr>
changesetedc4c99cbd33
branchdefault
phasepublic
hiddenno
parent revision#c30b0473b310 better message for E0202 (closes #77237)
child revision#db15dcd07ce0 0.25
files modified by this revision
ChangeLog
reporters/html.py
# HG changeset patch
# User Sylvain Thénault <sylvain.thenault@logilab.fr>
# Date 1317717127 -7200
# Tue Oct 04 10:32:07 2011 +0200
# Node ID edc4c99cbd3377741b16099847a3164f3a59e009
# Parent c30b0473b310451263ca03f93a698441eb54d48c
closes #73941: HTML reports badly formatted since col_offset addition, which was only partially added to the report

diff --git a/ChangeLog b/ChangeLog
@@ -16,10 +16,12 @@
1 
2      * #76920: crash if on eg "pylint --rcfile"(patch by Torsten Marek)
3 
4      * #77237: warning for E0202 may be very misleading
5 
6 +    * #73941: HTML report messages table is badly rendered
7 +
8 
9  2011-07-18  --  0.24.0
10      * #69738: add regular expressions support for "generated-members"
11 
12      * ids of logging and string_format checkers have been changed:
diff --git a/reporters/html.py b/reporters/html.py
@@ -1,7 +1,7 @@
13  # Copyright (c) 2003-2006 Sylvain Thenault (thenault@gmail.com).
14 -# Copyright (c) 2003-2006 LOGILAB S.A. (Paris, FRANCE).
15 +# Copyright (c) 2003-2011 LOGILAB S.A. (Paris, FRANCE).
16  # This program is free software; you can redistribute it and/or modify it under
17  # the terms of the GNU General Public License as published by the Free Software
18  # Foundation; either version 2 of the License, or (at your option) any later
19  # version.
20  #
@@ -26,11 +26,11 @@
21  class HTMLReporter(BaseReporter):
22      """report messages and layouts in HTML"""
23 
24      __implements__ = IReporter
25      extension = 'html'
26 -    
27 +
28      def __init__(self, output=sys.stdout):
29          BaseReporter.__init__(self, output)
30          self.msgs = []
31 
32      def add_message(self, msg_id, location, msg):
@@ -38,32 +38,32 @@
33          module, obj, line, col_offset = location[1:]
34          if self.include_ids:
35              sigle = msg_id
36          else:
37              sigle = msg_id[0]
38 -        self.msgs += [sigle, module, obj, str(line), escape(msg)]
39 -        
40 +        self.msgs += [sigle, module, obj, str(line), str(col_offset), escape(msg)]
41 +
42      def set_output(self, output=None):
43          """set output stream
44 -        
45 +
46          messages buffered for old output is processed first"""
47          if self.out and self.msgs:
48              self._display(Section())
49          BaseReporter.set_output(self, output)
50 -        
51 +
52      def _display(self, layout):
53          """launch layouts display
54 -        
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=5, children=msgs, rheaders=1))
67 +            sect.append(Table(cols=6, children=msgs, rheaders=1))
68              self.msgs = []
69          HTMLWriter().format(layout, self.out)
70