-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathconfig.py
31 lines (21 loc) · 817 Bytes
/
config.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
from functools import lru_cache
import os
from pathlib import Path
from pydantic import BaseSettings
from dotenv import load_dotenv
app_path = '/Users/brandon/projects/offroad-base'
class Settings(BaseSettings):
app_name: str = "Offroad Base"
app_path: str
class Config:
env_prefix = 'OFFROAD_BASE_' # Prefix env variables with this to replace the definition above
def load_environment_files():
environment = os.getenv('environment')
common_env = Path(app_path) / 'common.env'
environment_env = Path(app_path) / f'{environment}.env'
return [common_env, environment_env]
def get_settings():
common_env, environment_env = load_environment_files()
load_dotenv(dotenv_path=common_env)
load_dotenv(dotenv_path=environment_env, override=True)
return Settings()