def get_files()

in infra/build/developer-tools/build/verify_boilerplate/verify_boilerplate.py [0:0]


def get_files(extensions, ARGS):
    """Generates a list of paths whose boilerplate should be verified.

    If a list of file names has been provided on the command line, it will be
    treated as the initial set to search. Otherwise, all paths within rootdir
    will be discovered and used as the initial set.

    Once the initial set of files is identified, it is normalized via
    normalize_files() and further stripped of any file name whose extension is
    not in extensions.

    Args:
        extensions: a list of file extensions indicating which file types
                    should have their boilerplate verified

    Returns:
        A list of absolute file paths
    """
    files = []
    if ARGS.filenames:
        files = ARGS.filenames
    else:
        for root, dirs, walkfiles in os.walk(ARGS.rootdir):
            # don't visit certain dirs. This is just a performance improvement
            # as we would prune these later in normalize_files(). But doing it
            # cuts down the amount of filesystem walking we do and cuts down
            # the size of the file list
            for dpath in SKIPPED_DIRS:
                if dpath in dirs:
                    dirs.remove(dpath)
            for name in walkfiles:
                pathname = os.path.join(root, name)
                files.append(pathname)
    files = normalize_files(files)
    outfiles = []
    for pathname in files:
        basename = os.path.basename(pathname)
        extension = get_file_extension(pathname)
        if extension in extensions or basename in extensions:
            outfiles.append(pathname)
    return outfiles