How to use the pep8.options function in pep8

To help you get started, we’ve selected a few pep8 examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github praekelt / django-setuptest / setuptest / runtests.py View on Github external
def runpep8(package):
    # Hook into stdout.
    old_stdout = sys.stdout
    sys.stdout = mystdout = StringIO()

    # Run Pep8 checks.
    pep8.options, pep8.args = pep8.process_options()
    pep8.options.repeat = True
    pep8.input_dir(package)

    # Restore stdout.
    sys.stdout = old_stdout

    # Save result to pep8.txt.
    result = mystdout.getvalue()
    output = open('pep8.txt', 'w')
    output.write(result)
    output.close()

    # Return Pep8 result
    if result:
        return result
    else:
github praekelt / django-category / runtests.py View on Github external
def runpep8():
    # Hook into stdout.
    old_stdout = sys.stdout
    sys.stdout = mystdout = StringIO()

    # Run Pep8 checks.
    pep8.options, pep8.args = pep8.process_options()
    pep8.input_dir(MODULE)

    # Restore stdout.
    sys.stdout = old_stdout

    # Save result to pep8.txt.
    result = mystdout.getvalue()
    output = open('pep8.txt', 'w')
    output.write(result)
    output.close()

    # Return Pep8 result
    return result
github praekelt / django-setuptest / setuptest / runtests.py View on Github external
def runpep8(package):
    # Hook into stdout.
    old_stdout = sys.stdout
    sys.stdout = mystdout = StringIO()

    # Run Pep8 checks.
    pep8.options, pep8.args = pep8.process_options()
    pep8.options.repeat = True
    pep8.input_dir(package)

    # Restore stdout.
    sys.stdout = old_stdout

    # Save result to pep8.txt.
    result = mystdout.getvalue()
    output = open('pep8.txt', 'w')
    output.write(result)
    output.close()

    # Return Pep8 result
    if result:
        return result
    else:
        return None
github KDE / kate / addons / kate / pate / src / plugins / python_utils / python_checkers / pep8_checker.py View on Github external
if not path:
        saveFirst()
        return
    mark_key = '%s-pep8' % currentDocument.url().path()
    # Check the file for errors with PEP8
    sys.argv = [path]
    pep8.process_options([path])
    python_utils_conf = kate.configuration.root.get('python_utils', {})
    ignore_pep8_errors = python_utils_conf.get(_IGNORE_PEP8_ERRORS, DEFAULT_IGNORE_PEP8_ERRORS)
    if ignore_pep8_errors:
        ignore_pep8_errors = ignore_pep8_errors.split(",")
    else:
        ignore_pep8_errors = []
    if pep8.__version__ in OLD_PEP8_VERSIONS:
        checker = StoreErrorsChecker(path)
        pep8.options.ignore = ignore_pep8_errors
        checker.check_all()
        errors = checker.get_errors()
    else:
        checker = pep8.Checker(path, reporter=KateReport, ignore=ignore_pep8_errors)
        checker.check_all()
        errors = checker.report.get_errors()
    if len(errors) == 0:
        showOk(i18n('Pep8 Ok'))
        return
    errors_to_show = []
    # Paint errors found
    for error in errors:
        errors_to_show.append({
            "line": error[0],
            "column": error[1] + 1,
            "message": error[3],
github douglas / sublimetext2_configs / sublimelint / modules / python.py View on Github external
code = text[:4]
            msg = text[5:]
            if pep8.ignore_code(code):
                return
            if code.startswith('E'):
                messages.append(Pep8Error(filename, Dict2Obj(lineno=line_number, col_offset=offset), code, msg))
            else:
                messages.append(Pep8Warning(filename, Dict2Obj(lineno=line_number, col_offset=offset), code, msg))
        pep8.Checker.report_error = report_error

        _ignore = ignore + pep8.DEFAULT_IGNORE.split(',')
        class FakeOptions:
            verbose = 0
            select = []
            ignore = _ignore
        pep8.options = FakeOptions()
        pep8.options.physical_checks = pep8.find_checks('physical_line')
        pep8.options.logical_checks = pep8.find_checks('logical_line')
        pep8.options.counters = dict.fromkeys(pep8.BENCHMARK_KEYS, 0)
        good_lines = [l + '\n' for l in _lines]
        good_lines[-1] = good_lines[-1].rstrip('\n')
        if not good_lines[-1]:
            good_lines = good_lines[:-1]
        try:
            pep8.Checker(filename, good_lines).check_all()
        except:
            pass
    return messages
github douglas / sublimetext2_configs / sublimelint / modules / python.py View on Github external
msg = text[5:]
            if pep8.ignore_code(code):
                return
            if code.startswith('E'):
                messages.append(Pep8Error(filename, Dict2Obj(lineno=line_number, col_offset=offset), code, msg))
            else:
                messages.append(Pep8Warning(filename, Dict2Obj(lineno=line_number, col_offset=offset), code, msg))
        pep8.Checker.report_error = report_error

        _ignore = ignore + pep8.DEFAULT_IGNORE.split(',')
        class FakeOptions:
            verbose = 0
            select = []
            ignore = _ignore
        pep8.options = FakeOptions()
        pep8.options.physical_checks = pep8.find_checks('physical_line')
        pep8.options.logical_checks = pep8.find_checks('logical_line')
        pep8.options.counters = dict.fromkeys(pep8.BENCHMARK_KEYS, 0)
        good_lines = [l + '\n' for l in _lines]
        good_lines[-1] = good_lines[-1].rstrip('\n')
        if not good_lines[-1]:
            good_lines = good_lines[:-1]
        try:
            pep8.Checker(filename, good_lines).check_all()
        except:
            pass
    return messages
github domogik / domogik / src / tools / run_pep8.py View on Github external
def main():
    """
    Parse options and run checks on Python source.
    """
    pep8.options = options()
    repo = dirname(dirname(abspath(__file__)))
    pep8.input_dir(repo)
github goinnn / Kate-plugins / kate_plugins / pyte_plugins / check_plugins / pep8_plugins.py View on Github external
currentDocument = currentDocument or kate.activeDocument()

    if currentDocument.isModified():
        saveFirst()
        return
    path = unicode(currentDocument.url().path())
    if not path:
        saveFirst()
        return
    mark_key = '%s-pep8' % unicode(currentDocument.url().path())
    # Check the file for errors with PEP8
    sys.argv = [path]
    pep8.process_options([path])
    if pep8.__version__ in OLD_PEP8_VERSIONS:
        checker = StoreErrorsChecker(path)
        pep8.options.ignore = IGNORE_PEP8_ERRORS
        checker.check_all()
        errors = checker.get_errors()
    else:
        checker = pep8.Checker(path, reporter=KateReport, ignore=IGNORE_PEP8_ERRORS)
        checker.check_all()
        errors = checker.report.get_errors()
    if len(errors) == 0:
        commons.showOk('Pep8 Ok')
        return
    errors_to_show = []
    # Paint errors found
    for error in errors:
        errors_to_show.append({
            "line": error[0],
            "column": error[1] + 1,
            "message": error[3],
github domogik / domogik / src / tools / run_pep8.py View on Github external
def main():
    """
    Parse options and run checks on Python source.
    """
    pep8.options = options()
    repo = dirname(dirname(abspath(__file__)))
    pep8.input_dir(repo)