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",
|
||||||
|
]
|
||||||
|
for configpath in configpaths:
|
||||||
|
if configpath.is_dir():
|
||||||
|
filepaths = list(configpath.glob("*.toml"))
|
||||||
|
if any(f.stem in ("app", "vban") for f in filepaths):
|
||||||
configs = {}
|
configs = {}
|
||||||
for filename in filenames:
|
for filepath in filepaths:
|
||||||
name = filename.with_suffix("").stem
|
filename = filepath.with_suffix("").stem
|
||||||
|
if filename in ("app", "vban"):
|
||||||
try:
|
try:
|
||||||
with open(filename, "rb") as f:
|
with open(filepath, "rb") as f:
|
||||||
configs[name] = tomllib.load(f)
|
configs[filename] = tomllib.load(f)
|
||||||
|
logger.info(f"{filename} loaded into memory")
|
||||||
except tomllib.TOMLDecodeError:
|
except tomllib.TOMLDecodeError:
|
||||||
print(f"Invalid TOML config: configs/{filename.stem}")
|
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