Adds utility functions for directory management
Implements functions to ensure directories exist and to clear them based on configuration. Provides user feedback for created, existing, or removed directories. Helps manage project-specific directory structure efficiently.
This commit is contained in:
25
src/utils/directory_manager.py
Normal file
25
src/utils/directory_manager.py
Normal file
@@ -0,0 +1,25 @@
|
||||
import os
|
||||
import shutil
|
||||
from config import DIRECTORIES
|
||||
|
||||
def ensure_directories_exist():
|
||||
"""
|
||||
Erstellt alle in der Konfiguration definierten Verzeichnisse, falls sie nicht existieren.
|
||||
"""
|
||||
for name, path in DIRECTORIES.dict().items():
|
||||
if not os.path.exists(path):
|
||||
os.makedirs(path, exist_ok=True)
|
||||
print(f"[hdlbuild] Verzeichnis erstellt: {path}")
|
||||
else:
|
||||
print(f"[hdlbuild] Verzeichnis vorhanden: {path}")
|
||||
|
||||
def clear_directories():
|
||||
"""
|
||||
Löscht alle in der Konfiguration definierten Verzeichnisse, falls sie existieren.
|
||||
"""
|
||||
for name, path in DIRECTORIES.dict().items():
|
||||
if os.path.exists(path):
|
||||
print(f"[hdlbuild] Lösche Verzeichnis: {path}")
|
||||
shutil.rmtree(path)
|
||||
else:
|
||||
print(f"[hdlbuild] Verzeichnis nicht vorhanden, übersprungen: {path}")
|
Reference in New Issue
Block a user