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

Function from_binary

opcua/ua/ua_binary.py:469–486  ·  view source on GitHub ↗

unpack data given an uatype as a string or a python class having a ua_types memeber

(uatype, data)

Source from the content-addressed store, hash-verified

467
468
469def from_binary(uatype, data):
470 """
471 unpack data given an uatype as a string or a python class having a ua_types memeber
472 """
473 if isinstance(uatype, (str, unicode)) and uatype.startswith("ListOf"):
474 utype = uatype[6:]
475 if hasattr(ua.VariantType, utype):
476 vtype = getattr(ua.VariantType, utype)
477 return unpack_uatype_array(vtype, data)
478 size = Primitives.Int32.unpack(data)
479 return [from_binary(utype, data) for _ in range(size)]
480 elif isinstance(uatype, (str, unicode)) and hasattr(ua.VariantType, uatype):
481 vtype = getattr(ua.VariantType, uatype)
482 return unpack_uatype(vtype, data)
483 elif isinstance(uatype, (str, unicode)) and hasattr(Primitives, uatype):
484 return getattr(Primitives, uatype).unpack(data)
485 else:
486 return struct_from_binary(uatype, data)
487
488
489def struct_from_binary(objtype, data):

Callers 2

struct_from_binaryFunction · 0.85

Calls 4

unpack_uatype_arrayFunction · 0.85
unpack_uatypeFunction · 0.85
struct_from_binaryFunction · 0.85
unpackMethod · 0.45

Tested by

no test coverage detected