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
|
||||
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)
|
||||
|
||||
@property
|
||||
@ -39,8 +37,6 @@ class Bus(IRemote):
|
||||
|
||||
@mono.setter
|
||||
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)
|
||||
|
||||
@property
|
||||
@ -49,8 +45,6 @@ class Bus(IRemote):
|
||||
|
||||
@eq.setter
|
||||
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)
|
||||
|
||||
@property
|
||||
@ -59,8 +53,6 @@ class Bus(IRemote):
|
||||
|
||||
@eq_ab.setter
|
||||
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)
|
||||
|
||||
@property
|
||||
@ -69,8 +61,6 @@ class Bus(IRemote):
|
||||
|
||||
@sel.setter
|
||||
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)
|
||||
|
||||
@property
|
||||
@ -79,9 +69,7 @@ class Bus(IRemote):
|
||||
|
||||
@label.setter
|
||||
def label(self, val: str):
|
||||
if not isinstance(val, str):
|
||||
raise VMError("label is a string parameter")
|
||||
self.setter("Label", val)
|
||||
self.setter("Label", str(val))
|
||||
|
||||
@property
|
||||
def gain(self) -> float:
|
||||
|
@ -38,15 +38,11 @@ class Command(IRemote):
|
||||
return "Command"
|
||||
|
||||
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)
|
||||
|
||||
showvbanchat = property(fset=set_showvbanchat)
|
||||
|
||||
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)
|
||||
|
||||
lock = property(fset=set_lock)
|
||||
|
@ -27,8 +27,6 @@ class MacroButton(Adapter):
|
||||
|
||||
@state.setter
|
||||
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)
|
||||
|
||||
@property
|
||||
@ -37,8 +35,6 @@ class MacroButton(Adapter):
|
||||
|
||||
@stateonly.setter
|
||||
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)
|
||||
|
||||
@property
|
||||
@ -47,6 +43,4 @@ class MacroButton(Adapter):
|
||||
|
||||
@trigger.setter
|
||||
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)
|
||||
|
@ -8,8 +8,6 @@ def bool_prop(param):
|
||||
return self.getter(param) == 1
|
||||
|
||||
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)
|
||||
|
||||
return property(fget, fset)
|
||||
@ -44,8 +42,6 @@ def bus_mode_prop(param):
|
||||
return self.getter(param) == 1
|
||||
|
||||
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)
|
||||
|
||||
return property(fget, fset)
|
||||
|
@ -53,8 +53,6 @@ class Recorder(IRemote):
|
||||
raise VMError("File full directory must be a raw string")
|
||||
|
||||
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)
|
||||
|
||||
loop = property(fset=set_loop)
|
||||
|
@ -30,8 +30,6 @@ class Strip(IRemote):
|
||||
|
||||
@mono.setter
|
||||
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)
|
||||
|
||||
@property
|
||||
@ -40,8 +38,6 @@ class Strip(IRemote):
|
||||
|
||||
@solo.setter
|
||||
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)
|
||||
|
||||
@property
|
||||
@ -50,8 +46,6 @@ class Strip(IRemote):
|
||||
|
||||
@mute.setter
|
||||
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)
|
||||
|
||||
@property
|
||||
@ -68,9 +62,7 @@ class Strip(IRemote):
|
||||
|
||||
@label.setter
|
||||
def label(self, val: str):
|
||||
if not isinstance(val, str):
|
||||
raise VMError("label is a string parameter")
|
||||
self.setter("Label", val)
|
||||
self.setter("Label", str(val))
|
||||
|
||||
@property
|
||||
def gain(self) -> float:
|
||||
@ -136,8 +128,6 @@ class VirtualStrip(Strip):
|
||||
|
||||
@mc.setter
|
||||
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)
|
||||
|
||||
mono = mc
|
||||
@ -180,8 +170,6 @@ class VirtualStrip(Strip):
|
||||
self.setter("AppGain", f'("{name}", {gain})')
|
||||
|
||||
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})')
|
||||
|
||||
|
||||
|
@ -25,8 +25,6 @@ class VbanStream(IRemote):
|
||||
|
||||
@on.setter
|
||||
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)
|
||||
|
||||
@property
|
||||
|
Loading…
Reference in New Issue
Block a user