diff --git a/pyproject.toml b/pyproject.toml index 8bde170..4f4bf23 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,6 +1,6 @@ [project] name = "vban-cmd" -version = "2.9.1" +version = "2.9.2" description = "Python interface for the VBAN RT Packet Service (Sendtext)" authors = [{ name = "Onyx and Iris", email = "code@onyxandiris.online" }] license = { text = "MIT" } diff --git a/vban_cmd/iremote.py b/vban_cmd/iremote.py index 4f30f2a..7a89df9 100644 --- a/vban_cmd/iremote.py +++ b/vban_cmd/iremote.py @@ -1,6 +1,5 @@ import abc import logging -import time from dataclasses import dataclass logger = logging.getLogger(__name__) @@ -123,6 +122,8 @@ class IRemote(abc.ABC): def apply(self, data): """Sets all parameters of a dict for the channel.""" + script = '' + def fget(attr, val): if attr == 'mode': return (f'mode.{val}', 1) @@ -138,14 +139,9 @@ class IRemote(abc.ABC): val = 1 if val else 0 self._remote.cache[self._cmd(attr)] = val - self._remote._script += f'{self._cmd(attr)}={val};' + script += f'{self._cmd(attr)}={val};' else: target = getattr(self, attr) target.apply(val) - self._remote.sendtext(self._remote._script) - return self - - def then_wait(self): - self._remote._script = str() - time.sleep(self._remote.DELAY) + self._remote.sendtext(script) diff --git a/vban_cmd/vbancmd.py b/vban_cmd/vbancmd.py index 470a791..8d204a5 100644 --- a/vban_cmd/vbancmd.py +++ b/vban_cmd/vbancmd.py @@ -5,7 +5,7 @@ import threading import time from pathlib import Path from queue import Queue -from typing import Union +from typing import Mapping, Union from .enums import NBS from .error import VBANCMDConnectionError, VBANCMDError @@ -289,12 +289,8 @@ class VbanCmd(abc.ABC): while self.pdirty: time.sleep(self.DELAY) - def apply(self, data: dict): - """ - Sets all parameters of a dict - - minor delay between each recursion - """ + def apply(self, data: Mapping): + """Set all parameters of a dict""" def target(key): match key.split('-'): @@ -314,7 +310,9 @@ class VbanCmd(abc.ABC): raise ValueError(ERR_MSG) return target[int(index)] - [target(key).apply(di).then_wait() for key, di in data.items()] + for key, di in data.items(): + target(key).apply(di) + time.sleep(self.DELAY) def apply_config(self, name): """applies a config from memory"""