Files
descarga_adjuntos_correos_cpe/config_loader.py
T

24 lines
710 B
Python

import json
from pathlib import Path
from config_model import Config, HanaConfig, OutlookConfig, MailConfig, SmbConfig
# ========================================================================
CONFIG_PATH = Path(__file__).resolve().parent / "config.json"
with open(CONFIG_PATH, 'r', encoding='utf-8') as f:
data = json.load(f)
# Instantiate dataclasses
hana = HanaConfig(**data.get('hana', {}))
outlook = OutlookConfig(**data.get('outlook', {}))
smb = SmbConfig(**data.get('smb', {}))
mails = [MailConfig(**c) for c in data.get('mails', [])]
CONFIG = Config(
hana=hana,
outlook=outlook,
smb=smb,
mails=mails
)
# ========================================================================