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

Unified Diff: third_party/pylint/reporters/text.py

Issue 719313003: Revert "pylint: upgrade to 1.3.1" (Closed) Base URL: https://chromium.googlesource.com/chromium/tools/depot_tools.git@master
Patch Set: Created 6 years, 1 month 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « third_party/pylint/reporters/html.py ('k') | third_party/pylint/testutils.py » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: third_party/pylint/reporters/text.py
diff --git a/third_party/pylint/reporters/text.py b/third_party/pylint/reporters/text.py
index 04245f70ed4fb2bd0fd10f4d2624c034df6e8873..032df6b162f2d7f85340cc3a161f3a8bba9cce4d 100644
--- a/third_party/pylint/reporters/text.py
+++ b/third_party/pylint/reporters/text.py
@@ -1,4 +1,5 @@
-# Copyright (c) 2003-2013 LOGILAB S.A. (Paris, FRANCE).
+# Copyright (c) 2003-2007 Sylvain Thenault (thenault@gmail.com).
+# Copyright (c) 2003-2011 LOGILAB S.A. (Paris, FRANCE).
# This program is free software; you can redistribute it and/or modify it under
# the terms of the GNU General Public License as published by the Free Software
# Foundation; either version 2 of the License, or (at your option) any later
@@ -10,54 +11,56 @@
#
# You should have received a copy of the GNU General Public License along with
# this program; if not, write to the Free Software Foundation, Inc.,
-# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+# 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
"""Plain text reporters:
:text: the default one grouping messages by module
+:parseable:
+ standard parseable output with full module path on each message (for
+ editor integration)
:colorized: an ANSI colorized text reporter
+
"""
-import warnings
+import os
+import sys
from logilab.common.ureports import TextWriter
from logilab.common.textutils import colorize_ansi
from pylint.interfaces import IReporter
-from pylint.reporters import BaseReporter, Message
+from pylint.reporters import BaseReporter
TITLE_UNDERLINES = ['', '=', '-', '.']
class TextReporter(BaseReporter):
- """reports messages and layouts in plain text"""
+ """reports messages and layouts in plain text
+ """
__implements__ = IReporter
- name = 'text'
extension = 'txt'
- line_format = '{C}:{line:3d},{column:2d}: {msg} ({symbol})'
- def __init__(self, output=None):
+ def __init__(self, output=sys.stdout):
BaseReporter.__init__(self, output)
- self._modules = set()
- self._template = None
-
- def on_set_current_module(self, module, filepath):
- self._template = unicode(self.linter.config.msg_template or self.line_format)
-
- def write_message(self, msg):
- """Convenience method to write a formated message with class default template"""
- self.writeln(msg.format(self._template))
+ self._modules = {}
def add_message(self, msg_id, location, msg):
"""manage message of different type and in the context of path"""
- m = Message(self, msg_id, location, msg)
- if m.module not in self._modules:
- if m.module:
- self.writeln('************* Module %s' % m.module)
- self._modules.add(m.module)
+ path, module, obj, line, col_offset = location
+ if module not in self._modules:
+ if module:
+ self.writeln('************* Module %s' % (path if path else module))
+ self._modules[module] = 1
else:
- self.writeln('************* ')
- self.write_message(m)
+ self.writeln('************* %s' % module)
+ if obj:
+ obj = ':%s' % obj
+ if self.include_ids:
+ sigle = msg_id
+ else:
+ sigle = msg_id[0]
+ self.writeln('%s:%3s,%s%s: %s' % (sigle, line, col_offset, obj, msg))
def _display(self, layout):
"""launch layouts display"""
@@ -71,25 +74,35 @@ class ParseableTextReporter(TextReporter):
<filename>:<linenum>:<msg>
"""
- name = 'parseable'
- line_format = '{path}:{line}: [{msg_id}({symbol}), {obj}] {msg}'
+ line_format = '%(path)s:%(line)s: [%(sigle)s%(obj)s] %(msg)s'
- def __init__(self, output=None):
- warnings.warn('%s output format is deprecated. This is equivalent '
- 'to --msg-template=%s' % (self.name, self.line_format))
+ def __init__(self, output=sys.stdout, relative=True):
TextReporter.__init__(self, output)
+ if relative:
+ self._prefix = os.getcwd() + os.sep
+ else:
+ self._prefix = ''
+ def add_message(self, msg_id, location, msg):
+ """manage message of different type and in the context of path"""
+ path, _, obj, line, _ = location
+ if obj:
+ obj = ', %s' % obj
+ if self.include_ids:
+ sigle = msg_id
+ else:
+ sigle = msg_id[0]
+ if self._prefix:
+ path = path.replace(self._prefix, '')
+ self.writeln(self.line_format % locals())
class VSTextReporter(ParseableTextReporter):
"""Visual studio text reporter"""
- name = 'msvs'
- line_format = '{path}({line}): [{msg_id}({symbol}){obj}] {msg}'
-
+ line_format = '%(path)s(%(line)s): [%(sigle)s%(obj)s] %(msg)s'
class ColorizedTextReporter(TextReporter):
"""Simple TextReporter that colorizes text output"""
- name = 'colorized'
COLOR_MAPPING = {
"I" : ("green", None),
'C' : (None, "bold"),
@@ -100,11 +113,12 @@ class ColorizedTextReporter(TextReporter):
'S' : ("yellow", "inverse"), # S stands for module Separator
}
- def __init__(self, output=None, color_mapping=None):
+ def __init__(self, output=sys.stdout, color_mapping = None):
TextReporter.__init__(self, output)
self.color_mapping = color_mapping or \
dict(ColorizedTextReporter.COLOR_MAPPING)
+
def _get_decoration(self, msg_id):
"""Returns the tuple color, style associated with msg_id as defined
in self.color_mapping
@@ -118,26 +132,24 @@ class ColorizedTextReporter(TextReporter):
"""manage message of different types, and colorize output
using ansi escape codes
"""
- msg = Message(self, msg_id, location, msg)
- if msg.module not in self._modules:
+ module, obj, line, _ = location[1:]
+ if module not in self._modules:
color, style = self._get_decoration('S')
- if msg.module:
- modsep = colorize_ansi('************* Module %s' % msg.module,
+ if module:
+ modsep = colorize_ansi('************* Module %s' % module,
color, style)
else:
- modsep = colorize_ansi('************* %s' % msg.module,
+ modsep = colorize_ansi('************* %s' % module,
color, style)
self.writeln(modsep)
- self._modules.add(msg.module)
- color, style = self._get_decoration(msg.C)
- for attr in ('msg', 'symbol', 'category', 'C'):
- setattr(msg, attr, colorize_ansi(getattr(msg, attr), color, style))
- self.write_message(msg)
-
-
-def register(linter):
- """Register the reporter classes with the linter."""
- linter.register_reporter(TextReporter)
- linter.register_reporter(ParseableTextReporter)
- linter.register_reporter(VSTextReporter)
- linter.register_reporter(ColorizedTextReporter)
+ self._modules[module] = 1
+ if obj:
+ obj = ':%s' % obj
+ if self.include_ids:
+ sigle = msg_id
+ else:
+ sigle = msg_id[0]
+ color, style = self._get_decoration(sigle)
+ msg = colorize_ansi(msg, color, style)
+ sigle = colorize_ansi(sigle, color, style)
+ self.writeln('%s:%3s%s: %s' % (sigle, line, obj, msg))
« no previous file with comments | « third_party/pylint/reporters/html.py ('k') | third_party/pylint/testutils.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698