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

Method _get_path

opcua/common/node.py:422–441  ·  view source on GitHub ↗

Attempt to find path of node from root node and return it as a list of Nodes. There might several possible paths to a node, this function will return one Some nodes may be missing references, so this method may return an empty list Since address space may hav

(self, max_length=20)

Source from the content-addressed store, hash-verified

420 return path
421
422 def _get_path(self, max_length=20):
423 """
424 Attempt to find path of node from root node and return it as a list of Nodes.
425 There might several possible paths to a node, this function will return one
426 Some nodes may be missing references, so this method may
427 return an empty list
428 Since address space may have circular references, a max length is specified
429
430 """
431 path = []
432 node = self
433 while True:
434 refs = node.get_references(refs=ua.ObjectIds.HierarchicalReferences, direction=ua.BrowseDirection.Inverse)
435 if len(refs) > 0:
436 path.insert(0, refs[0])
437 node = Node(self.server, refs[0].NodeId)
438 if len(path) >= (max_length -1):
439 return path
440 else:
441 return path
442
443 def get_parent(self):
444 """

Callers 1

get_pathMethod · 0.95

Calls 2

get_referencesMethod · 0.95
NodeClass · 0.85

Tested by

no test coverage detected