def list_files_recursive(file_dir, pattern, do_first=[], exclude_dirs=[]):
    all_files = [os.path.join(file_dir, file) for file in do_first]
    skip_me = set(all_files)
    exclude_dirs = set([os.path.join(file_dir, path) for path in exclude_dirs])

    new_files = []
    for root, dirs, files in os.walk(file_dir):
        if root in exclude_dirs:
            continue
        for file in fnmatch.filter(files, pattern):
            path = os.path.join(root, file)
            if not path in skip_me:
                new_files.append(path)

    # Make imports more predictable by sorting by filename
    all_files.extend(sorted(new_files))
    return all_files
Recursively find all files matching pattern under file_dir and return a list.
dataset/ETHPy150Open ooici/pyon/pyon/core/path.py/list_files_recursive