From a1c1a188642135ad9c04f90328d089ebc6a1f8fa Mon Sep 17 00:00:00 2001 From: Joshua Date: Tue, 17 Nov 2026 12:32:12 -0600 Subject: [PATCH] Refactor find_file function. --- src/AuDaGe/file_utilities.py | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/src/AuDaGe/file_utilities.py b/src/AuDaGe/file_utilities.py index a1ad147..5ebfddf 100644 --- a/src/AuDaGe/file_utilities.py +++ b/src/AuDaGe/file_utilities.py @@ -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()