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

Method make_ext_obj_code

schemas/generate_address_space.py:228–244  ·  view source on GitHub ↗
(self, indent, extobj)

Source from the content-addressed store, hash-verified

226 self.writecode(indent, f'attrs.ArrayDimensions = {obj.dimensions}')
227
228 def make_ext_obj_code(self, indent, extobj):
229 self.writecode(indent, f'extobj = ua.{extobj.objname}()')
230 for name, val in extobj.body:
231 for k, v in val:
232 if type(v) is str:
233 val = _to_val([extobj.objname], k, v)
234 self.writecode(indent, f'extobj.{k} = {val}')
235 else:
236 if k == "DataType": #hack for strange nodeid xml format
237 self.writecode(indent, 'extobj.{0} = {1}'.format(k, nodeid_code(v[0][1])))
238 continue
239 if k == "ArrayDimensions": # hack for v1.04 - Ignore UInt32 tag?
240 self.writecode(indent, 'extobj.ArrayDimensions = [{0}]'.format(v[0][1]))
241 continue
242 for k2, v2 in v:
243 val2 = _to_val([extobj.objname, k], k2, v2)
244 self.writecode(indent, f'extobj.{k}.{k2} = {val2}')
245
246 def make_variable_code(self, obj):
247 indent = " "

Callers 1

Calls 3

writecodeMethod · 0.95
_to_valFunction · 0.85
nodeid_codeFunction · 0.85

Tested by

no test coverage detected