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.
This commit is contained in:
@@ -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}")
|
||||
|
Reference in New Issue
Block a user