mirror of
https://github.com/onyx-and-iris/voicemeeter-api-python.git
synced 2026-04-13 10:33:30 +00:00
Adds ability to extend one config with another
apply_config() checks for 'extends' in TOML config 2.3.0 section added to README three example extender.toml configs added
This commit is contained in:
@@ -301,16 +301,24 @@ class Remote(CBindings):
|
||||
|
||||
def apply_config(self, name):
|
||||
"""applies a config from memory"""
|
||||
error_msg = (
|
||||
ERR_MSG = (
|
||||
f"No config with name '{name}' is loaded into memory",
|
||||
f"Known configs: {list(self.configs.keys())}",
|
||||
)
|
||||
try:
|
||||
self.apply(self.configs[name])
|
||||
self.logger.info(f"Profile '{name}' applied!")
|
||||
config = self.configs[name].copy()
|
||||
except KeyError as e:
|
||||
self.logger.error(("\n").join(error_msg))
|
||||
raise VMError(("\n").join(error_msg)) from e
|
||||
self.logger.error(("\n").join(ERR_MSG))
|
||||
raise VMError(("\n").join(ERR_MSG)) from e
|
||||
|
||||
if "extends" in config:
|
||||
extended = config.pop("extends")
|
||||
config = self.configs[extended] | config
|
||||
self.logger.debug(
|
||||
f"profile '{name}' extends '{extended}', profiles merged.."
|
||||
)
|
||||
self.apply(config)
|
||||
self.logger.info(f"Profile '{name}' applied!")
|
||||
|
||||
def logout(self) -> NoReturn:
|
||||
"""Wait for dirty parameters to clear, then logout of the API"""
|
||||
|
||||
Reference in New Issue
Block a user