From a7a846dfbafa2256469884a02f6ea250f91c86c3 Mon Sep 17 00:00:00 2001 From: Markus Zolliker Date: Tue, 10 Dec 2024 16:29:07 +0100 Subject: [PATCH] frappy_psi.sea: fix case when bool is implemented as text introduce SeaBool for this Change-Id: I9c6b6ee7d33f11b173d612efc044fce8a563f626 --- frappy_psi/sea.py | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/frappy_psi/sea.py b/frappy_psi/sea.py index efd3a6b..2ef8ee5 100644 --- a/frappy_psi/sea.py +++ b/frappy_psi/sea.py @@ -419,11 +419,24 @@ class SeaConfigCreator(SeaClient): return reply +class SeaBool(BoolType): + """some sea enum nodes used as boolean have text type -> accept '' also""" + def copy(self): + return SeaBool() + + def __call__(self, value): + try: + value = int(value) + return super().__call__(value) + except Exception as e: + raise ReadFailedError(e) from e + + SEA_TO_SECOPTYPE = { 'float': FloatRange(), 'text': StringType(), 'int': IntRange(-1 << 63, 1 << 63 - 1), - 'bool': BoolType(), + 'bool': SeaBool(), 'none': None, 'floatvarar': ArrayOf(FloatRange(), 0, 400), # 400 is the current limit for proper notify events in SEA }