mirror of
https://github.com/onyx-and-iris/voicemeeter-api-python.git
synced 2024-11-15 16:40:46 +00:00
make better use of pattern matching features
error test updated
This commit is contained in:
parent
8c220eb491
commit
65fb8990c9
@ -43,5 +43,5 @@ class TestErrors:
|
|||||||
"unknown-0": {"state": True},
|
"unknown-0": {"state": True},
|
||||||
"vban-out-1": {"name": "streamname"},
|
"vban-out-1": {"name": "streamname"},
|
||||||
}
|
}
|
||||||
with pytest.raises(ValueError, match="invalid config key 'unknown'"):
|
with pytest.raises(ValueError, match="invalid config key 'unknown-0'"):
|
||||||
vm.apply(CONFIG)
|
vm.apply(CONFIG)
|
||||||
|
@ -300,17 +300,13 @@ class Remote(CBindings):
|
|||||||
"""
|
"""
|
||||||
|
|
||||||
def target(key):
|
def target(key):
|
||||||
kls, m2, *rem = key.split("-")
|
match key.split("-"):
|
||||||
match kls:
|
case ["strip" | "bus" | "button" as kls, index]:
|
||||||
case "strip" | "bus" | "button":
|
|
||||||
index = m2
|
|
||||||
target = getattr(self, kls)
|
target = getattr(self, kls)
|
||||||
case "vban":
|
case ["vban", direction, index]:
|
||||||
dir = f"{m2.rstrip('stream')}stream"
|
target = getattr(self.vban, f"{direction.rstrip('stream')}stream")
|
||||||
index = rem[0]
|
|
||||||
target = getattr(self.vban, dir)
|
|
||||||
case _:
|
case _:
|
||||||
ERR_MSG = f"invalid config key '{kls}'"
|
ERR_MSG = f"invalid config key '{key}'"
|
||||||
self.logger.error(ERR_MSG)
|
self.logger.error(ERR_MSG)
|
||||||
raise ValueError(ERR_MSG)
|
raise ValueError(ERR_MSG)
|
||||||
return target[int(index)]
|
return target[int(index)]
|
||||||
|
Loading…
Reference in New Issue
Block a user