本文整理汇总了Python中pylint.checkers.initialize函数的典型用法代码示例。如果您正苦于以下问题:Python initialize函数的具体用法?Python initialize怎么用?Python initialize使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了initialize函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: _init_pylint
def _init_pylint():
from pylint import lint, checkers
import re
class VimReporter(object):
def __init__(self):
self.errors = []
def add_message(self, msg_id, location, msg):
_, _, line, col = location[1:]
self.errors.append(dict(
lnum=line,
col=col,
text="%s %s" % (msg_id, msg),
type=msg_id[0]
))
PYLINT['lint'] = lint.PyLinter()
PYLINT['re'] = re.compile('^(?:.:)?[^:]+:(\d+): \[([EWRCI]+)[^\]]*\] (.*)$')
checkers.initialize(PYLINT['lint'])
PYLINT['lint'].load_file_configuration(vim.eval("g:pymode_lint_config"))
PYLINT['lint'].set_option("output-format", "parseable")
PYLINT['lint'].set_option("include-ids", 1)
PYLINT['lint'].set_option("reports", 0)
PYLINT['lint'].reporter = VimReporter()
开发者ID:0Chuzz,项目名称:python-mode,代码行数:27,代码来源:pymode.py
示例2: setUpClass
def setUpClass(cls):
cls._linter = PyLinter()
cls._linter.set_reporter(TestReporter())
checkers.initialize(cls._linter)
register(cls._linter)
cls._linter.disable('all')
cls._linter.enable('too-complex')
开发者ID:bashell,项目名称:pylint,代码行数:7,代码来源:test_check_mccabe.py
示例3: test_simple_json_output
def test_simple_json_output():
output = StringIO()
reporter = JSONReporter()
linter = PyLinter(reporter=reporter)
checkers.initialize(linter)
linter.config.persistent = 0
linter.reporter.set_output(output)
linter.open()
linter.set_current_module("0123")
linter.add_message("line-too-long", line=1, args=(1, 2))
# we call this method because we didn't actually run the checkers
reporter.display_messages(None)
expected_result = [
[
("column", 0),
("line", 1),
("message", "Line too long (1/2)"),
("message-id", "C0301"),
("module", "0123"),
("obj", ""),
("path", "0123"),
("symbol", "line-too-long"),
("type", "convention"),
]
]
report_result = json.loads(output.getvalue())
report_result = [sorted(report_result[0].items(), key=lambda item: item[0])]
assert report_result == expected_result
开发者ID:aluoch-sheila,项目名称:NEIGHBOURHOOD,代码行数:32,代码来源:unittest_reporters_json.py
示例4: lint
def lint(cls, namespace):
'Performs pylint checks'
from pylint import lint
linter = lint.PyLinter()
from pylint import checkers
checkers.initialize(linter)
linter.check([str(path) for path in Path.cwd().iterfiles()])
开发者ID:Evgenus,项目名称:pooh,代码行数:7,代码来源:police.py
示例5: setUp
def setUp(self):
self.linter = PyLinter(reporter=TextReporter())
self.linter.disable('I')
self.linter.config.persistent = 0
# register checkers
checkers.initialize(self.linter)
os.environ.pop('PYLINTRC', None)
开发者ID:Wooble,项目名称:pylint,代码行数:7,代码来源:unittest_reporting.py
示例6: run_linter
def run_linter(self):
from pylint.lint import PyLinter
from pylint import checkers
from os.path import join
linter = PyLinter(pylintrc=self.lint_config)
# same, but not all pylint versions have load_default_plugins
if hasattr(linter, 'load_default_plugins'):
linter.load_default_plugins()
else:
checkers.initialize(linter)
linter.read_config_file()
linter.load_config_file()
if self.packages:
self.announce("checking packages", 2)
report_fn = "packages_report." + linter.reporter.extension
report_fn = join(self.build_base, report_fn)
with open(report_fn, "wt") as out:
linter.reporter.set_output(out)
linter.check(self.packages)
self.announce_overview(linter, report_fn)
if self.build_scripts:
self.announce("checking scripts", 2)
report_fn = "scripts_report." + linter.reporter.extension
report_fn = join(self.build_base, report_fn)
with open(report_fn, "wt") as out:
linter.reporter.set_output(out)
linter.check(self.build_scripts)
self.announce_overview(linter, report_fn)
开发者ID:jenix21,项目名称:python-javatools,代码行数:35,代码来源:setup.py
示例7: __init__
def __init__(self, *args, **kwargs):
self.sema = Semaphore(0)
self._output = []
self.running = True
self._plugins = []
pylintrc = kwargs.pop('pylintrc', None)
super(PidaLinter, self).__init__(*args, **kwargs)
#self.load_plugin_modules(self._plugins)
from pylint import checkers
checkers.initialize(self)
#self._rcfile =
gconfig = os.path.join(
environment.get_plugin_global_settings_path('python_lint'),
'pylintrc')
if os.path.exists(gconfig):
self.read_config_file(gconfig)
if pylintrc and os.path.exists(pylintrc):
self.read_config_file(pylintrc)
config_parser = self._config_parser
if config_parser.has_option('MASTER', 'load-plugins'):
plugins = get_csv(config_parser.get('MASTER', 'load-plugins'))
self.load_plugin_modules(plugins)
try:
self.load_config_file()
except Exception, e:
log.exception(e)
log.error(_("pylint couldn't load your config file: %s") %e)
开发者ID:fermat618,项目名称:pida,代码行数:28,代码来源:python_lint.py
示例8: linter
def linter():
linter = PyLinter()
linter.set_reporter(MinimalTestReporter())
checkers.initialize(linter)
linter.register_checker(OverlappingExceptionsChecker(linter))
linter.disable('I')
return linter
开发者ID:Vauxoo,项目名称:pylint,代码行数:7,代码来源:test_overlapping_exceptions.py
示例9: __init__
def __init__(self, reporter=None, quiet=0, pylintrc=None, crunchy_report=None):
if crunchy_report == "full":
self.full_report = True
else:
self.full_report = False
self.LinterClass = lint.PyLinter
self._rcfile = pylintrc
self.linter = self.LinterClass(
reporter=reporter,
pylintrc=self._rcfile,
)
self.linter.quiet = quiet
self._report = None
self._code = None
# register standard checkers
checkers.initialize(self.linter)
# read configuration
self.linter.read_config_file()
self.linter.load_config_file()
# Disable some errors.
if self.full_report:
self.linter.load_command_line_configuration([
'--module-rgx=.*', # don't check the module name
'--persistent=n', # don't save the old score (no sens for temp)
])
else:
self.linter.load_command_line_configuration([
'--module-rgx=.*', # don't check the module name
'--reports=n', # remove tables
'--persistent=n', # don't save the old score (no sens for temp)
])
self.linter.load_configuration()
self.linter.disable_message('C0121')# required attribute "__revision__"
if reporter:
self.linter.set_reporter(reporter)
开发者ID:Mekyi,项目名称:crunchy,代码行数:35,代码来源:analyzer_pylint.py
示例10: test_html_reporter_msg_template
def test_html_reporter_msg_template(self):
expected = '''
<html>
<body>
<div>
<div>
<h2>Messages</h2>
<table>
<tr class="header">
<th>category</th>
<th>msg_id</th>
</tr>
<tr class="even">
<td>warning</td>
<td>W0332</td>
</tr>
</table>
</div>
</div>
</body>
</html>'''.strip().splitlines()
output = six.StringIO()
linter = PyLinter(reporter=HTMLReporter())
checkers.initialize(linter)
linter.config.persistent = 0
linter.reporter.set_output(output)
linter.set_option('msg-template', '{category}{msg_id}')
linter.open()
linter.set_current_module('0123')
linter.add_message('lowercase-l-suffix', line=1)
linter.reporter.display_results(Section())
self.assertEqual(output.getvalue().splitlines(), expected)
开发者ID:Wooble,项目名称:pylint,代码行数:32,代码来源:unittest_reporting.py
示例11: linter
def linter():
linter = PyLinter()
linter.set_reporter(MinimalTestReporter())
checkers.initialize(linter)
linter.register_checker(BadBuiltinChecker(linter))
linter.disable('I')
return linter
开发者ID:Vauxoo,项目名称:pylint,代码行数:7,代码来源:test_bad_builtin.py
示例12: setUp
def setUp(self):
self.linter = PyLinter()
self.linter.disable('I')
self.linter.config.persistent = 0
# register checkers
checkers.initialize(self.linter)
self.linter.set_reporter(TestReporter())
开发者ID:The-Compiler,项目名称:pylint,代码行数:7,代码来源:unittest_lint.py
示例13: process_file
def process_file(filename):
"""
Analyze the file with pylint and write the result
to a database
"""
linter = PyLinter()
checkers.initialize(linter)
linter.read_config_file()
linter.quiet = 1
filemods = linter.expand_files((filename, ))
if filemods:
old_stats = config.load_results(filemods[0].get('basename'))
old_score = old_stats.get('global_note', 0.0)
linter.check(filename)
score = eval(linter.config.evaluation, {}, linter.stats)
# Calculate the credit for both scores
if score < 0:
credit = 2.0 * score
elif score < old_score:
credit = -1.5 * (old_score - score)
elif score < MINIMUM_SCORE:
credit = -1.5 * (MINIMUM_SCORE - score)
else:
credit = score - old_score
return score, old_score, credit
开发者ID:codecollision,项目名称:DropboxToFlickr,代码行数:30,代码来源:huLint.py
示例14: linter
def linter():
linter = PyLinter()
linter.disable('I')
linter.config.persistent = 0
# register checkers
checkers.initialize(linter)
linter.set_reporter(testutils.TestReporter())
return linter
开发者ID:Vauxoo,项目名称:pylint,代码行数:8,代码来源:unittest_lint.py
示例15: linter
def linter():
test_reporter = testutils.TestReporter()
linter = lint.PyLinter()
linter.set_reporter(test_reporter)
linter.disable('I')
linter.config.persistent = 0
checkers.initialize(linter)
return linter
开发者ID:Vauxoo,项目名称:pylint,代码行数:8,代码来源:test_regr.py
示例16: linter
def linter():
linter = PyLinter()
linter.set_reporter(MinimalTestReporter())
checkers.initialize(linter)
register(linter)
linter.disable('all')
linter.enable('too-complex')
return linter
开发者ID:Vauxoo,项目名称:pylint,代码行数:8,代码来源:test_check_mccabe.py
示例17: linter
def linter():
linter = PyLinter(reporter=TextReporter())
linter.disable('I')
linter.config.persistent = 0
# register checkers
checkers.initialize(linter)
os.environ.pop('PYLINTRC', None)
return linter
开发者ID:Vauxoo,项目名称:pylint,代码行数:8,代码来源:unittest_reporting.py
示例18: __init__
def __init__(self, test_file):
test_reporter = FunctionalTestReporter()
self._linter = lint.PyLinter()
self._linter.set_reporter(test_reporter)
self._linter.config.persistent = 0
checkers.initialize(self._linter)
self._linter.disable('I')
try:
self._linter.read_config_file(test_file.option_file)
self._linter.load_config_file()
except NoFileError:
pass
self._test_file = test_file
开发者ID:KabageMark,项目名称:newsapp,代码行数:13,代码来源:test_functional.py
示例19: __init__
def __init__(self, test_file):
super(LintModuleTest, self).__init__('_runTest')
test_reporter = TestReporter()
self._linter = lint.PyLinter()
self._linter.set_reporter(test_reporter)
self._linter.config.persistent = 0
checkers.initialize(self._linter)
self._linter.disable('I')
try:
self._linter.load_file_configuration(test_file.option_file)
except NoFileError:
pass
self._test_file = test_file
开发者ID:balagopalraj,项目名称:clearlinux,代码行数:13,代码来源:test_functional.py
示例20: test_parseable_output_regression
def test_parseable_output_regression(self):
output = six.StringIO()
linter = PyLinter(reporter=ParseableTextReporter())
checkers.initialize(linter)
linter.config.persistent = 0
linter.reporter.set_output(output)
linter.set_option('output-format', 'parseable')
linter.open()
linter.set_current_module('0123')
linter.add_message('line-too-long', line=1, args=(1, 2))
self.assertMultiLineEqual(output.getvalue(),
'************* Module 0123\n'
'0123:1: [C0301(line-too-long), ] '
'Line too long (1/2)\n')
开发者ID:XHydro,项目名称:PSI-Project-2-Django,代码行数:14,代码来源:unittest_reporting.py
注:本文中的pylint.checkers.initialize函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论