diff options
author | Sylvain Thénault <sylvain.thenault@logilab.fr> | 2007-02-17 11:23:14 +0100 |
---|---|---|
committer | Sylvain Thénault <sylvain.thenault@logilab.fr> | 2007-02-17 11:23:14 +0100 |
commit | 54d4c1988c5676848b0253bf54272aee301c7934 (patch) | |
tree | 8cd4ad62af70de91ef9baaccb9aa06c9304162de /reporters | |
parent | 2aa82b4af90298f89db6de369ad45f957f0b08e9 (diff) | |
download | pylint-git-54d4c1988c5676848b0253bf54272aee301c7934.tar.gz |
implement #3285: reported for Visual Studio line number reporting (msvs)
Diffstat (limited to 'reporters')
-rw-r--r-- | reporters/text.py | 37 |
1 files changed, 16 insertions, 21 deletions
diff --git a/reporters/text.py b/reporters/text.py index 5bffe645e..2cc7a212a 100644 --- a/reporters/text.py +++ b/reporters/text.py @@ -1,5 +1,5 @@ -# Copyright (c) 2003-2006 Sylvain Thenault (thenault@gmail.com). -# Copyright (c) 2003-2006 LOGILAB S.A. (Paris, FRANCE). +# Copyright (c) 2003-2007 Sylvain Thenault (thenault@gmail.com). +# Copyright (c) 2003-2007 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 @@ -14,12 +14,13 @@ # 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. """Plain text reporters: -* the default one grouping messages by module -* the parseable one with module path on each message -* an ANSI colorized text reporter -""" +: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 -__revision__ = "$Id: text.py,v 1.21 2005-12-28 00:24:35 syt Exp $" +""" import os import sys @@ -33,12 +34,6 @@ from pylint.reporters import BaseReporter TITLE_UNDERLINES = ['', '=', '-', '.'] -## def modname_to_path(modname, prefix=os.getcwd() + os.sep): -## """transform a module name into a path""" -## module = load_module_from_name(modname).__file__.replace(prefix, '') -## return module.replace('.pyc', '.py').replace('.pyo', '.py') - - class TextReporter(BaseReporter): """reports messages and layouts in plain text """ @@ -73,12 +68,14 @@ class TextReporter(BaseReporter): TextWriter().format(layout, self.out) -class TextReporter2(TextReporter): +class ParseableTextReporter(TextReporter): """a reporter very similar to TextReporter, but display messages in a form recognized by most text editors : <filename>:<linenum>:<msg> """ + line_format = '%(path)s:%(line)s: [%(sigle)s%(obj)s] %(msg)s' + def __init__(self, output=sys.stdout, relative=True): TextReporter.__init__(self, output) if relative: @@ -97,14 +94,12 @@ class TextReporter2(TextReporter): sigle = msg_id[0] if self._prefix: path = path.replace(self._prefix, '') -## try: -## modpath = self._modules[module] -## except KeyError: -## modpath = self._modules[module] = self.linter.current_file or \ -## modname_to_path(module) - self.writeln('%s:%s: [%s%s] %s' % (path, line, sigle, obj, msg)) + self.writeln(self.line_format % locals()) + +class VSTextReported(ParseableTextReporter): + """Visual studio text reporter""" + line_format = '%(path)s(%(line)s): [%(sigle)s%(obj)s] %(msg)s' - class ColorizedTextReporter(TextReporter): """Simple TextReporter that colorizes text output""" |