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

Function get_default_value

opcua/common/structures.py:25–45  ·  view source on GitHub ↗
(uatype, enums)

Source from the content-addressed store, hash-verified

23
24
25def get_default_value(uatype, enums):
26 if uatype == "String":
27 return "None"
28 elif uatype == "Guid":
29 return "uuid.uuid4()"
30 elif uatype in ("ByteString", "CharArray", "Char"):
31 return "b''"
32 elif uatype == "Boolean":
33 return "True"
34 elif uatype == "DateTime":
35 return "datetime.utcnow()"
36 elif uatype in ("Int16", "Int32", "Int64", "UInt16", "UInt32", "UInt64", "Double", "Float", "Byte", "SByte"):
37 return 0
38 elif uatype in enums:
39 return "ua." + uatype + "(" + enums[uatype] + ")"
40 elif hasattr(ua, uatype) and issubclass(getattr(ua, uatype), Enum):
41 # We have an enum, try to initilize it correctly
42 val = list(getattr(ua, uatype).__members__)[0]
43 return "ua.{}.{}".format(uatype, val)
44 else:
45 return "ua.{}()".format(uatype)
46
47
48class EnumType(object):

Callers 1

_make_modelMethod · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected