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:
19
src/utils/source_resolver.py
Normal file
19
src/utils/source_resolver.py
Normal 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
|
Reference in New Issue
Block a user