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

Function split_requests

schemas/generate_model.py:259–302  ·  view source on GitHub ↗
(model)

Source from the content-addressed store, hash-verified

257# obj.fields = [el for el in obj.fields if el.name not in ("TypeId", "Body", "Encoding")]
258
259def split_requests(model):
260 structs = []
261 for struct in model.structs:
262 structtype = None
263 if struct.name.endswith('Request') and not struct.name in NotRequest:
264 structtype = 'Request'
265 elif struct.name.endswith('Response') or struct.name == 'ServiceFault':
266 structtype = 'Response'
267 if structtype:
268 # for field in struct.fields:
269 # if field.name == "Encoding":
270 # struct.fields.remove(field)
271 # break
272 # for field in struct.fields:
273 # if field.name == "BodyLength":
274 # struct.fields.remove(field)
275 # break
276 struct.needconstructor = True
277 field = Field()
278 field.name = 'TypeId'
279 field.uatype = 'NodeId'
280 struct.fields.insert(0, field)
281
282 if structtype and not struct.name in NoSplitStruct:
283 paramstruct = Struct()
284 if structtype == 'Request':
285 basename = struct.name.replace('Request', '') + 'Parameters'
286 paramstruct.name = basename
287 else:
288 basename = struct.name.replace('Response', '') + 'Result'
289 paramstruct.name = basename
290 paramstruct.fields = struct.fields[2:]
291 paramstruct.bits = struct.bits
292
293 struct.fields = struct.fields[:2]
294 # struct.bits = {}
295 structs.append(paramstruct)
296
297 typeid = Field()
298 typeid.name = "Parameters"
299 typeid.uatype = paramstruct.name
300 struct.fields.append(typeid)
301 structs.append(struct)
302 model.structs = structs
303
304
305class Parser(object):

Callers

nothing calls this directly

Calls 2

FieldClass · 0.70
StructClass · 0.70

Tested by

no test coverage detected