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

Function nodeid_code

schemas/generate_address_space.py:50–83  ·  view source on GitHub ↗
(string)

Source from the content-addressed store, hash-verified

48
49
50def nodeid_code(string):
51 l = string.split(";")
52 identifier = None
53 namespace = 0
54 ntype = None
55 srv = None
56 nsu = None
57 for el in l:
58 if not el:
59 continue
60 k, v = el.split("=", 1)
61 k = k.strip()
62 v = v.strip()
63 if k == "ns":
64 namespace = v
65 elif k == "i":
66 ntype = "NumericNodeId"
67 identifier = v
68 elif k == "s":
69 ntype = "StringNodeId"
70 identifier = f"'{v}'"
71 elif k == "g":
72 ntype = "GuidNodeId"
73 identifier = f"b'{v}'"
74 elif k == "b":
75 ntype = "ByteStringNodeId"
76 identifier = f"b'{v}'"
77 elif k == "srv":
78 srv = v
79 elif k == "nsu":
80 nsu = v
81 if identifier is None:
82 raise Exception("Could not find identifier in string: " + string)
83 return f"{ntype}({identifier}, {namespace})"
84
85
86class CodeGenerator:

Callers 5

make_node_codeMethod · 0.85
to_data_typeMethod · 0.85
to_ref_typeMethod · 0.85
make_ext_obj_codeMethod · 0.85
make_refs_codeMethod · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected