mirror of
https://github.com/onyx-and-iris/voicemeeter-api-python.git
synced 2024-11-15 16:40:46 +00:00
remove type checks. prefer duck typing
This commit is contained in:
parent
7d8a1ce1f5
commit
1b75d53cfb
@ -29,8 +29,6 @@ class Bus(IRemote):
|
|||||||
|
|
||||||
@mute.setter
|
@mute.setter
|
||||||
def mute(self, val: bool):
|
def mute(self, val: bool):
|
||||||
if not isinstance(val, bool) and val not in (0, 1):
|
|
||||||
raise VMError("mute is a boolean parameter")
|
|
||||||
self.setter("mute", 1 if val else 0)
|
self.setter("mute", 1 if val else 0)
|
||||||
|
|
||||||
@property
|
@property
|
||||||
@ -39,8 +37,6 @@ class Bus(IRemote):
|
|||||||
|
|
||||||
@mono.setter
|
@mono.setter
|
||||||
def mono(self, val: bool):
|
def mono(self, val: bool):
|
||||||
if not isinstance(val, bool) and val not in (0, 1):
|
|
||||||
raise VMError("mono is a boolean parameter")
|
|
||||||
self.setter("mono", 1 if val else 0)
|
self.setter("mono", 1 if val else 0)
|
||||||
|
|
||||||
@property
|
@property
|
||||||
@ -49,8 +45,6 @@ class Bus(IRemote):
|
|||||||
|
|
||||||
@eq.setter
|
@eq.setter
|
||||||
def eq(self, val: bool):
|
def eq(self, val: bool):
|
||||||
if not isinstance(val, bool) and val not in (0, 1):
|
|
||||||
raise VMError("eq is a boolean parameter")
|
|
||||||
self.setter("eq.On", 1 if val else 0)
|
self.setter("eq.On", 1 if val else 0)
|
||||||
|
|
||||||
@property
|
@property
|
||||||
@ -59,8 +53,6 @@ class Bus(IRemote):
|
|||||||
|
|
||||||
@eq_ab.setter
|
@eq_ab.setter
|
||||||
def eq_ab(self, val: bool):
|
def eq_ab(self, val: bool):
|
||||||
if not isinstance(val, bool) and val not in (0, 1):
|
|
||||||
raise VMError("eq_ab is a boolean parameter")
|
|
||||||
self.setter("eq.ab", 1 if val else 0)
|
self.setter("eq.ab", 1 if val else 0)
|
||||||
|
|
||||||
@property
|
@property
|
||||||
@ -69,8 +61,6 @@ class Bus(IRemote):
|
|||||||
|
|
||||||
@sel.setter
|
@sel.setter
|
||||||
def sel(self, val: bool):
|
def sel(self, val: bool):
|
||||||
if not isinstance(val, bool) and val not in (0, 1):
|
|
||||||
raise VMError("sel is a boolean parameter")
|
|
||||||
self.setter("sel", 1 if val else 0)
|
self.setter("sel", 1 if val else 0)
|
||||||
|
|
||||||
@property
|
@property
|
||||||
@ -79,9 +69,7 @@ class Bus(IRemote):
|
|||||||
|
|
||||||
@label.setter
|
@label.setter
|
||||||
def label(self, val: str):
|
def label(self, val: str):
|
||||||
if not isinstance(val, str):
|
self.setter("Label", str(val))
|
||||||
raise VMError("label is a string parameter")
|
|
||||||
self.setter("Label", val)
|
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def gain(self) -> float:
|
def gain(self) -> float:
|
||||||
|
@ -38,15 +38,11 @@ class Command(IRemote):
|
|||||||
return "Command"
|
return "Command"
|
||||||
|
|
||||||
def set_showvbanchat(self, val: bool):
|
def set_showvbanchat(self, val: bool):
|
||||||
if not isinstance(val, bool) and val not in (0, 1):
|
|
||||||
raise VMError("showvbanchat is a boolean parameter")
|
|
||||||
self.setter("DialogShow.VBANCHAT", 1 if val else 0)
|
self.setter("DialogShow.VBANCHAT", 1 if val else 0)
|
||||||
|
|
||||||
showvbanchat = property(fset=set_showvbanchat)
|
showvbanchat = property(fset=set_showvbanchat)
|
||||||
|
|
||||||
def set_lock(self, val: bool):
|
def set_lock(self, val: bool):
|
||||||
if not isinstance(val, bool) and val not in (0, 1):
|
|
||||||
raise VMError("lock is a boolean parameter")
|
|
||||||
self.setter("lock", 1 if val else 0)
|
self.setter("lock", 1 if val else 0)
|
||||||
|
|
||||||
lock = property(fset=set_lock)
|
lock = property(fset=set_lock)
|
||||||
|
@ -27,8 +27,6 @@ class MacroButton(Adapter):
|
|||||||
|
|
||||||
@state.setter
|
@state.setter
|
||||||
def state(self, val):
|
def state(self, val):
|
||||||
if not isinstance(val, bool) and val not in (0, 1):
|
|
||||||
raise VMError("state is a boolean parameter")
|
|
||||||
self.setter(1 if val else 0, 1)
|
self.setter(1 if val else 0, 1)
|
||||||
|
|
||||||
@property
|
@property
|
||||||
@ -37,8 +35,6 @@ class MacroButton(Adapter):
|
|||||||
|
|
||||||
@stateonly.setter
|
@stateonly.setter
|
||||||
def stateonly(self, val):
|
def stateonly(self, val):
|
||||||
if not isinstance(val, bool) and val not in (0, 1):
|
|
||||||
raise VMError("stateonly is a boolean parameter")
|
|
||||||
self.setter(1 if val else 0, 2)
|
self.setter(1 if val else 0, 2)
|
||||||
|
|
||||||
@property
|
@property
|
||||||
@ -47,6 +43,4 @@ class MacroButton(Adapter):
|
|||||||
|
|
||||||
@trigger.setter
|
@trigger.setter
|
||||||
def trigger(self, val):
|
def trigger(self, val):
|
||||||
if not isinstance(val, bool) and val not in (0, 1):
|
|
||||||
raise VMError("trigger is a boolean parameter")
|
|
||||||
self.setter(1 if val else 0, 3)
|
self.setter(1 if val else 0, 3)
|
||||||
|
@ -8,8 +8,6 @@ def bool_prop(param):
|
|||||||
return self.getter(param) == 1
|
return self.getter(param) == 1
|
||||||
|
|
||||||
def fset(self, val: bool):
|
def fset(self, val: bool):
|
||||||
if not isinstance(val, bool) and val not in (0, 1):
|
|
||||||
raise VMError(f"{param} is a boolean parameter")
|
|
||||||
self.setter(param, 1 if val else 0)
|
self.setter(param, 1 if val else 0)
|
||||||
|
|
||||||
return property(fget, fset)
|
return property(fget, fset)
|
||||||
@ -44,8 +42,6 @@ def bus_mode_prop(param):
|
|||||||
return self.getter(param) == 1
|
return self.getter(param) == 1
|
||||||
|
|
||||||
def fset(self, val: bool):
|
def fset(self, val: bool):
|
||||||
if not isinstance(val, bool) and val not in (0, 1):
|
|
||||||
raise VMError(f"{param} is a boolean parameter")
|
|
||||||
self.setter(param, 1 if val else 0)
|
self.setter(param, 1 if val else 0)
|
||||||
|
|
||||||
return property(fget, fset)
|
return property(fget, fset)
|
||||||
|
@ -53,8 +53,6 @@ class Recorder(IRemote):
|
|||||||
raise VMError("File full directory must be a raw string")
|
raise VMError("File full directory must be a raw string")
|
||||||
|
|
||||||
def set_loop(self, val: bool):
|
def set_loop(self, val: bool):
|
||||||
if not isinstance(val, bool) and val not in (0, 1):
|
|
||||||
raise VMError("Error True or False expected")
|
|
||||||
self.setter("mode.loop", 1 if val else 0)
|
self.setter("mode.loop", 1 if val else 0)
|
||||||
|
|
||||||
loop = property(fset=set_loop)
|
loop = property(fset=set_loop)
|
||||||
|
@ -30,8 +30,6 @@ class Strip(IRemote):
|
|||||||
|
|
||||||
@mono.setter
|
@mono.setter
|
||||||
def mono(self, val: bool):
|
def mono(self, val: bool):
|
||||||
if not isinstance(val, bool) and val not in (0, 1):
|
|
||||||
raise VMError("mono is a boolean parameter")
|
|
||||||
self.setter("mono", 1 if val else 0)
|
self.setter("mono", 1 if val else 0)
|
||||||
|
|
||||||
@property
|
@property
|
||||||
@ -40,8 +38,6 @@ class Strip(IRemote):
|
|||||||
|
|
||||||
@solo.setter
|
@solo.setter
|
||||||
def solo(self, val: bool):
|
def solo(self, val: bool):
|
||||||
if not isinstance(val, bool) and val not in (0, 1):
|
|
||||||
raise VMError("solo is a boolean parameter")
|
|
||||||
self.setter("solo", 1 if val else 0)
|
self.setter("solo", 1 if val else 0)
|
||||||
|
|
||||||
@property
|
@property
|
||||||
@ -50,8 +46,6 @@ class Strip(IRemote):
|
|||||||
|
|
||||||
@mute.setter
|
@mute.setter
|
||||||
def mute(self, val: bool):
|
def mute(self, val: bool):
|
||||||
if not isinstance(val, bool) and val not in (0, 1):
|
|
||||||
raise VMError("mute is a boolean parameter")
|
|
||||||
self.setter("mute", 1 if val else 0)
|
self.setter("mute", 1 if val else 0)
|
||||||
|
|
||||||
@property
|
@property
|
||||||
@ -68,9 +62,7 @@ class Strip(IRemote):
|
|||||||
|
|
||||||
@label.setter
|
@label.setter
|
||||||
def label(self, val: str):
|
def label(self, val: str):
|
||||||
if not isinstance(val, str):
|
self.setter("Label", str(val))
|
||||||
raise VMError("label is a string parameter")
|
|
||||||
self.setter("Label", val)
|
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def gain(self) -> float:
|
def gain(self) -> float:
|
||||||
@ -136,8 +128,6 @@ class VirtualStrip(Strip):
|
|||||||
|
|
||||||
@mc.setter
|
@mc.setter
|
||||||
def mc(self, val: bool):
|
def mc(self, val: bool):
|
||||||
if not isinstance(val, bool) and val not in (0, 1):
|
|
||||||
raise VMError("mc is a boolean parameter")
|
|
||||||
self.setter("mc", 1 if val else 0)
|
self.setter("mc", 1 if val else 0)
|
||||||
|
|
||||||
mono = mc
|
mono = mc
|
||||||
@ -180,8 +170,6 @@ class VirtualStrip(Strip):
|
|||||||
self.setter("AppGain", f'("{name}", {gain})')
|
self.setter("AppGain", f'("{name}", {gain})')
|
||||||
|
|
||||||
def appmute(self, name: str, mute: bool = None):
|
def appmute(self, name: str, mute: bool = None):
|
||||||
if not isinstance(mute, bool) and mute not in (0, 1):
|
|
||||||
raise VMError("appmute is a boolean parameter")
|
|
||||||
self.setter("AppMute", f'("{name}", {1 if mute else 0})')
|
self.setter("AppMute", f'("{name}", {1 if mute else 0})')
|
||||||
|
|
||||||
|
|
||||||
|
@ -25,8 +25,6 @@ class VbanStream(IRemote):
|
|||||||
|
|
||||||
@on.setter
|
@on.setter
|
||||||
def on(self, val: bool):
|
def on(self, val: bool):
|
||||||
if not isinstance(val, bool) and val not in (0, 1):
|
|
||||||
raise VMError("True or False expected")
|
|
||||||
self.setter("on", 1 if val else 0)
|
self.setter("on", 1 if val else 0)
|
||||||
|
|
||||||
@property
|
@property
|
||||||
|
Loading…
Reference in New Issue
Block a user