diff options
author | Torsten Marek <tmarek@google.com> | 2013-06-19 16:29:18 +0200 |
---|---|---|
committer | Torsten Marek <tmarek@google.com> | 2013-06-19 16:29:18 +0200 |
commit | f6bddc94f23ef417ae1577b6416c412a82aff9c7 (patch) | |
tree | 14a4b526b3ac568efe4f18ac058ba1e4a7f827fa /reporters | |
parent | c5e3e1ff04b2d8f3d2525d24b426ef1c7e73a21a (diff) | |
download | pylint-f6bddc94f23ef417ae1577b6416c412a82aff9c7.tar.gz |
Turn reporters into proper plugins rather than classes that are loaded explicitly.
Diffstat (limited to 'reporters')
-rw-r--r-- | reporters/__init__.py | 5 | ||||
-rw-r--r-- | reporters/html.py | 5 | ||||
-rw-r--r-- | reporters/text.py | 17 |
3 files changed, 26 insertions, 1 deletions
diff --git a/reporters/__init__.py b/reporters/__init__.py index 5c36af2..3e87aed 100644 --- a/reporters/__init__.py +++ b/reporters/__init__.py @@ -15,6 +15,8 @@ import sys, locale +from pylint import utils + CMPS = ['=', '-', '+'] # py3k has no more cmp builtin @@ -110,3 +112,6 @@ class BaseReporter(object): pass +def initialize(linter): + """initialize linter with reporters in this package """ + utils.register_plugins(linter, __path__[0]) diff --git a/reporters/html.py b/reporters/html.py index cac08b2..23c1d18 100644 --- a/reporters/html.py +++ b/reporters/html.py @@ -27,6 +27,7 @@ class HTMLReporter(BaseReporter): """report messages and layouts in HTML""" __implements__ = IReporter + name = 'html' extension = 'html' def __init__(self, output=sys.stdout): @@ -64,3 +65,7 @@ class HTMLReporter(BaseReporter): self.msgs = [] HTMLWriter().format(layout, self.out) + +def register(linter): + """Register the reporter classes with the linter.""" + linter.register_reporter(HTMLReporter) diff --git a/reporters/text.py b/reporters/text.py index d5b4a9b..54e13a0 100644 --- a/reporters/text.py +++ b/reporters/text.py @@ -35,8 +35,9 @@ TITLE_UNDERLINES = ['', '=', '-', '.'] class TextReporter(BaseReporter): """reports messages and layouts in plain text """ - + __implements__ = IReporter + name = 'text' extension = 'txt' def __init__(self, output=None): @@ -69,6 +70,8 @@ class ParseableTextReporter(TextReporter): <filename>:<linenum>:<msg> """ + name = 'parseable' + line_format = '%(path)s:%(line)s: [%(sigle)s%(obj)s] %(msg)s' def __init__(self, output=None, relative=True): @@ -92,10 +95,14 @@ class ParseableTextReporter(TextReporter): class VSTextReporter(ParseableTextReporter): """Visual studio text reporter""" line_format = '%(path)s(%(line)s): [%(sigle)s%(obj)s] %(msg)s' + + name = 'msvs' class ColorizedTextReporter(TextReporter): """Simple TextReporter that colorizes text output""" + name = 'colorized' + COLOR_MAPPING = { "I" : ("green", None), 'C' : (None, "bold"), @@ -143,3 +150,11 @@ class ColorizedTextReporter(TextReporter): msg = colorize_ansi(msg, color, style) sigle = colorize_ansi(sigle, color, style) self.writeln('%s:%3s%s: %s' % (sigle, line, obj, 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) |