Skip to content

tools

dandy.core.path.tools

get_file_path_or_exception

Source code in dandy/core/path/tools.py
def get_file_path_or_exception(
        file_path: Union[str, Path],
) -> Path:
    if Path(file_path).is_file():
        return Path(file_path)

    elif Path(settings.BASE_PATH, file_path).is_file():
        return Path(settings.BASE_PATH, file_path)

    else:
        raise DandyCriticalException(f'File "{file_path}" does not exist')