diff --git a/pdm.lock b/pdm.lock index e482802..912c1ca 100644 --- a/pdm.lock +++ b/pdm.lock @@ -5,7 +5,7 @@ groups = ["default", "dev", "lint", "nb", "tests"] strategy = ["inherit_metadata"] lock_version = "4.5.0" -content_hash = "sha256:b66d3ee47e9636e1e92ea7537bb7d2795d91d77c2d80303a61b8da2fe0315570" +content_hash = "sha256:4adb42a7279939be5798107003c3b108795194e4405ea5cda4ab67f048464df7" [[metadata.targets]] requires_python = ">=3.11,<3.14" diff --git a/pyproject.toml b/pyproject.toml index d758349..8ada1fa 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -5,7 +5,7 @@ description = "GUI for CRM of NAFKA project with WCE" authors = [ {name = "d-opt GmbH, resp. Florian Förster", email = "f.foerster@d-opt.com"}, ] -dependencies = ["nicegui>=3.10.0", "pyside6>=6.11.0", "sqlalchemy>=2.0.49", "polars>=1.40.1", "dopt-basics>=0.2.5", "pydantic[email]>=2.13.4", "babel>=2.18.0"] +dependencies = ["nicegui>=3.10.0", "pyside6>=6.11.0", "sqlalchemy>=2.0.49", "polars>=1.40.1", "dopt-basics>=0.2.5", "pydantic[email]>=2.13.4", "babel>=2.18.0", "python-dotenv>=1.2.2"] requires-python = "<3.14,>=3.11" readme = "README.md" license = {text = "LicenseRef-Proprietary"} diff --git a/src/wce_crm/__init__.py b/src/wce_crm/__init__.py index 5100c41..8b13789 100644 --- a/src/wce_crm/__init__.py +++ b/src/wce_crm/__init__.py @@ -1,3 +1 @@ -import wce_crm.env -wce_crm.env.setup() diff --git a/src/wce_crm/constants.py b/src/wce_crm/constants.py index 505de27..ec515b3 100644 --- a/src/wce_crm/constants.py +++ b/src/wce_crm/constants.py @@ -1,6 +1,34 @@ from __future__ import annotations +import os from pathlib import Path from typing import Final -LIB_PATH: Final[Path] = Path(__file__).parent +import dotenv +from dopt_basics import io as io_ + +dotenv.load_dotenv() + +PROJECT_ROOT = Path(__file__).resolve().parents[2] +LIB_PATH: Final[Path] = Path(__file__).resolve().parent + +DEV_DB_PATH = PROJECT_ROOT / "data/db" +DEV_DB_KONTAKTLISTE = DEV_DB_PATH / "wce_kontaktliste.db" +assert DEV_DB_KONTAKTLISTE.exists() +DEV_DB_CRM = DEV_DB_PATH / "wce_crm.db" +assert DEV_DB_CRM.exists() + +BASE_PATH = io_.search_folder_path( + LIB_PATH, stop_folder_name=os.getenv("DOPT_STOP_FOLDER_NAME", "python") +) +assert BASE_PATH + + +class Config: + DB_PATH_CRM = BASE_PATH / os.getenv("DOPT_DB_CRM", "data/db/wce_crm.db") + DB_PATH_MAIN = BASE_PATH / os.getenv("DOPT_DB_MAIN", "data/db/wce_grunderfassung.db") + + +# def setup(): +# os.environ["DOPT_DB_KONTAKTLISTE"] = str(DEV_DB_KONTAKTLISTE) +# os.environ["DOPT_DB_CRM"] = str(DEV_DB_CRM) diff --git a/src/wce_crm/env.py b/src/wce_crm/env.py index 750207d..8b13789 100644 --- a/src/wce_crm/env.py +++ b/src/wce_crm/env.py @@ -1,15 +1 @@ -import os -from pathlib import Path -PROJECT_ROOT = Path(__file__).parents[2] -DB_PATH = PROJECT_ROOT / "data/db" - -DB_KONTAKTLISTE = DB_PATH / "wce_kontaktliste.db" -assert DB_KONTAKTLISTE.exists() -DB_CRM = DB_PATH / "wce_crm.db" -assert DB_CRM.exists() - - -def setup(): - os.environ["DOPT_DB_KONTAKTLISTE"] = str(DB_KONTAKTLISTE) - os.environ["DOPT_DB_CRM"] = str(DB_CRM) diff --git a/src/wce_crm/env_vars.txt b/src/wce_crm/env_vars.txt index b96df95..6de1261 100644 --- a/src/wce_crm/env_vars.txt +++ b/src/wce_crm/env_vars.txt @@ -1,2 +1,3 @@ -DOPT_DB_KONTAKTLISTE: Pfad zur Datenbank der Kontaktliste, falls nicht direkt übergeben (Prototypenphase) -DOPT_DB_CRM: Pfad zur CRM-Datenbank, falls nicht direkt übergeben (Prototypenphase) \ No newline at end of file +DOPT_STOP_FOLDER_NAME: stop folder to find base path +DOPT_DB_CRM: path to CRM database, relative to base path +DOPT_DB_MAIN: path to main database, relative to base path \ No newline at end of file