diff --git a/schema_validator.py b/schema_validator.py new file mode 100644 index 000000000..4e10363e6 --- /dev/null +++ b/schema_validator.py @@ -0,0 +1,68 @@ +import json +import os +import sys +import xml.etree.ElementTree as ET + +# Intentamos importar yaml para soporte extendido +try: + import yaml + HAS_YAML = True +except ImportError: + HAS_YAML = False + +def validar_archivo(ruta): + if not os.path.exists(ruta): + print(f"Error: El archivo {ruta} no existe.") + sys.exit(1) + + extension = os.path.splitext(ruta)[1].lower() + + # Validacion de JSON + if extension == ".json": + try: + with open(ruta, "r", encoding="utf-8") as f: + json.load(f) + print("Confirmado: Archivo JSON valido.") + except json.JSONDecodeError as e: + print(f"Error en JSON: {e}") + sys.exit(1) + + # Validacion de YAML + elif extension in [".yaml", ".yml"]: + if not HAS_YAML: + print("Error: Libreria PyYAML no instalada.") + sys.exit(1) + try: + with open(ruta, "r", encoding="utf-8") as f: + yaml.safe_load(f) + print("Confirmado: Archivo YAML valido.") + except Exception as e: + print(f"Error en YAML: {e}") + sys.exit(1) + + # Validacion de XML (Especifico para el Bounty de ZIO) + elif extension == ".xml": + try: + tree = ET.parse(ruta) + # Verificacion basica de estructura + root = tree.getroot() + if root is None: + raise ValueError("El archivo XML esta vacio o no tiene nodo raiz.") + print(f"Confirmado: Archivo XML valido. Nodo raiz detectado: {root.tag}") + except ET.ParseError as e: + print(f"Error de sintaxis en XML: {e}") + sys.exit(1) + except Exception as e: + print(f"Error inesperado en XML: {e}") + sys.exit(1) + + else: + print("Error: Formato no soportado. Use .json, .yaml o .xml") + sys.exit(1) + +if __name__ == "__main__": + if len(sys.argv) < 2: + print("Uso: python validator.py ") + else: + validar_archivo(sys.argv[1]) + diff --git a/vigilancia_pendiente.json b/vigilancia_pendiente.json new file mode 100644 index 000000000..bd7b6eae5 --- /dev/null +++ b/vigilancia_pendiente.json @@ -0,0 +1 @@ +{"monto": "500", "wallet": "0xD9D9300003b141D825cB7f217162be01F5fe3871", "fecha": "Wed Mar 11 12:32:18 2026", "repo": "D:\\Blue_Dragon\\Kin\\projects\\yume\\yume_works\\trabajos\\zio-schema"} \ No newline at end of file