Did I find the right examples for you? yes no      Crawl my project      Python Jobs

All Samples(3)  |  Call(1)  |  Derive(0)  |  Import(2)
Run flake8 lint with external interpreter.

        def lint_external(filename, settings, interpreter, linter):
    """
    Run flake8 lint with external interpreter.
    """
    import subprocess

    # check if active view contains file
    if not filename or not os.path.exists(filename):
        return

    # first argument is interpreter
    arguments = [interpreter, linter]

    # do we need to run pyflake lint
    if settings.get('pyflakes', True):
        arguments.append('--pyflakes')
        builtins = settings.get('builtins')
        if builtins:
            arguments.append('--builtins')
            arguments.append(','.join(builtins))

    # do we need to run pep8 lint
    if settings.get('pep8', True):
        arguments.append('--pep8')
        max_line_length = settings.get('pep8_max_line_length', 79)
        arguments.append('--pep8-max-line-length')
        arguments.append(str(max_line_length))

    # do we need to run complexity check
    complexity = settings.get('complexity', -1)
    arguments.extend(('--complexity', str(complexity)))

    # last argument is script to check filename
    arguments.append(filename)

    # place for warnings =)
    warnings = []

    startupinfo = None
    if os.name == 'nt':
        startupinfo = subprocess.STARTUPINFO()
        startupinfo.dwFlags |= subprocess.STARTF_USESHOWWINDOW
    # run subprocess
    proc = subprocess.Popen(arguments, stdout=subprocess.PIPE,
                            stderr=subprocess.STDOUT,
                            startupinfo=startupinfo)

    # parse STDOUT for warnings and errors
    for line in proc.stdout:
        line = line.decode('utf-8').strip()
        warning = line.split(':', 2)
        if len(warning) == 3:
            try:
                warnings.append((int(warning[0]), int(warning[1]), warning[2]))
            except (TypeError, ValueError):
                print("Flake8Lint ERROR: {0}".format(line))
        else:
            print("Flake8Lint ERROR: {0}".format(line))

    # and return them =)
    return warnings
        


src/f/l/Flake8Lint-HEAD/Flake8Lint.py   Flake8Lint(Download)
 
try:
    from .lint import lint, lint_external, skip_file, load_flake8_config
except (ValueError, SystemError):
    from lint import lint, lint_external, skip_file, load_flake8_config  # noqa
            # and lint file in subprocess
            debug("interpreter is external")
            self.errors_list = lint_external(filename, view_settings,
                                             interpreter, linter)