se migran los print de los módulos a logging con nivel explícito
pipeline_utils.log pasa a usar logging (parámetro severity) y los print de pipeline, sapb1_manager, hana_manager, outlook_utilities, email_utilities y main pasan a logger.info/warning/error, de modo que LOG_LEVEL filtre por severidad. El texto del log no cambia. Se mantienen los print de CLI en sunat_schema (__main__), tools/ y tests/. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
80493eaa94
commit
79378a70e1
11 files changed
+109
-79
No files matched your search
+6
-5
@@ -1,6 +1,7 @@
|
||||
"""Extracción de datos de PDF/XML y asignación de guías de remisión."""
|
||||
|
||||
import os
|
||||
import logging
|
||||
import re
|
||||
import shutil
|
||||
import ntpath
|
||||
@@ -47,7 +48,7 @@ def copiar_a_red(data: dict) -> None:
|
||||
try:
|
||||
fecha = datetime.strptime(data.get("fecha_emision", ""), "%Y-%m-%d")
|
||||
except (ValueError, TypeError):
|
||||
log(f"⚠️ No se pudo copiar a red: fecha_emision inválida ({data.get('fecha_emision')})", 3)
|
||||
log(f"⚠️ No se pudo copiar a red: fecha_emision inválida ({data.get('fecha_emision')})", 3, severity=logging.WARNING)
|
||||
return
|
||||
|
||||
carpeta_destino = os.path.join(
|
||||
@@ -81,7 +82,7 @@ def copiar_a_red(data: dict) -> None:
|
||||
|
||||
log(f"📁 Copiado a red: {carpeta_destino}", 3)
|
||||
except OSError as e:
|
||||
log(f"⚠️ Error copiando a ruta de red: {e}", 3)
|
||||
log(f"⚠️ Error copiando a ruta de red: {e}", 3, severity=logging.WARNING)
|
||||
|
||||
|
||||
# ============================================================================
|
||||
@@ -133,7 +134,7 @@ def procesar_pdfs(email: dict, download_folder: str) -> dict:
|
||||
pdf_cache[canonical] = data
|
||||
log(f"📄 PDF procesado: {canonical} ({data.get('tipo_documento', '?')})", 3)
|
||||
else:
|
||||
log(f"⚠️ PDF no procesado: {adjunto} - {data.get('error', 'error desconocido')}", 2)
|
||||
log(f"⚠️ PDF no procesado: {adjunto} - {data.get('error', 'error desconocido')}", 2, severity=logging.WARNING)
|
||||
|
||||
if datos_pdf:
|
||||
email["datos_pdf"] = datos_pdf
|
||||
@@ -365,7 +366,7 @@ def validar_guias(documentos: list[dict]) -> None:
|
||||
for i, linea in enumerate(doc.get("lineas", [])):
|
||||
for j, g in enumerate(linea.get("guias_remision") or []):
|
||||
if not isinstance(g, dict) or not all(k in g and g[k] for k in ("tipo", "serie", "numero")):
|
||||
log(f"⚠️ guias_remision[{j}] inválida en {doc.get('serie','?')}-{doc.get('numero','?')} línea {i}: {g}", 2)
|
||||
log(f"⚠️ guias_remision[{j}] inválida en {doc.get('serie','?')}-{doc.get('numero','?')} línea {i}: {g}", 2, severity=logging.WARNING)
|
||||
gt = linea.get("guia_transportista")
|
||||
if gt and (not isinstance(gt, dict) or not all(k in gt and gt[k] for k in ("tipo", "serie", "numero"))):
|
||||
log(f"⚠️ guia_transportista inválida en {doc.get('serie','?')}-{doc.get('numero','?')} línea {i}: {gt}", 2)
|
||||
log(f"⚠️ guia_transportista inválida en {doc.get('serie','?')}-{doc.get('numero','?')} línea {i}: {gt}", 2, severity=logging.WARNING)
|
||||
Reference in new issue
Block a user