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.
This commit is contained in:
2025-04-26 13:52:58 +02:00
parent cfca986f72
commit f0100234c9

View File

@@ -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