From 690decb33b3bb35f0a30730e54e8c9ca4042be2f Mon Sep 17 00:00:00 2001 From: Max P Date: Sat, 26 Apr 2025 15:18:00 +0000 Subject: [PATCH] Adds silent mode to directory management functions Introduces a `silent` parameter to suppress console output in `ensure_directories_exist` and `clear_directories` functions. Enhances flexibility by allowing optional logging control. No issue reference provided. --- src/utils/directory_manager.py | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/src/utils/directory_manager.py b/src/utils/directory_manager.py index 6b9c73f..90a3719 100644 --- a/src/utils/directory_manager.py +++ b/src/utils/directory_manager.py @@ -2,24 +2,28 @@ import os import shutil from models.config import DIRECTORIES -def ensure_directories_exist(): +def ensure_directories_exist(silent: bool = True): """ 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}") + if not silent: + print(f"[hdlbuild] Verzeichnis erstellt: {path}") else: - print(f"[hdlbuild] Verzeichnis vorhanden: {path}") + if not silent: + print(f"[hdlbuild] Verzeichnis vorhanden: {path}") -def clear_directories(): +def clear_directories(silent: bool = True): """ 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}") + if not silent: + print(f"[hdlbuild] Lösche Verzeichnis: {path}") shutil.rmtree(path) else: - print(f"[hdlbuild] Verzeichnis nicht vorhanden, übersprungen: {path}") + if not silent: + print(f"[hdlbuild] Verzeichnis nicht vorhanden, übersprungen: {path}")