Refactor find_file function.

This commit is contained in:
2026-11-17 12:32:12 -06:00
parent 1f2a6adb83
commit a1c1a18864

View File

@@ -1,3 +1,5 @@
from collections.abc import Collection
from itertools import chain
from os import PathLike, getcwd from os import PathLike, getcwd
from pathlib import Path from pathlib import Path
@@ -9,11 +11,13 @@ def breadcrumb_to_path(breadcrumb: str, extension: str = "") -> Path:
def find_file( def find_file(
filepath: PathLike | Path | str, folders: list[Path] | None = None filepath: PathLike | Path | str, folders: Collection[Path] = ()
) -> Path: ) -> Path:
path = Path(filepath) path = Path(filepath)
allfolders = ( allfolders = chain(
([] if folders is None else folders) + [Path(getcwd())] + AuDaGe.folders [] if folders is None else folders,
[Path(getcwd())],
AuDaGe.folders,
) )
for folder in allfolders: for folder in allfolders:
fullpath = Path(folder, path).resolve() fullpath = Path(folder, path).resolve()