Skip to content

Filesystem

mongorunway.application.filesystem ¤

__all__: typing.Sequence[str] = ('read', 'getcwd', 'join', 'find_any') module-attribute ¤

find_any(*filenames, base_dir=os.getcwd()) ¤

Source code in mongorunway\application\filesystem.py
def find_any(*filenames: str, base_dir: str = os.getcwd()) -> typing.List[str]:
    found_files: typing.List[str] = []

    for dirpath, dirnames, filenames_in_dir in os.walk(base_dir):
        for filename in filenames:
            if filename in filenames_in_dir:
                found_files.append(os.path.join(dirpath, filename))

    return found_files

getcwd() ¤

Source code in mongorunway\application\filesystem.py
def getcwd() -> str:
    return os.getcwd()

join(*components) ¤

Source code in mongorunway\application\filesystem.py
def join(*components: str) -> str:
    return os.path.join(*components)

read(filename) ¤

Source code in mongorunway\application\filesystem.py
def read(filename: str) -> str:
    with open(filename) as file:
        return file.read()