summaryrefslogtreecommitdiff
path: root/lint.py
diff options
context:
space:
mode:
authorKevin Jing Qiu <kevin.jing.qiu@gmail.com>2012-09-20 07:07:47 +0200
committerKevin Jing Qiu <kevin.jing.qiu@gmail.com>2012-09-20 07:07:47 +0200
commita867f79d216518b18075ccf39406a3140b89a7ab (patch)
treec4e0f5555a24f760521bfb97fe4094ce96ecf288 /lint.py
parentd4d8fe742e8860df3a699a4999be133a1fc8db42 (diff)
downloadpylint-a867f79d216518b18075ccf39406a3140b89a7ab.tar.gz
Added the ability to specify reporter class name as report's 'output-format'.
This allows a custom reporter to be used to format reports. Backwards-compatibility is maintained, so a user can still specify the named reporters such as 'text' or 'parseable'.
Diffstat (limited to 'lint.py')
-rw-r--r--lint.py13
1 files changed, 10 insertions, 3 deletions
diff --git a/lint.py b/lint.py
index d32205c..660fc8a 100644
--- a/lint.py
+++ b/lint.py
@@ -39,6 +39,7 @@ from warnings import warn
from logilab.common.configuration import UnsupportedAction, OptionsManagerMixIn
from logilab.common.optik_ext import check_csv
from logilab.common.modutils import load_module_from_name
+from logilab.common.modutils import get_module_part
from logilab.common.interface import implements
from logilab.common.textutils import splitstrip
from logilab.common.ureports import Table, Text, Section
@@ -183,8 +184,7 @@ They should be base names, not paths.'}),
python modules names) to load, usually to register additional checkers.'}),
('output-format',
- {'default': 'text', 'type': 'choice', 'metavar' : '<format>',
- 'choices': REPORTER_OPT_MAP.keys(),
+ {'default': 'text', 'type': 'string', 'metavar' : '<format>',
'short': 'f',
'group': 'Reports',
'help' : 'Set the output format. Available formats are text,\
@@ -341,7 +341,14 @@ This is used by the global evaluation report (RP0004).'}),
else :
meth(value)
elif optname == 'output-format':
- self.set_reporter(REPORTER_OPT_MAP[value.lower()]())
+ if value.lower() in REPORTER_OPT_MAP:
+ self.set_reporter(REPORTER_OPT_MAP[value.lower()]())
+ else:
+ module = load_module_from_name(get_module_part(value))
+ class_name = value.split('.')[-1]
+ reporter_class = getattr(module, class_name)
+ self.set_reporter(reporter_class())
+
try:
BaseRawChecker.set_option(self, optname, value, action, optdict)
except UnsupportedAction: