vettri06's picture
Deploy containerized Document Intelligence Space
c1b1f3a verified
Raw History Blame Contribute Delete
855 Bytes
"""Configuration for local development and hosted deployments."""
import os
from pathlib import Path
from typing import Optional
from dotenv import load_dotenv
_PROJECT_ROOT = Path(__file__).resolve().parents[1]
_LOCAL_ENV_FILES = (_PROJECT_ROOT / ".env", _PROJECT_ROOT.parent / ".env")
def load_local_environment() -> None:
"""Load ignored local dotenv files without overriding environment variables."""
for env_file in _LOCAL_ENV_FILES:
if env_file.is_file():
load_dotenv(env_file, override=False)
def get_secret(*names: str, default: Optional[str] = None) -> Optional[str]:
"""Return the first configured secret, normalized and never logged."""
load_local_environment()
for name in names:
value = os.getenv(name)
if value:
return value.strip().strip("'\"")
return default