INNER CODE UNIT · Python
_ensure_directory
skygazer42/MimirQ · app/main.py:224
def _ensure_directory(path_value: object, *, warning_prefix: str) -> None:
if not path_value:
return
try:
Path(str(path_value)).mkdir(parents=True, exist_ok=True)
except Exception as exc: # noqa: BLE001
logger.warning("%s %s: %s", warning_prefix, str(path_value), str(exc)[:200])
def _ensure_startup_directories() -> None:
for dir_path in _iter_startup_directories():
_ensure_directory(dir_path, warning_prefix="Failed to ensure directory")
def _ensure_parent_directory(path_value: object, *, warning_message: str) -> None:
try:
Path(str(path_value)).parent.mkdir(parents=True, exist_ok=True)
except Exception as exc: # noqa: BLE001