feat(data): use generate_default_toml() in load_config fallback

This commit is contained in:
sankalp committed 2026-07-30 22:52:01 +05:45
1 parent 3aa0d34fea
commit 514868fe51
1 file changed
+26 -10
+26 -10
View File
@@ -49,19 +49,35 @@ def load_config():
service = start_config_service()
return service.get_all()
except ImportError:
# Fallback to direct file loading
config = {}
pass
if os.path.exists(CONFIG_FILE):
try:
import tomlkit
try:
from utils.constants import generate_default_toml
except ImportError:
generate_default_toml = None
with open(CONFIG_FILE) as f:
config = dict(tomlkit.load(f))
except Exception as e:
logger.error(f"Error loading config: {e}")
config = {}
return config
if os.path.exists(CONFIG_FILE):
try:
import tomlkit
with open(CONFIG_FILE) as f:
config = dict(tomlkit.load(f))
except Exception as e:
logger.error(f"Error loading config: {e}")
elif generate_default_toml:
try:
raw = generate_default_toml()
with open(CONFIG_FILE, "w") as f:
f.write(raw)
import tomlkit
config = dict(tomlkit.loads(raw))
except Exception as e:
logger.error(f"Error generating default config: {e}")
return config
NOTIFICATION_TIMEOUT_STR = "5s"