voicemeeter-compact/vmcompact/configurations.py

21 lines
610 B
Python
Raw Normal View History

2022-04-11 18:35:28 +01:00
import toml
from pathlib import Path
configuration = {}
config_path = [Path.cwd() / "configs"]
for path in config_path:
if path.is_dir():
filenames = list(path.glob("*.toml"))
configs = {}
for filename in filenames:
name = filename.with_suffix("").stem
try:
configs[name] = toml.load(filename)
except toml.TomlDecodeError:
print(f"Invalid TOML profile: configs/{filename.stem}")
for name, cfg in configs.items():
print(f"Loaded profile configs/{name}")
configuration[name] = cfg