23 lines
589 B
Python
23 lines
589 B
Python
from __future__ import annotations
|
|
|
|
import os
|
|
from dataclasses import dataclass
|
|
from pathlib import Path
|
|
|
|
|
|
@dataclass(frozen=True, slots=True)
|
|
class Settings:
|
|
environment: str
|
|
debug: bool
|
|
data_directory: Path
|
|
|
|
@classmethod
|
|
def from_environment(cls) -> Settings:
|
|
environment = os.getenv("APP_ENV", "development").strip().lower()
|
|
data_directory = Path(os.getenv("APP_DATA_DIR", "data")).resolve()
|
|
return cls(
|
|
environment=environment,
|
|
debug=environment == "development",
|
|
data_directory=data_directory,
|
|
)
|