#!/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()