fixes regression in apply()

patch bump
This commit is contained in:
onyx-and-iris 2026-03-02 23:52:06 +00:00
parent 7b3340042c
commit 55b3125e10
3 changed files with 11 additions and 17 deletions

View File

@ -1,6 +1,6 @@
[project] [project]
name = "vban-cmd" name = "vban-cmd"
version = "2.9.1" version = "2.9.2"
description = "Python interface for the VBAN RT Packet Service (Sendtext)" description = "Python interface for the VBAN RT Packet Service (Sendtext)"
authors = [{ name = "Onyx and Iris", email = "code@onyxandiris.online" }] authors = [{ name = "Onyx and Iris", email = "code@onyxandiris.online" }]
license = { text = "MIT" } license = { text = "MIT" }

View File

@ -1,6 +1,5 @@
import abc import abc
import logging import logging
import time
from dataclasses import dataclass from dataclasses import dataclass
logger = logging.getLogger(__name__) logger = logging.getLogger(__name__)
@ -123,6 +122,8 @@ class IRemote(abc.ABC):
def apply(self, data): def apply(self, data):
"""Sets all parameters of a dict for the channel.""" """Sets all parameters of a dict for the channel."""
script = ''
def fget(attr, val): def fget(attr, val):
if attr == 'mode': if attr == 'mode':
return (f'mode.{val}', 1) return (f'mode.{val}', 1)
@ -138,14 +139,9 @@ class IRemote(abc.ABC):
val = 1 if val else 0 val = 1 if val else 0
self._remote.cache[self._cmd(attr)] = val self._remote.cache[self._cmd(attr)] = val
self._remote._script += f'{self._cmd(attr)}={val};' script += f'{self._cmd(attr)}={val};'
else: else:
target = getattr(self, attr) target = getattr(self, attr)
target.apply(val) target.apply(val)
self._remote.sendtext(self._remote._script) self._remote.sendtext(script)
return self
def then_wait(self):
self._remote._script = str()
time.sleep(self._remote.DELAY)

View File

@ -5,7 +5,7 @@ import threading
import time import time
from pathlib import Path from pathlib import Path
from queue import Queue from queue import Queue
from typing import Union from typing import Mapping, Union
from .enums import NBS from .enums import NBS
from .error import VBANCMDConnectionError, VBANCMDError from .error import VBANCMDConnectionError, VBANCMDError
@ -289,12 +289,8 @@ class VbanCmd(abc.ABC):
while self.pdirty: while self.pdirty:
time.sleep(self.DELAY) time.sleep(self.DELAY)
def apply(self, data: dict): def apply(self, data: Mapping):
""" """Set all parameters of a dict"""
Sets all parameters of a dict
minor delay between each recursion
"""
def target(key): def target(key):
match key.split('-'): match key.split('-'):
@ -314,7 +310,9 @@ class VbanCmd(abc.ABC):
raise ValueError(ERR_MSG) raise ValueError(ERR_MSG)
return target[int(index)] 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): def apply_config(self, name):
"""applies a config from memory""" """applies a config from memory"""