def loop_params(file_list): for i, (error_no, error_comment) in enumerate(ERRORS, start=1): info("{2} of {3}: {0} {1}".format( error_no, error_comment, i, len(ERRORS))) for fullpath in file_list: hash_before = sha1_file(fullpath) yield (fullpath, hash_before, error_no, error_comment)
def run_autopylint(file_or_directory, ext=".py", recurse=True, dryrun=False, verbose=False, author=None): file_list = get_filelist(file_or_directory, recurse, ext) i = 0 for fullpath, hash_before, error_no, error_comment in loop_params(file_list): cmd = ["autopylint", "--in-place", "--verbose", "--select={0}".format(error_no), fullpath] if verbose or dryrun: info(" ".join(cmd)) if not dryrun: output = run_command(cmd) if hash_before != sha1_file(fullpath): # I can't tell if autopep8 has modified a file from the return code, # so I do it the hard way... info(output) git_commit( fullpath, "{0} {1}".format(error_no, error_comment), dryrun, verbose, author) i += 1 info("# {0} files scanned/modified".format(i))