dict expansion for defaultkwarg

This commit is contained in:
onyx-and-iris 2022-07-28 10:00:24 +01:00
parent 051b5898a2
commit 00a97b1d8b
2 changed files with 19 additions and 16 deletions

View File

@ -12,8 +12,10 @@ class ObsClient(object):
DELAY = 0.001 DELAY = 0.001
def __init__(self, **kwargs): def __init__(self, **kwargs):
defaultkwargs = {key: None for key in ["host", "port", "password"]} defaultkwargs = {
defaultkwargs["subs"] = 0 **{key: None for key in ["host", "port", "password"]},
"subs": 0,
}
kwargs = defaultkwargs | kwargs kwargs = defaultkwargs | kwargs
for attr, val in kwargs.items(): for attr, val in kwargs.items():
setattr(self, attr, val) setattr(self, attr, val)

View File

@ -23,20 +23,21 @@ class EventClient(object):
DELAY = 0.001 DELAY = 0.001
def __init__(self, **kwargs): def __init__(self, **kwargs):
defaultkwargs = dict() defaultkwargs = {
defaultkwargs["subs"] = ( "subs": (
(1 << Subs.general) (1 << Subs.general)
| (1 << Subs.config) | (1 << Subs.config)
| (1 << Subs.scenes) | (1 << Subs.scenes)
| (1 << Subs.inputs) | (1 << Subs.inputs)
| (1 << Subs.transitions) | (1 << Subs.transitions)
| (1 << Subs.filters) | (1 << Subs.filters)
| (1 << Subs.outputs) | (1 << Subs.outputs)
| (1 << Subs.sceneitems) | (1 << Subs.sceneitems)
| (1 << Subs.mediainputs) | (1 << Subs.mediainputs)
| (1 << Subs.vendors) | (1 << Subs.vendors)
| (1 << Subs.ui) | (1 << Subs.ui)
) )
}
kwargs = defaultkwargs | kwargs kwargs = defaultkwargs | kwargs
self.base_client = ObsClient(**kwargs) self.base_client = ObsClient(**kwargs)
self.base_client.authenticate() self.base_client.authenticate()