def findPath(self, converterPath, paths): ''' @see: IResourcesLocator.findPath ''' assert isinstance(converterPath, ConverterPath), 'Invalid converter path %s' % converterPath if not isinstance(paths, deque): assert isinstance(paths, Iterable), 'Invalid iterable paths %s' % paths paths = deque(paths) assert isinstance(paths, deque), 'Invalid paths %s' % paths if len(paths) == 0: return Path(self, [], self.root) node = self.root matches = [] found = pushMatch(matches, node.tryMatch(converterPath, paths)) while found and len(paths) > 0: found = False for child in node.children: assert isinstance(child, Node) match = child.tryMatch(converterPath, paths) if pushMatch(matches, match): node = child found = True break if len(paths) == 0: return Path(self, matches, node) return Path(self, matches)
def findGetAllAccessible(self, fromPath=None): ''' @see: IResourcesLocator.findGetAllAccessible ''' if fromPath is None: node = self.root else: assert isinstance(fromPath, Path), 'Invalid from path %s' % fromPath node = fromPath.node assert isinstance(node, Node), 'Invalid node %s' % fromPath.node paths = [] for child in node.children: assert isinstance(child, Node) if isinstance(child, NodePath): matches = [] pushMatch(matches, child.newMatch()) if fromPath is None: extended = Path(self, matches, child) else: extended = PathExtended(fromPath, matches, child) if child.get: paths.append(extended) paths.extend(self.findGetAllAccessible(extended)) return paths
def _findGetModel(self, modelType, fromPath, node, index, inPath, matchNodes, exclude=None): ''' Provides the recursive find of a get model based on the path. ''' assert isinstance(modelType, TypeModel), 'Invalid model type %s' % modelType assert isinstance(fromPath, Path), 'Invalid from path %s' % fromPath assert isinstance(node, Node), 'Invalid node %s' % node assert isinstance(matchNodes, deque), 'Invalid match nodes %s' % matchNodes assert exclude is None or isinstance(exclude, Node), 'Invalid exclude node %s' % exclude added = False if isinstance(node, NodePath): assert isinstance(node, NodePath) if not inPath: matchNodes.append(node) added = True if node.name == modelType.container.name: for nodeId in node.children: if isinstance(nodeId, NodeProperty): assert isinstance(nodeId, NodeProperty) if nodeId.get is None: continue assert isinstance(nodeId.get, Invoker) if not nodeId.get.output.isOf(modelType): continue for typ in nodeId.typesProperties: assert isinstance(typ, TypeModelProperty) if typ.parent != modelType: continue matches = [] for matchNode in matchNodes: pushMatch(matches, matchNode.newMatch()) pushMatch(matches, nodeId.newMatch()) return PathExtended(fromPath, matches, nodeId, index) for child in node.children: if child == exclude: continue path = self._findGetModel(modelType, fromPath, child, index, False, matchNodes) if path: return path if added: matchNodes.pop()