Пример #1
0
def process_items(reporter, items, tester):
    """Process list of modules or packages.
    """
    test_pylint = tester in ("pylint", "all",)
    test_pep8 = tester in ("pep8", "all",)

    if test_pep8:
        # PEP8 report instance setup
        pep8style = StyleGuide(parse_argv=False, config_file=False)
        if reporter.name == "csv":
            pep8style.options.report = CsvPep8Report(pep8style.options,
                                                     reporter.writer)
        else:
            colorized = (reporter.name == "colorized")
            pep8style.options.report = Pep8Report(pep8style.options,
                                                  reporter.line_format,
                                                  reporter.out,
                                                  colorized)

    pylint_rc_path = os.path.join(_CURRENT_PATH, "pylint.rc")
    for item in items:
        path = os.path.join(_BASE_PATH, item)
        if test_pylint:
            # Pylint tests
            lint.Run([path, "--rcfile={0}".format(pylint_rc_path)],
                     reporter=reporter, exit=False)
        if test_pep8:
            # Pep8 tests
            if item.endswith(".py"):
                pep8style.input_file(path)
            else:
                pep8style.input_dir(path)
Пример #2
0
def process_items(reporter, items, tester):
    """Process list of modules or packages.
    """
    test_pylint = tester in (
        "pylint",
        "all",
    )
    test_pep8 = tester in (
        "pep8",
        "all",
    )

    if test_pep8:
        # PEP8 report instance setup
        pep8style = StyleGuide(parse_argv=False, config_file=False)
        if reporter.name == "csv":
            pep8style.options.report = CsvPep8Report(pep8style.options,
                                                     reporter.writer)
        else:
            colorized = (reporter.name == "colorized")
            pep8style.options.report = Pep8Report(pep8style.options,
                                                  reporter.line_format,
                                                  reporter.out, colorized)

    pylint_rc_path = os.path.join(_CURRENT_PATH, "pylint.rc")
    for item in items:
        path = os.path.join(_BASE_PATH, item)
        if test_pylint:
            # Pylint tests
            lint.Run([path, "--rcfile={0}".format(pylint_rc_path)],
                     reporter=reporter,
                     exit=False)
        if test_pep8:
            # Pep8 tests
            if item.endswith(".py"):
                pep8style.input_file(path)
            else:
                pep8style.input_dir(path)
Пример #3
0
    def run(path, code=None, params=None, **meta):
        """Check code with PEP8.

        :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=_PEP8Report, **params)
        buf = StringIO(code)
        return P8Style.input_file(path, lines=buf.readlines())
Пример #4
0
    def run(path, code=None, params=None, **meta):
        """Check code with PEP8.

        :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=_PEP8Report, **params)
        buf = StringIO(code)
        return P8Style.input_file(path, lines=buf.readlines())