當前位置: 首頁>>代碼示例>>Python>>正文


Python pycodestyle.StyleGuide方法代碼示例

本文整理匯總了Python中pycodestyle.StyleGuide方法的典型用法代碼示例。如果您正苦於以下問題:Python pycodestyle.StyleGuide方法的具體用法?Python pycodestyle.StyleGuide怎麽用?Python pycodestyle.StyleGuide使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在pycodestyle的用法示例。


在下文中一共展示了pycodestyle.StyleGuide方法的10個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: print_files_information_pep8

# 需要導入模塊: import pycodestyle [as 別名]
# 或者: from pycodestyle import StyleGuide [as 別名]
def print_files_information_pep8():
    """
    Print the list of files which can be removed from the whitelist and the
    list of files which do not respect PEP8 formatting that aren't in the
    whitelist
    """
    infracting_files = []
    non_infracting_files = []
    pep8_checker = StyleGuide(quiet=True)
    for path in list_files(".py"):
        number_of_infractions = pep8_checker.input_file(path)
        rel_path = os.path.relpath(path, cleverhans.__path__[0])
        if number_of_infractions > 0:
            if rel_path not in whitelist_pep8:
                infracting_files.append(path)
        else:
            if rel_path in whitelist_pep8:
                non_infracting_files.append(path)
    print("Files that must be corrected or added to whitelist:")
    for file in infracting_files:
        print(file)
    print("Files that can be removed from whitelist:")
    for file in non_infracting_files:
        print(file) 
開發者ID:StephanZheng,項目名稱:neural-fingerprinting,代碼行數:26,代碼來源:test_format.py

示例2: test_format_pep8

# 需要導入模塊: import pycodestyle [as 別名]
# 或者: from pycodestyle import StyleGuide [as 別名]
def test_format_pep8():
    """
    Test if pep8 is respected.
    """
    pep8_checker = StyleGuide()
    files_to_check = []
    for path in list_files(".py"):
        rel_path = os.path.relpath(path, cleverhans.__path__[0])
        if rel_path in whitelist_pep8:
            continue
        else:
            files_to_check.append(path)
    report = pep8_checker.check_files(files_to_check)
    if report.total_errors > 0:
        raise AssertionError("PEP8 Format not respected") 
開發者ID:StephanZheng,項目名稱:neural-fingerprinting,代碼行數:17,代碼來源:test_format.py

示例3: run

# 需要導入模塊: import pycodestyle [as 別名]
# 或者: from pycodestyle import StyleGuide [as 別名]
def run(path, code=None, params=None, **meta):
        """Check code with pycodestyle.

        :return list: List of errors.
        """
        parser = get_parser()
        for option in parser.option_list:
            if option.dest and option.dest in params:
                value = params[option.dest]
                if not isinstance(value, str):
                    continue
                params[option.dest] = option.convert_value(option, params[option.dest])
        P8Style = StyleGuide(reporter=_PycodestyleReport, **params)
        buf = StringIO(code)
        return P8Style.input_file(path, lines=buf.readlines()) 
開發者ID:AtomLinter,項目名稱:linter-pylama,代碼行數:17,代碼來源:pylama_pycodestyle.py

示例4: process_module

# 需要導入模塊: import pycodestyle [as 別名]
# 或者: from pycodestyle import StyleGuide [as 別名]
def process_module(self, node):
        style_guide = pycodestyle.StyleGuide(paths=[node.stream().name], reporter=JSONReport, ignore=IGNORED_CHECKS)
        report = style_guide.check_files()

        for line_num, msg in report.get_file_results():
            self.add_message('pep8-errors', line=line_num, args=msg) 
開發者ID:pyta-uoft,項目名稱:pyta,代碼行數:8,代碼來源:pycodestyle_checker.py

示例5: setUp

# 需要導入模塊: import pycodestyle [as 別名]
# 或者: from pycodestyle import StyleGuide [as 別名]
def setUp(self):
        self.style = pycodestyle.StyleGuide(show_source=True,
                                            ignore="E402") 
