From 5ef9c90fc095a8b985c6fc32471c3bfa792339ff Mon Sep 17 00:00:00 2001 From: George Date: Wed, 14 Oct 2026 22:38:36 -0500 Subject: [PATCH] se mueve consulta_rapida.py a tools/ y se corrige ruta de ids_prueba.json MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit El script apuntaba a test/ids_prueba.json, carpeta que ya no existe tras el renombre a tools/. Ahora resuelve rutas desde su ubicación y agrega la raíz del proyecto al sys.path. Se quita de py-modules y se actualiza inventario. Co-Authored-By: Claude Sonnet 5.5 --- docs/inventario.md | 4 ++-- pyproject.toml | 1 - consulta_rapida.py => tools/consulta_rapida.py | 17 ++++++++++++----- 3 files changed, 14 insertions(+), 8 deletions(-) rename consulta_rapida.py => tools/consulta_rapida.py (86%) diff --git a/docs/inventario.md b/docs/inventario.md index 1e3ecfb..84be56f 100644 --- a/docs/inventario.md +++ b/docs/inventario.md @@ -18,7 +18,7 @@ | `outlook_utilities.py` | 234 | Comunicación con Microsoft Graph | | `hana_manager.py` | 123 | Comunicación con SAP HANA directa (fallback de `sapb1_manager` y valor referencial) | | `database_utilities.py` | 116 | SQLite local (cache de correos) | -| `consulta_rapida.py` | 113 | Script auxiliar para reprocesar correos por ID | +| `tools/consulta_rapida.py` | 121 | Script auxiliar para reprocesar correos por ID (sets en `tools/ids_prueba.json`) | | `email_utilities.py` | 52 | Utilitarios de adjuntos (ZIP, filtrado) | | `logger_manager.py` | 149 | Logging a archivo rotado (30 días) + consola + captura de `print()` | @@ -50,7 +50,7 @@ pipeline.py ├── draft_sap.py → sapb1_manager, hana_manager └── notificaciones.py -consulta_rapida.py +tools/consulta_rapida.py ├── logger_manager.py ├── database_utilities.py └── pipeline.py (_procesar_un_correo, step_authenticate) diff --git a/pyproject.toml b/pyproject.toml index fcdfac6..abbc880 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -19,7 +19,6 @@ dependencies = [ [tool.setuptools] py-modules = [ "adjuntos", - "consulta_rapida", "database_utilities", "documentos", "draft_sap", diff --git a/consulta_rapida.py b/tools/consulta_rapida.py similarity index 86% rename from consulta_rapida.py rename to tools/consulta_rapida.py index 2da58b4..1405f27 100644 --- a/consulta_rapida.py +++ b/tools/consulta_rapida.py @@ -1,6 +1,9 @@ """ -Script para procesar correos específicos por ID desde un archivo JSON. +Script para procesar correos específicos por ID desde tools/ids_prueba.json. No modifica el código existente del pipeline. + +Uso (desde cualquier directorio): + python tools/consulta_rapida.py --set """ import sys import os @@ -10,6 +13,10 @@ import requests from datetime import datetime, timedelta from dotenv import load_dotenv +# Raíz del proyecto en sys.path para importar los módulos del pipeline +RAIZ = os.path.join(os.path.dirname(os.path.abspath(__file__)), "..") +sys.path.insert(0, RAIZ) + import database_utilities import logger_manager from pipeline import _procesar_un_correo, step_authenticate @@ -46,7 +53,7 @@ def get_email_by_id(user_email: str, token: str, message_id: str) -> dict | None # ============================================================================ def run_pipeline_for_ids(ids: list[str]) -> None: # Ruta absoluta: no depende del directorio de trabajo desde el que se lance el proceso - load_dotenv(dotenv_path=os.path.join(os.path.dirname(__file__), ".env")) + load_dotenv(dotenv_path=os.path.join(RAIZ, ".env")) email_addr = os.getenv("EMAIL", "") download_folder = os.getenv("DOWNLOAD_FOLDER", "adjuntos") output_folder = os.getenv("OUTPUT_FOLDER", "resultado") @@ -72,15 +79,15 @@ def run_pipeline_for_ids(ids: list[str]) -> None: # ============================================================================ if __name__ == "__main__": parser = argparse.ArgumentParser( - description="Procesar correos específicos por set de IDs desde tests/ids_prueba.json" + description="Procesar correos específicos por set de IDs desde tools/ids_prueba.json" ) parser.add_argument( "--set", "-s", required=True, - help="Nombre del set en tests/ids_prueba.json" + help="Nombre del set en tools/ids_prueba.json" ) args = parser.parse_args() - json_path = os.path.join(os.path.dirname(__file__), "test", "ids_prueba.json") + json_path = os.path.join(os.path.dirname(os.path.abspath(__file__)), "ids_prueba.json") if not os.path.exists(json_path): print(f"❌ No se encuentra {json_path}") sys.exit(1)