From 5a456a82b086f6162eca782ff5df2435b6dd495a Mon Sep 17 00:00:00 2001 From: Markus Zolliker Date: Mon, 5 Jun 2023 13:55:34 +0200 Subject: [PATCH] fix enum when SEA type is text Change-Id: I873045a2dac8771b844431ccda70ce1b8ff1aee5 --- 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 2d98f92..0fc78e0 100644 --- a/frappy_psi/sea.py +++ b/frappy_psi/sea.py @@ -383,6 +383,19 @@ SEA_TO_SECOPTYPE = { } +class SeaEnum(EnumType): + """some sea enum nodes have text type -> accept '' also""" + def copy(self): + return SeaEnum(self._enum) + + def __call__(self, value): + try: + value = int(value) + except TypeError: + pass + return super().__call__(value) + + def get_datatype(paramdesc): typ = paramdesc['type'] result = SEA_TO_SECOPTYPE.get(typ, False) @@ -390,7 +403,7 @@ def get_datatype(paramdesc): return result # special cases if typ == 'enum': - return EnumType(paramdesc['enum']) + return SeaEnum(paramdesc['enum']) raise ValueError('unknown SEA type %r' % typ)