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]
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" }

View File

@ -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)

View File

@ -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"""