From f0100234c9d9b855eceb94ea57081d2b41823505 Mon Sep 17 00:00:00 2001 From: "Max P." Date: Sat, 26 Apr 2025 13:52:58 +0200 Subject: [PATCH] Adds utility to expand source file paths with wildcards Introduces a function to resolve wildcard patterns in source file paths, normalizing and returning them as tuples of library and file path. Improves flexibility in handling source files. --- src/utils/source_resolver.py | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) create mode 100644 src/utils/source_resolver.py diff --git a/src/utils/source_resolver.py b/src/utils/source_resolver.py new file mode 100644 index 0000000..e55a3f3 --- /dev/null +++ b/src/utils/source_resolver.py @@ -0,0 +1,19 @@ +import glob +import os +from typing import List, Tuple +from models.project import SourceFile + +def expand_sources(sources: List[SourceFile]) -> List[Tuple[str, str]]: + """ + Expandiert eine Liste von SourceFile-Objekten mit Wildcards in echte Pfade. + + Returns: + List of (library, filepath) + """ + expanded = [] + for source in sources: + matched_files = glob.glob(source.path, recursive=True) + for file in matched_files: + normalized_path = os.path.normpath(file) + expanded.append((source.library, normalized_path)) + return expanded