開發者ID:bilelmoussaoui,項目名稱:nautilus-folder-icons,代碼行數:5,代碼來源:test_code_format.py

示例6: test_pycodestyle

# 需要導入模塊: import pycodestyle [as 別名]
# 或者: from pycodestyle import StyleGuide [as 別名]
def test_pycodestyle():
    style = pycodestyle.StyleGuide()
    base_path = os.path.dirname(os.path.dirname(__file__))
    report = style.check_files([
        os.path.join(base_path, 'script', 'control_team_blue'),
        os.path.join(base_path, 'script', 'control_team_gold'),
        os.path.join(base_path, 'script', 'rqt_uctf'),
        os.path.join(base_path, 'script', 'spawn_blue'),
        os.path.join(base_path, 'script', 'spawn_gold'),
        os.path.join(base_path, 'src'),
        os.path.join(base_path, 'test'),
    ])
    assert not report.total_errors 
開發者ID:osrf,項目名稱:uctf,代碼行數:15,代碼來源:test_pycodestyle.py

示例7: test_pep8

# 需要導入模塊: import pycodestyle [as 別名]
# 或者: from pycodestyle import StyleGuide [as 別名]
def test_pep8(self):
        style = pycodestyle.StyleGuide()
        files = glob('kademlia/**/*.py', recursive=True)
        result = style.check_files(files)
        if result.total_errors > 0:
            raise LintError("Code style errors found.") 
開發者ID:bmuller,項目名稱:kademlia,代碼行數:8,代碼來源:test_linting.py

示例8: test_conformance

# 需要導入模塊: import pycodestyle [as 別名]
# 或者: from pycodestyle import StyleGuide [as 別名]
def test_conformance(self):
        """Test that we conform to PEP-8."""
        style = pycodestyle.StyleGuide(quiet=False, ignore=['E501', 'W605'])
        if exists('transitions'):  # when run from root directory (e.g. tox)
            style.input_dir('transitions')
            style.input_dir('tests')
        else:  # when run from test directory (e.g. pycharm)
            style.input_dir('../transitions')
            style.input_dir('.')
        result = style.check_files()
        self.assertEqual(result.total_errors, 0,
                         "Found code style errors (and warnings).") 
開發者ID:pytransitions,項目名稱:transitions,代碼行數:14,代碼來源:test_codestyle.py

示例9: run

# 需要導入模塊: import pycodestyle [as 別名]
# 或者: from pycodestyle import StyleGuide [as 別名]
def run(self):
        """
        Call pycodestyle and pylint here.
        """
        import pylint.lint
        import pycodestyle

        files = ["setup.py", "src/virtBootstrap/", "tests/"]
        output_format = "colorized" if sys.stdout.isatty() else "text"

        print(">>> Running pycodestyle ...")

        style_guide = pycodestyle.StyleGuide(paths=files)
        report = style_guide.check_files()
        if style_guide.options.count:
            sys.stderr.write(str(report.total_errors) + '\n')

        print(">>> Running pylint ...")

        pylint_opts = [
            "--rcfile", "pylintrc",
            "--output-format=%s" % output_format
        ]

        if self.errors_only:
            pylint_opts.append("-E")

        pylint.lint.Run(files + pylint_opts)


# SdistCommand is reused from the libvirt python binding (GPLv2+) 
開發者ID:virt-manager,項目名稱:virt-bootstrap,代碼行數:33,代碼來源:setup.py

示例10: test_pep8

# 需要導入模塊: import pycodestyle [as 別名]
# 或者: from pycodestyle import StyleGuide [as 別名]
def test_pep8():
    report = StyleGuide(ignore=['E501', 'E402']).check_files([os.path.dirname(os.path.abspath(__file__)) + '/../'])
    report.print_statistics()

    if report.messages:
        raise Exception("pep8") 
開發者ID:elehcimd,項目名稱:pynb,代碼行數:8,代碼來源:test_pep8.py


注:本文中的pycodestyle.StyleGuide方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。