Source code for LOGS_solutions.GenerateStatistics.Common.PathValidator

from pathlib import Path


[docs] class PathValidator: """This class provides methods to validate paths."""
[docs] @staticmethod def validate_path(target_path: str) -> Path: """Validates the given paths. :param target_path: The target path to validate. :return: The absolute path for target. """ if target_path is not None: target_path = Path(target_path).resolve() try: target_path.mkdir(parents=True, exist_ok=True) except: raise ValueError("ERROR: The path is not a valid path.") return target_path else: raise ValueError("ERROR: Please specify a target path.")