Skip to content

Commit b6a4a18

Browse files
Fix for Enumeration, and Nested Extension Object import (#1907)
* fixed localizedText regex and added missing emum datatype * fixed enum resolution when actual numbers are passed * change if check because of ruff * reverted Localized Text * fixes nested extension object error with wrong datatype resolve
1 parent c5535cc commit b6a4a18

File tree

3 files changed

+11
-2
lines changed

3 files changed

+11
-2
lines changed

asyncua/common/ua_utils.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -133,7 +133,10 @@ def string_to_val(string, vtype):
133133
elif vtype == ua.VariantType.Guid:
134134
val = uuid.UUID(string)
135135
elif issubclass(vtype, Enum):
136-
enum_int = int(string.rsplit("_", 1)[1])
136+
if string.isdigit():
137+
enum_int = int(string)
138+
else:
139+
enum_int = int(string.rsplit("_", 1)[1])
137140
val = vtype(enum_int)
138141
else:
139142
# FIXME: Some types are probably missing!

asyncua/common/xmlimporter.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -548,7 +548,9 @@ def _set_attr(self, atttype, fargs, attname: str, val):
548548
for attname2, v2 in val:
549549
if attname2 != "EncodingMask":
550550
# Skip Encoding Mask used for optional types
551-
sub_atttype = self._get_val_type(atttype, attname2)
551+
resolved_sub_type = get_type_hints(atttype, {"ua": ua})
552+
sub_atttype = resolved_sub_type[attname2]
553+
# sub_atttype = self._get_val_type(atttype, attname2)
552554
self._set_attr(sub_atttype, subargs, attname2, v2)
553555
subargs.pop("Encoding", None)
554556
fargs[attname] = atttype(**subargs) # type: ignore[operator]

asyncua/ua/uatypes.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -192,6 +192,10 @@ class DateTime(datetime):
192192
class Guid(uuid.UUID):
193193
pass
194194

195+
class Enumeration(IntEnum):
196+
pass
197+
198+
195199

196200
_microsecond = timedelta(microseconds=1)
197201

0 commit comments

Comments
 (0)