MCPcopy Create free account
hub / github.com/FreeOpcUa/python-opcua / load_enums

Function load_enums

opcua/common/structures.py:333–353  ·  view source on GitHub ↗

Read enumeration data types on server and generate python Enums in ua scope for them

(server, env=None)

Source from the content-addressed store, hash-verified

331
332
333def load_enums(server, env=None):
334 """
335 Read enumeration data types on server and generate python Enums in ua scope for them
336 """
337 model = []
338 nodes = server.nodes.enum_data_type.get_children()
339 if env is None:
340 env = ua.__dict__
341 for node in nodes:
342 name = node.get_browse_name().Name
343 try:
344 c = _get_enum_strings(name, node)
345 except ua.UaError as ex:
346 try:
347 c = _get_enum_values(name, node)
348 except ua.UaError as ex:
349 logger.info("Node %s, %s under DataTypes/Enumeration, does not seem to have a child called EnumString or EumValue: %s", name, node, ex)
350 continue
351 if not hasattr(ua, c.name):
352 model.append(c)
353 return _generate_python_class(model, env=env)
354
355
356def _get_enum_values(name, node):

Callers 2

load_enumsMethod · 0.90
load_enumsMethod · 0.90

Calls 5

_get_enum_stringsFunction · 0.85
_get_enum_valuesFunction · 0.85
_generate_python_classFunction · 0.85
get_childrenMethod · 0.80
get_browse_nameMethod · 0.80

Tested by

no test coverage detected