vban-cmd-python/vban_cmd/command.py

47 lines
1.1 KiB
Python
Raw Normal View History

from .iremote import IRemote
2023-06-25 02:38:59 +01:00
from .meta import action_fn
class Command(IRemote):
"""
Implements the common interface
Defines concrete implementation for command
"""
@classmethod
def make(cls, remote):
"""
Factory function for command class.
Returns a Command class of a kind.
"""
CMD_cls = type(
f"Command{remote.kind}",
(cls,),
{
**{
2023-06-25 02:38:59 +01:00
param: action_fn(param) for param in ["show", "shutdown", "restart"]
},
2023-06-25 02:38:59 +01:00
"hide": action_fn("show", val=0),
},
)
return CMD_cls(remote)
@property
def identifier(self) -> str:
return "Command"
def set_showvbanchat(self, val: bool):
self.setter("DialogShow.VBANCHAT", 1 if val else 0)
showvbanchat = property(fset=set_showvbanchat)
def set_lock(self, val: bool):
self.setter("lock", 1 if val else 0)
lock = property(fset=set_lock)
def reset(self):
self._remote.apply_config("reset")