def rsr_nodes(self, sa, *args): "Print existing nodes. " nodes = [] for arg in args: typehint, nodeid = self.deref(arg, sa) # do something with typehint? node = Node.find(( Node.name == nodeid, )) if not node: log.warn("No entry for %s:%s", typehint, nodeid) continue print(node.ntype, node.name) nodes.append(node) yield dict(nodes=nodes)
def rsr_show(self, ref_or_node, sa ): "Print a single node from name or path reference. " if isinstance( ref_or_node, str ): nodetype, localpart = self.deref(ref_or_node, sa) node = Node.find(( Node.name == localpart, )) print(node)
def rsr_remove(self, ref, sa, opts): "Remove a node" node = Node.find(( Node.name == ref, )) sa.delete( node ) if opts.rsr_auto_commit: sa.commit()