当前位置: 首页>>代码示例>>Python>>正文


Python PyLinter.load_plugin_modules方法代码示例

本文整理汇总了Python中pylint.lint.PyLinter.load_plugin_modules方法的典型用法代码示例。如果您正苦于以下问题:Python PyLinter.load_plugin_modules方法的具体用法?Python PyLinter.load_plugin_modules怎么用?Python PyLinter.load_plugin_modules使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在pylint.lint.PyLinter的用法示例。


在下文中一共展示了PyLinter.load_plugin_modules方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: builder_inited

# 需要导入模块: from pylint.lint import PyLinter [as 别名]
# 或者: from pylint.lint.PyLinter import load_plugin_modules [as 别名]
def builder_inited(app):
    """Output full documentation in ReST format for all extension modules"""
    # PACKAGE/docs/exts/pylint_extensions.py --> PACKAGE/
    base_path = os.path.dirname(
        os.path.dirname(os.path.dirname(os.path.abspath(__file__))))
    # PACKAGE/ --> PACKAGE/pylint/extensions
    ext_path = os.path.join(base_path, 'pylint', 'extensions')
    modules = []
    doc_files = {}
    for filename in os.listdir(ext_path):
        name, ext = os.path.splitext(filename)
        if name[0] == '_' or name in DEPRECATED_MODULES:
            continue
        if ext == '.py':
            modules.append('pylint.extensions.%s' % name)
        elif ext == '.rst':
            doc_files['pylint.extensions.' + name] = os.path.join(ext_path,
                                                                  filename)
    modules.sort()
    if not modules:
        sys.exit("No Pylint extensions found?")

    linter = PyLinter()
    linter.load_plugin_modules(modules)

    extensions_doc = os.path.join(base_path, 'doc', 'technical_reference', 'extensions.rst')
    with open(extensions_doc, 'w') as stream:
        stream.write("Optional Pylint checkers in the extensions module\n")
        stream.write("=================================================\n\n")
        stream.write("Pylint provides the following optional plugins:\n\n")
        for module in modules:
            stream.write("- :ref:`{0}`\n".format(module))
        stream.write("\n")
        stream.write("You can activate any or all of these extensions "
                     "by adding a ``load-plugins`` line to the ``MASTER`` "
                     "section of your ``.pylintrc``, for example::\n")
        stream.write("\n    load-plugins=pylint.extensions.docparams,"
                     "pylint.extensions.docstyle\n\n")
        by_module = get_plugins_info(linter, doc_files)
        for module, info in sorted(six.iteritems(by_module)):
            linter._print_checker_doc(info['name'], info, stream=stream)
开发者ID:eladm26,项目名称:pylint,代码行数:43,代码来源:pylint_extensions.py

示例2: import

# 需要导入模块: from pylint.lint import PyLinter [as 别名]
# 或者: from pylint.lint.PyLinter import load_plugin_modules [as 别名]
from __future__ import (absolute_import, division,
                        print_function, unicode_literals)

from unittest import TestCase
import sys
from os.path import abspath, dirname, join

from pylint.testutils import TestReporter
from pylint.lint import PyLinter
from pylint import checkers

test_reporter = TestReporter()
linter = PyLinter()
linter.set_reporter(test_reporter)
linter.load_plugin_modules(['django_linter'])
linter.disable('I')
linter.config.persistent = 0
checkers.initialize(linter)

DATA = join(dirname(abspath(__file__)), 'settings')
sys.path.insert(1, DATA)


class SettingsTestCase(TestCase):

    def setUp(self):
        linter.reporter.finalize()

    def test_required_setting_missed(self):
        linter.check('settings.required.settings')
        got = linter.reporter.finalize().strip()
开发者ID:johndeng,项目名称:django_linter,代码行数:33,代码来源:test_settings.py


注:本文中的pylint.lint.PyLinter.load_plugin_modules方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。