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