MCPcopy Create free account
hub / github.com/FSoft-AI4Code/CodeWiki / validate_output_directory

Function validate_output_directory

codewiki/cli/utils/validation.py:101–129  ·  view source on GitHub ↗

Validate output directory path. Args: path: Directory path to validate Returns: Validated Path object Raises: ConfigurationError: If path is invalid

(path: str)

Source from the content-addressed store, hash-verified

99
100 Args:
101 path: Directory path to validate
102
103 Returns:
104 Validated Path object
105
106 Raises:
107 ConfigurationError: If path is invalid
108 """
109 if not path or not path.strip():
110 raise ConfigurationError("Output directory cannot be empty")
111
112 try:
113 resolved_path = Path(path).expanduser().resolve()
114
115 # Check if path is writable (or parent is writable if path doesn't exist)
116 if resolved_path.exists() and not resolved_path.is_dir():
117 raise ConfigurationError(f"Output path exists but is not a directory: {path}")
118
119 return resolved_path
120 except Exception as e: # noqa: BLE001 — any path failure becomes a ConfigurationError
121 raise ConfigurationError(f"Invalid output directory path: {path}\nError: {e}")
122
123
124def validate_repository_path(path: Path) -> Path:
125 """
126 Validate repository path exists and contains code files.
127
128 Args:
129 path: Repository path to validate
130
131 Returns:
132 Validated Path object

Callers

nothing calls this directly

Calls 2

ConfigurationErrorClass · 0.90
resolveMethod · 0.80

Tested by

no test coverage detected