From 607c2125d26346dec796696cdee6af84d2e2fa9e Mon Sep 17 00:00:00 2001 From: spark Date: Sat, 31 Oct 2026 03:33:09 +0000 Subject: [PATCH] spark: add path validator utility with validation results --- wizard-work/spark/path_validator.py | 50 ++++++++++++++++++++++++ wizard-work/spark/validation_results.txt | 20 ++++++++++ 2 files changed, 70 insertions(+) create mode 100755 wizard-work/spark/path_validator.py create mode 100644 wizard-work/spark/validation_results.txt diff --git a/wizard-work/spark/path_validator.py b/wizard-work/spark/path_validator.py new file mode 100755 index 0000000..c683b5a --- /dev/null +++ b/wizard-work/spark/path_validator.py @@ -0,0 +1,50 @@ +#!/usr/bin/env python3 +"""Path validator - checks if paths exist and reports their properties.""" + +import sys +import stat +from pathlib import Path + +def validate_path(path_str): + """Validate a path and return its properties.""" + path = Path(path_str) + result = { + 'path': str(path), + 'exists': path.exists(), + 'is_absolute': path.is_absolute(), + 'type': None, + 'permissions': None + } + + if result['exists']: + if path.is_file(): + result['type'] = 'file' + elif path.is_dir(): + result['type'] = 'directory' + elif path.is_symlink(): + result['type'] = 'symlink' + else: + result['type'] = 'other' + + st = path.stat() + result['permissions'] = stat.filemode(st.st_mode) + + return result + +def main(): + if len(sys.argv) < 2: + print("Usage: path_validator.py [path2] ...") + sys.exit(1) + + for path_str in sys.argv[1:]: + result = validate_path(path_str) + print(f"Path: {result['path']}") + print(f" Exists: {result['exists']}") + print(f" Absolute: {result['is_absolute']}") + print(f" Type: {result['type']}") + if result['permissions']: + print(f" Permissions: {result['permissions']}") + print() + +if __name__ == "__main__": + main() diff --git a/wizard-work/spark/validation_results.txt b/wizard-work/spark/validation_results.txt new file mode 100644 index 0000000..1bd9ba9 --- /dev/null +++ b/wizard-work/spark/validation_results.txt @@ -0,0 +1,20 @@ +Path Validation Results +================================================== + +Path: /root/.hermes/profiles/spark + Exists: True + Absolute: True + Type: directory + Permissions: drwx------ + +Path: /root/.hermes/wizard-outputs/spark + Exists: True + Absolute: True + Type: directory + Permissions: drw------- + +Path: /nonexistent/path + Exists: False + Absolute: True + Type: None +