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


Python pycodestyle.Checker方法代码示例

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


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

示例1: _run_check

# 需要导入模块: import pycodestyle [as 别名]
# 或者: from pycodestyle import Checker [as 别名]
def _run_check(self, code, checker, filename=None):
        # We are patching pycodestyle (pep8) so that only the check under test
        # is actually installed.
        mock_checks = {'physical_line': {}, 'logical_line': {}, 'tree': {}}
        with mock.patch('pycodestyle._checks', mock_checks):
            pycodestyle.register_check(checker)

            lines = textwrap.dedent(code).strip().splitlines(True)

            checker = pycodestyle.Checker(filename=filename, lines=lines)
            # NOTE(sdague): the standard reporter has printing to stdout
            # as a normal part of check_all, which bleeds through to the
            # test output stream in an unhelpful way. This blocks that
            # printing.
            with mock.patch('pycodestyle.StandardReport.get_file_results'):
                checker.check_all()
            checker.report._deferred_print.sort()
            return checker.report._deferred_print 
开发者ID:openstack,项目名称:os-win,代码行数:20,代码来源:test_hacking.py

示例2: _run_check

# 需要导入模块: import pycodestyle [as 别名]
# 或者: from pycodestyle import Checker [as 别名]
def _run_check(self, code, checker, filename=None):
        pycodestyle.register_check(checker)

        lines = textwrap.dedent(code).strip().splitlines(True)

        checker = pycodestyle.Checker(filename=filename, lines=lines)
        checker.check_all()
        checker.report._deferred_print.sort()
        return checker.report._deferred_print 
开发者ID:openstack,项目名称:zun,代码行数:11,代码来源:test_hacking.py

示例3: _execute_pep8

# 需要导入模块: import pycodestyle [as 别名]
# 或者: from pycodestyle import Checker [as 别名]
def _execute_pep8(pep8_options, source):
    """Execute pycodestyle via python method calls."""
    class QuietReport(pycodestyle.BaseReport):

        """Version of checker that does not print."""

        def __init__(self, options):
            super(QuietReport, self).__init__(options)
            self.__full_error_results = []

        def error(self, line_number, offset, text, check):
            """Collect errors."""
            code = super(QuietReport, self).error(line_number,
                                                  offset,
                                                  text,
                                                  check)
            if code:
                self.__full_error_results.append(
                    {'id': code,
                     'line': line_number,
                     'column': offset + 1,
                     'info': text})

        def full_error_results(self):
            """Return error results in detail.

            Results are in the form of a list of dictionaries. Each
            dictionary contains 'id', 'line', 'column', and 'info'.

            """
            return self.__full_error_results

    checker = pycodestyle.Checker('', lines=source, reporter=QuietReport,
                                  **pep8_options)
    checker.check_all()
    return checker.report.full_error_results() 
开发者ID:sofia-netsurv,项目名称:python-netsurv,代码行数:38,代码来源:autopep8.py

示例4: __init__

# 需要导入模块: import pycodestyle [as 别名]
# 或者: from pycodestyle import Checker [as 别名]
def __init__(self, filename):
        self.checker = Checker(filename) 
开发者ID:morten1982,项目名称:crossCobra,代码行数:4,代码来源:pycodechecker.py

示例5: _run_check

# 需要导入模块: import pycodestyle [as 别名]
# 或者: from pycodestyle import Checker [as 别名]
def _run_check(self, code, checker, filename=None):
        pycodestyle.register_check(checker)

        lines = textwrap.dedent(code).lstrip().splitlines(True)

        checker = pycodestyle.Checker(filename=filename, lines=lines)
        checker.check_all()
        checker.report._deferred_print.sort()
        return checker.report._deferred_print 
开发者ID:openstack,项目名称:masakari,代码行数:11,代码来源:test_hacking.py

示例6: check_code

# 需要导入模块: import pycodestyle [as 别名]
# 或者: from pycodestyle import Checker [as 别名]
def check_code(self):
        """
        Uses PyFlakes and PyCodeStyle to gather information about potential
        problems with the code in the current tab.
        """
        tab = self._view.current_tab
        if tab is None:
            # There is no active text editor so abort.
            return
        if tab.path and not tab.path.endswith(".py"):
            # Only works on Python files, so abort.
            return
        tab.has_annotations = not tab.has_annotations
        if tab.has_annotations:
            logger.info("Checking code.")
            self._view.reset_annotations()
            filename = tab.path if tab.path else _("untitled")
            builtins = self.modes[self.mode].builtins
            flake = check_flake(filename, tab.text(), builtins)
            if flake:
                logger.info(flake)
                self._view.annotate_code(flake, "error")
            pep8 = check_pycodestyle(tab.text())
            if pep8:
                logger.info(pep8)
                self._view.annotate_code(pep8, "style")
            self._view.show_annotations()
            tab.has_annotations = bool(flake or pep8)
            if not tab.has_annotations:
                # No problems detected, so confirm this with a friendly
                # message.
                ok_messages = [
                    _("Good job! No problems found."),
                    _("Hurrah! Checker turned up no problems."),
                    _("Nice one! Zero problems detected."),
                    _("Well done! No problems here."),
                    _("Awesome! Zero problems found."),
                ]
                self.show_status_message(random.choice(ok_messages))
                self._view.set_checker_icon("check-good.png")
            else:
                self._view.set_checker_icon("check-bad.png")
        else:
            self._view.reset_annotations() 
开发者ID:mu-editor,项目名称:mu,代码行数:46,代码来源:logic.py


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