Handle non-existent paths in path dictionary creation

This commit is contained in:
sko00o
2025-03-11 18:26:05 +08:00
parent 90b012e922
commit 86ed1e7a6f
+1 -1
View File
@@ -45,7 +45,7 @@ def create_path_dict(paths: list[str], predicate: Callable[[Path], bool] = lambd
Default: Include everything
"""
flattened_paths = [item for path in paths for item in Path(path).iterdir() if predicate(item)]
flattened_paths = [item for path in paths if Path(path).exists() for item in Path(path).iterdir() if predicate(item)]
return {item.name: str(item.absolute()) for item in flattened_paths}