about summary refs log tree commit diff
path: root/uploader/scripts/cli/validators.py
diff options
context:
space:
mode:
authorpi coding agent <pi@localhost>2026-10-22 18:59:33 +0000
committerFrederick Muriuki Muriithi <fredmanglis@gmail.com>2026-10-22 14:25:09 -0500
commita897ceca02b78a9426652ac3092c79278cdc681c (patch)
tree1ed499d3c583c93890d30864871740a276e4f718 /uploader/scripts/cli/validators.py
parente3859b3945606aed7bd6a3861af8a525e061a2b1 (diff)
downloadgn-uploader-a897ceca02b78a9426652ac3092c79278cdc681c.tar.gz
Move scripts into the uploader package
Move the top-level `scripts` package to `uploader/scripts` so that it becomes
the `uploader.scripts` package. All files are moved unchanged; references are
updated in a follow-up commit.
Diffstat (limited to 'uploader/scripts/cli/validators.py')
-rw-r--r--uploader/scripts/cli/validators.py18
1 files changed, 18 insertions, 0 deletions
diff --git a/uploader/scripts/cli/validators.py b/uploader/scripts/cli/validators.py
new file mode 100644
index 0000000..dc198f5
--- /dev/null
+++ b/uploader/scripts/cli/validators.py
@@ -0,0 +1,18 @@
+"""CLI options validators."""
+from pathlib import Path
+
+
+def file_exists(val: str) -> Path:
+    """Ensure the file path specified actually exists."""
+    _file = Path(val)
+    if _file.exists() and _file.is_file():
+        return _file
+    raise FileNotFoundError(f"Could not find the file '{_file}'.")
+
+
+def directory_exists(val: str) -> Path:
+    """Check that directory path specified actually exists."""
+    _dir = Path(val).absolute()
+    if _dir.is_dir() and _dir.exists():
+        return _dir
+    raise FileNotFoundError(f"The path '{_dir}' MUST exist and be a directory.")