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


Python PyLinter.load_config_file方法代码示例

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


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

示例1: run_linter

# 需要导入模块: from pylint.lint import PyLinter [as 别名]
# 或者: from pylint.lint.PyLinter import load_config_file [as 别名]
    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,代码行数:37,代码来源:setup.py

示例2: check_pylint

# 需要导入模块: from pylint.lint import PyLinter [as 别名]
# 或者: from pylint.lint.PyLinter import load_config_file [as 别名]
    def check_pylint(self):
        """
        Check using pylint.
        """
        options = self.options.get('pylint', self.file_path).copy()
        if not options['enabled']:
            return
        del options['enabled']

        if not self._compiled_tree:
            # We failed to compile the tree.
            return

        from pylint.lint import PyLinter, fix_import_path
        from pylint.reporters import CollectingReporter

        linter = PyLinter()
        linter.load_default_plugins()
        linter.set_reporter(CollectingReporter())

        if options['py3k']:
            linter.python3_porting_mode()
        del options['py3k']

        rcfile = options.get('rcfile', None)
        del options['rcfile']

        if rcfile:
            linter.read_config_file(config_file=rcfile)
            linter.load_config_file()
        else:
            linter.load_configuration_from_config(options)

        # PyLint does its own import and parsing, so we only pass the file
        # name and the precompiled tree.
        with fix_import_path(self.file_path):
            linter.check(self.file_path)

        for message in linter.reporter.messages:
            self.message(
                message.line,
                '%s:%s %s' % (
                    message.msg_id,
                    message.symbol,
                    message.msg,
                    ),
                code=message.msg_id,
                icon='info',
                category='pylint',
                )
开发者ID:chevah,项目名称:pocket-lint,代码行数:52,代码来源:formatcheck.py

示例3: run_linter

# 需要导入模块: from pylint.lint import PyLinter [as 别名]
# 或者: from pylint.lint.PyLinter import load_config_file [as 别名]
    def run_linter(self):
        linter = PyLinter(pylintrc=self.lint_config)

        # load_default_plugins will call checkers.initialize if
        # implemented, but some older versions of pylint don't have
        # this method so we fall back to calling is manually.
        if hasattr(linter, 'load_default_plugins'):
            linter.load_default_plugins()
        else:
            checkers.initialize(linter)

        linter.read_config_file()
        linter.load_config_file()

        # don't emit messages about suppressed or useless suppressed
        # configs, it's just annoying and doesn't help.
        #linter.disable('suppressed-message')
        #linter.disable('useless-suppression')

        if self.packages:
            self.announce("pylint is 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("pylint is 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:achieverForever,项目名称:python-javatools,代码行数:40,代码来源:pylint_cmd.py

示例4: Runner

# 需要导入模块: from pylint.lint import PyLinter [as 别名]
# 或者: from pylint.lint.PyLinter import load_config_file [as 别名]
class Runner():
    """
    Run and control the checking process.
    """
    outputStream = None
    linter = None
    allowOptions = None
    # Customized checkers.
    checkers = ("header.HeaderChecker",
                "names.TwistedNamesChecker",
                "pycodestyleformat.PyCodeStyleChecker",
                "docstring.DocstringChecker",
                "formattingoperation.FormattingOperationChecker",
                "comment.CommentChecker",
                "testclassname.TestClassNameChecker")
    allowedMessagesFromPylint = ("F0001",
                                 "C0103",
                                 "C0301",
                                 "W0311",
                                 "W0312")
    diffOption = None
    errorResultRead = "Error: Failed to read result file '%s'.\n"
    prefixModuleName = "************* Module "
    regexLineStart = "^[WCEFR]\d{4}\:"

    def __init__(self):
        """
        Initialize C{PyLinter} object, and load configuration file.
        """
        self.allowOptions = True
        self.linter = PyLinter(self._makeOptions())
        # register standard checkers.
        self.linter.load_default_plugins()
        # read configuration.
        pathConfig = os.path.join(twistedchecker.abspath,
                                  "configuration", "pylintrc")
        self.linter.read_config_file(pathConfig)
        # now we can load file config and command line, plugins (which can
        # provide options) have been registered.
        self.linter.load_config_file()
        allowedMessages = self.registerCheckers()
        # disable messages
        disabledMessages = set(self.linter
                           .cfgfile_parser.get("TWISTEDCHECKER", "disable")
                           .replace(" ", "").split(","))
        if disabledMessages != {""}:
            for msg in disabledMessages:
                self.linter.disable(msg)
            allowedMessages -= disabledMessages
        # set default output stream to stdout
        self.setOutput(sys.stdout)
        # set default reporter to limited reporter
        self.setReporter(LimitedReporter(allowedMessages))


    def _makeOptions(self):
        """
        Return options for twistedchecker.
        """
        return (
            ("diff",
             {"type": "string",
              "metavar": "<result-file>",
              "help": "Set comparing result file to automatically "
                      "generate a diff."}
            ),
            ('pep8',
             {'type': 'yn', 'metavar': '<y_or_n>',
              'default': False,
              'help': 'Show pep8 warnings.'}
            ),
            ('strict-epydoc',
             {'type': 'yn', 'metavar': '<y_or_n>',
              'default': False,
              'help': "Check '@type' and '@rtype' in epydoc."}
            ),
          )


    def setOutput(self, stream):
        """
        Set the stream to output result of checking.

        @param stream: output stream, defaultly it should be stdout
        """
        self.outputStream = stream
        sys.stdout = stream


    def setReporter(self, reporter):
        """
        Set the reporter of pylint.

        @param reporter: reporter used to show messages
        """
        self.linter.set_reporter(reporter)


    def displayHelp(self):
        """
#.........这里部分代码省略.........
开发者ID:twisted,项目名称:twistedchecker,代码行数:103,代码来源:runner.py


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