mirror of
https://github.com/FreeOpcUa/opcua-asyncio
synced 2025-10-29 17:07:18 +08:00
Added functionality for importing and parsing ListOfLocalizedText with both Text and Locale.
This commit is contained in:
parent
ffc7d40fb0
commit
45d55f01a4
|
|
@ -291,6 +291,8 @@ class XmlImporter:
|
|||
vtype = obj.valuetype[6:]
|
||||
if hasattr(ua.ua_binary.Primitives, vtype):
|
||||
return ua.Variant(obj.value, getattr(ua.VariantType, vtype))
|
||||
elif vtype == "LocalizedText":
|
||||
return ua.Variant([getattr(ua, vtype)(text=item["Text"],locale=item["Locale"]) for item in obj.value])
|
||||
else:
|
||||
return ua.Variant([getattr(ua, vtype)(v) for v in obj.value])
|
||||
elif obj.valuetype == 'ExtensionObject':
|
||||
|
|
@ -303,6 +305,8 @@ class XmlImporter:
|
|||
for name, val in obj.value:
|
||||
if name == "Text":
|
||||
ltext.Text = val
|
||||
elif name == "Locale":
|
||||
ltext.Locale = val
|
||||
else:
|
||||
self.logger.warning("While parsing localizedText value, unkown element: %s with val: %s", name, val)
|
||||
return ua.Variant(ltext, ua.VariantType.LocalizedText)
|
||||
|
|
|
|||
|
|
@ -297,10 +297,12 @@ class XMLParser:
|
|||
value = []
|
||||
for localized_text in el:
|
||||
mylist = self._parse_body(localized_text)
|
||||
# small hack since we did not handle LocalizedText as ExtensionObject at begynning
|
||||
# each localized text is in a dictionary with "Locale" and "Text" keys
|
||||
item = {"Text":None,"Locale":None}
|
||||
for name, val in mylist:
|
||||
if name == "Text":
|
||||
value.append(val)
|
||||
item.update({str(name):val})
|
||||
# value is an array of dictionaries with localized texts
|
||||
value.append(item)
|
||||
return value
|
||||
|
||||
def _parse_list_of_extension_object(self, el):
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user