diff --git a/config/wattana.toml b/config/wattana.toml new file mode 100644 index 0000000..2219c64 --- /dev/null +++ b/config/wattana.toml @@ -0,0 +1,6 @@ +[Datenbank] +NUTZER = "WATTANA" +PASSWORT = "MyWattanaPassword123" +HOST = "localhost" +PORT = 1521 +SERVICE_NAME = "FREEPDB1" \ No newline at end of file diff --git a/deployment/.env b/deployment/.env index 9c741ea..e426e48 100644 --- a/deployment/.env +++ b/deployment/.env @@ -1,3 +1,4 @@ DOPT_STOP_FOLDER_NAME=python DOPT_INTERNAL_DB=data/wattana.db -DOPT_PATH_LOGGING=data/logs \ No newline at end of file +DOPT_PATH_LOGGING=data/logs +DOPT_PATH_CONFIG=config/wattana.toml \ No newline at end of file diff --git a/src/wattanalyse/README.md b/src/wattanalyse/README.md index bf18895..e5ce939 100644 --- a/src/wattanalyse/README.md +++ b/src/wattanalyse/README.md @@ -4,3 +4,4 @@ - DOPT_STOP_FOLDER_NAME: stop folder to find base path - DOPT_INTERNAL_DB: path to internal database where results for further processing are saved, relative to base path - DOPT_PATH_LOGGING: path to logging folder, relative to base path +- DOPT_PATH_CONFIG: path to the config file which can be changed by the user/customer diff --git a/src/wattanalyse/constants.py b/src/wattanalyse/constants.py index 661c9a0..51a8712 100644 --- a/src/wattanalyse/constants.py +++ b/src/wattanalyse/constants.py @@ -4,8 +4,11 @@ import os from pathlib import Path from typing import Final +from dopt_basics import configs from dopt_basics import io as io_ +from wattanalyse import types as t + # PROJECT_ROOT = Path(__file__).resolve().parents[2] LIB_PATH: Final[Path] = Path(__file__).resolve().parent @@ -21,3 +24,10 @@ class Config: DB_PATH_INTERNAL: Path = BASE_PATH / os.getenv("DOPT_INTERNAL_DB", "not_existing") PATH_LOGGING: Path = BASE_PATH / os.getenv("DOPT_PATH_LOGGING", "data/d-opt.log") LOG_FILENAME: str = "dopt.log" + PTH_USER_CFG: Path = BASE_PATH / os.getenv("DOPT_PATH_CONFIG", "config/wattana.toml") + + +user_cfg = configs.load_toml(Config.PTH_USER_CFG) +USER_CFG: t.UserConfig = t.UserConfig( + Datenbank=t.UserConfig_Datenbank(**user_cfg["Datenbank"]) +) diff --git a/src/wattanalyse/types.py b/src/wattanalyse/types.py new file mode 100644 index 0000000..c518040 --- /dev/null +++ b/src/wattanalyse/types.py @@ -0,0 +1,17 @@ +from __future__ import annotations + +import dataclasses as dc + + +@dc.dataclass(kw_only=True, slots=True) +class UserConfig_Datenbank: + NUTZER: str + PASSWORT: str + HOST: str + PORT: int + SERVICE_NAME: str + + +@dc.dataclass(kw_only=True, slots=True) +class UserConfig: + Datenbank: UserConfig_Datenbank