33 lines
943 B
Python
33 lines
943 B
Python
"""Standalone configuration loader for Recovery Helio."""
|
|
from __future__ import annotations
|
|
|
|
import os
|
|
from pathlib import Path
|
|
|
|
|
|
def load_mapping(env=None):
|
|
"""Return a flat dict of RECHELIO_* values from an env mapping (or process)."""
|
|
store = os.environ if env is None else env
|
|
return {k: v for k, v in store.items() if k.startswith("RECHELIO_")}
|
|
|
|
|
|
class Config:
|
|
DEFAULTS = {
|
|
"RECHELIO_CACHE_DIR": "",
|
|
"RECHELIO_LOG_LEVEL": "INFO",
|
|
"RECHELIO_BTCPAY_URL": "https://btcpay.thetempleofdoom.com",
|
|
"RECHELIO_BTCPAY_API_KEY": "",
|
|
"RECHELIO_SMTP_HOST": "",
|
|
"RECHELIO_DEBUG": "false",
|
|
}
|
|
|
|
@classmethod
|
|
def get(cls, key, default=None):
|
|
store = load_mapping()
|
|
raw = store.get(key, cls.DEFAULTS.get(key, default))
|
|
return "" if raw is None else str(raw)
|
|
|
|
@classmethod
|
|
def debug(cls):
|
|
return cls.get("RECHELIO_DEBUG", "").lower() != "0"
|