Skip to content

list_files

:param root_dir: The directory containing the files. :param extension: The extension the files should have. :return: A list with absolute paths to the files.

Source code in library_analyzer/utils/_files.py
def list_files(root_dir: Path, extension: str = "") -> list[str]:
    """
    :param root_dir: The directory containing the files.
    :param extension: The extension the files should have.
    :return: A list with absolute paths to the files.
    """

    result: list[str] = []

    for root, _, files in os.walk(root_dir):
        for filename in files:
            if filename.endswith(extension):
                result.append(str(os.path.join(root, filename)))

    return result