From 18f59b4eb28b3d825e899f2e7c93a07268d874c5 Mon Sep 17 00:00:00 2001 From: onyx-and-iris <75868496+onyx-and-iris@users.noreply.github.com> Date: Mon, 21 Mar 2022 16:41:27 +0000 Subject: [PATCH] Update dataclass.py add check for empty labels --- vbancmd/dataclass.py | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/vbancmd/dataclass.py b/vbancmd/dataclass.py index 2e0b733..e9456b8 100644 --- a/vbancmd/dataclass.py +++ b/vbancmd/dataclass.py @@ -108,12 +108,20 @@ class VBAN_VMRT_Packet_Data: return tuple(((1 << 16) - 1) - int.from_bytes(self._busGaindB100[i:i+2], 'little') for i in range(0, 16, 2)) @property def striplabels(self) -> tuple: - """ returns tuple of strip labels """ - return tuple(self._stripLabelUTF8c60[i:i+60].decode().strip('\x00') for i in range(0, 480, 60)) + """ returns list of strip labels """ + labels = list(self._stripLabelUTF8c60[i:i+60].decode().rstrip('\x00') for i in range(0, 480, 60)) + for i, label in enumerate(labels): + if label != label.lstrip('\x00'): + labels[i] = None + return labels @property def buslabels(self) -> tuple: - """ returns tuple of bus labels """ - return tuple(self._busLabelUTF8c60[i:i+60].decode().strip('\x00') for i in range(0, 480, 60)) + """ returns list of bus labels """ + labels = list(self._busLabelUTF8c60[i:i+60].decode().rstrip('\x00') for i in range(0, 480, 60)) + for i, label in enumerate(labels): + if label != label.lstrip('\x00'): + labels[i] = None + return labels @dataclass class VBAN_VMRT_Packet_Header: