Beispiel #1
0
 def add_node(self):
   """Add a new node.
   Return:
   A new MpaDataNode instance
   """
   new_node = MapDataNode(None, None, None, None, None, False, parent=self)
   self.nodes.append(new_node.key())
   return new_node
Beispiel #2
0
 def del_node(self, key='', node=None):
   """Delete a node.
   Args:
   key: key
   node: node
   Return:
   True for success, False for fail.
   """
   if node:
     key = node.key()
   if key == '' or key not in self.nodes:
     return False
   self.nodes.pop(self.nodes.index(key))
   if node:
     target = node
   else:
     target = MapDataNode.get(key)
   target.del_all_connect()
   target.delete()
   return True