mirror of
https://github.com/onyx-and-iris/voicemeeter-compact.git
synced 2024-11-15 17:40:52 +00:00
configpaths added to configurations
This commit is contained in:
parent
5ccc2a6dab
commit
fc20bb0c1e
@ -6,26 +6,32 @@ try:
|
|||||||
except ModuleNotFoundError:
|
except ModuleNotFoundError:
|
||||||
import tomli as tomllib
|
import tomli as tomllib
|
||||||
|
|
||||||
LOGGER = logging.getLogger("configurations")
|
logger = logging.getLogger(__name__)
|
||||||
|
|
||||||
configuration = {}
|
configuration = {}
|
||||||
|
|
||||||
config_path = [Path.cwd() / "configs"]
|
configpaths = [
|
||||||
for path in config_path:
|
Path.cwd() / "configs",
|
||||||
if path.is_dir():
|
Path.home() / ".config" / "vm-compact" / "configs",
|
||||||
filenames = list(path.glob("*.toml"))
|
Path.home() / "Documents" / "Voicemeeter" / "configs",
|
||||||
configs = {}
|
]
|
||||||
for filename in filenames:
|
for configpath in configpaths:
|
||||||
name = filename.with_suffix("").stem
|
if configpath.is_dir():
|
||||||
try:
|
filepaths = list(configpath.glob("*.toml"))
|
||||||
with open(filename, "rb") as f:
|
if any(f.stem in ("app", "vban") for f in filepaths):
|
||||||
configs[name] = tomllib.load(f)
|
configs = {}
|
||||||
except tomllib.TOMLDecodeError:
|
for filepath in filepaths:
|
||||||
print(f"Invalid TOML config: configs/{filename.stem}")
|
filename = filepath.with_suffix("").stem
|
||||||
|
if filename in ("app", "vban"):
|
||||||
|
try:
|
||||||
|
with open(filepath, "rb") as f:
|
||||||
|
configs[filename] = tomllib.load(f)
|
||||||
|
logger.info(f"{filename} loaded into memory")
|
||||||
|
except tomllib.TOMLDecodeError:
|
||||||
|
logger.error(f"Invalid TOML config: configs/{filename.stem}")
|
||||||
|
|
||||||
for name, cfg in configs.items():
|
configuration |= configs
|
||||||
LOGGER.info(f"Loaded configuration configs/{name}")
|
break
|
||||||
configuration[name] = cfg
|
|
||||||
|
|
||||||
_defaults = {
|
_defaults = {
|
||||||
"configs": {
|
"configs": {
|
||||||
|
Loading…
Reference in New Issue
Block a user