Exemple #1
0
    number_of_pep8_passes = "2000"
    # in-place, verbose, select only styles which are listed above,
    # pep8-passes limit is to avoid infinite loop
    autopep8_args = [
        "-i",
        "-v",
        "--select",
        ",".join(styles_to_be_corrected),
        "--pep8-passes",
        number_of_pep8_passes,
    ]

    if files is not None:
        python_files = []
        for filename in files:
            if autopep8.is_python_file(filename):
                python_files = python_files + [filename]
            else:
                if verbosity != "silent":
                    print(filename, "is not a python file, skipping ")
        # execute autopep8 only on python files, without being recursive
        autopep8_args = autopep8_args + python_files
        if not python_files:
            print("No python files to process.")
            sys.exit()
        if verbosity != "silent":
            print("Running autopep8 on the files: ", " ".join(python_files))
    else:
        # perform recursive search in the given directory
        if os.path.isdir(path):
            os.chdir(path)
Exemple #2
0
                              'E301', 'E302', 'E303', 'E304', 'E306',
                              'E401',
                              'E502',
                              'W291', 'W292', 'W29',
                              'W391']
    # Must be written as string since it is passed to command
    number_of_pep8_passes = '2000'
    # in-place, verbose, select only styles which are listed above,
    # pep8-passes limit is to avoid infinite loop
    autopep8_args = ['-i', '-v', '--select', ','.join(styles_to_be_corrected),
                     '--pep8-passes', number_of_pep8_passes]

    if files is not None:
        python_files = []
        for filename in files:
            if autopep8.is_python_file(filename):
                python_files = python_files + [filename]
            else:
                if verbosity != 'silent':
                    print filename, 'is not a python file, skipping '
        # execute autopep8 only on python files, without being recursive
        autopep8_args = autopep8_args + python_files
        if not python_files:
            print 'No python files to process.'
            sys.exit()
        if verbosity != 'silent':
            print 'Running autopep8 on the files: ', ' '.join(python_files)
    else:
        # perform recursive search in the given directory
        if os.path.isdir(path):
            os.chdir(path)