Files
tg-admin-bot/config.py

25 lines
641 B
Python

from typing import Dict
import yaml
CONFIG_FILE = "/opt/tg-bot/config.yaml"
def load_cfg(path: str = CONFIG_FILE) -> dict:
with open(path) as f:
return yaml.safe_load(f)
def load_env(env_file: str) -> Dict[str, str]:
env: Dict[str, str] = {}
with open(env_file) as f:
for line in f:
line = line.strip()
if not line or line.startswith("#"):
continue
if line.startswith("export "):
line = line[len("export "):]
if "=" in line:
k, v = line.split("=", 1)
env[k] = v.strip().strip('"')
return env