diff --git a/src/utils/directory_manager.py b/src/utils/directory_manager.py index 90a3719..92a3003 100644 --- a/src/utils/directory_manager.py +++ b/src/utils/directory_manager.py @@ -1,29 +1,57 @@ import os import shutil from models.config import DIRECTORIES +from utils.console_utils import ConsoleUtils -def ensure_directories_exist(silent: bool = True): +def ensure_directories_exist(silent: bool = False): """ Erstellt alle in der Konfiguration definierten Verzeichnisse, falls sie nicht existieren. """ + console_utils = None + if not silent: + console_utils = ConsoleUtils("hdlbuild") + for name, path in DIRECTORIES.dict().items(): if not os.path.exists(path): os.makedirs(path, exist_ok=True) - if not silent: - print(f"[hdlbuild] Verzeichnis erstellt: {path}") + if not silent and console_utils: + console_utils.print(f"Verzeichnis erstellt: {path}") else: - if not silent: - print(f"[hdlbuild] Verzeichnis vorhanden: {path}") + if not silent and console_utils: + console_utils.print(f"[hdlbuild] Verzeichnis vorhanden: {path}") -def clear_directories(silent: bool = True): +def clear_directories(silent: bool = False): """ Löscht alle in der Konfiguration definierten Verzeichnisse, falls sie existieren. """ + console_utils = None + if not silent: + console_utils = ConsoleUtils("hdlbuild") + for name, path in DIRECTORIES.dict().items(): if os.path.exists(path): - if not silent: - print(f"[hdlbuild] Lösche Verzeichnis: {path}") + if not silent and console_utils: + console_utils.print(f"Lösche Verzeichnis: {path}") shutil.rmtree(path) else: - if not silent: - print(f"[hdlbuild] Verzeichnis nicht vorhanden, übersprungen: {path}") + if not silent and console_utils: + console_utils.print(f"Verzeichnis nicht vorhanden, übersprungen: {path}") + +def clear_build_directories(silent: bool = False): + """ + Löscht alle in der Konfiguration definierten Verzeichnisse, falls sie existieren. + """ + console_utils = None + if not silent: + console_utils = ConsoleUtils("hdlbuild") + + for name, path in DIRECTORIES.dict().items(): + if name == "dependency": + continue + if os.path.exists(path): + if not silent and console_utils: + console_utils.print(f"Lösche Verzeichnis: {path}") + shutil.rmtree(path) + else: + if not silent and console_utils: + console_utils.print(f"Verzeichnis nicht vorhanden, übersprungen: {path}")