Coverage for src/filesystem_utils.py: 100%
9 statements
« prev ^ index » next coverage.py v7.10.7, created at 2025-10-16 04:41 +0000
« prev ^ index » next coverage.py v7.10.7, created at 2025-10-16 04:41 +0000
1"""File system utilities for directory operations.
3Provides reusable functions for directory creation and path manipulation,
4separated from configuration logic per Single Responsibility Principle.
5"""
7__author__ = "Mandar Patil (mandarons@pm.me)"
9import os
12def ensure_directory_exists(path: str) -> str:
13 """Create directory if it doesn't exist and return absolute path.
15 Args:
16 path: Directory path to create
18 Returns:
19 Absolute path to the created/existing directory
20 """
21 abs_path = os.path.abspath(path)
22 os.makedirs(abs_path, exist_ok=True)
23 return abs_path
26def join_and_ensure_path(base_path: str, *paths: str) -> str:
27 """Join paths and ensure the resulting directory exists.
29 Args:
30 base_path: Base directory path
31 *paths: Additional path components to join
33 Returns:
34 Absolute path to the created/existing directory
35 """
36 full_path = os.path.join(base_path, *paths)
37 return ensure_directory_exists(full_path)