def do_export(self, arg): try: nodes = self.get_ids(arg) types = exporter.Exporter.types() ftype = tools.select("Select filetype:", types) exp = exporter.Exporter.get(ftype) out_file = tools.getinput("Select output file:") if len(nodes) > 0: b = tools.getyesno("Export nodes %s?" % (nodes), True) if not b: return exp.export_data(self._db, out_file, nodes) else: nodes = self._db.listnodes() tags = self._db.currenttags() tagstr = "" if len(tags) > 0: tagstr = " for " for t in tags: tagstr += "'%s' " % (t.get_name()) b = tools.getyesno("Export all nodes%s?" % (tagstr), True) if not b: return exp.export_data(self._db, out_file, nodes) print "Data exported." except Exception, e: self.error(e)
def do_delete(self, arg): ids = self.get_ids(arg) try: nodes = self._db.getnodes(ids) for n in nodes: b = tools.getyesno("Are you sure you want to delete '%s@%s'?" % (n.get_username(), n.get_url()), False) if b is True: self._db.removenodes([n]) print "%s@%s deleted" % (n.get_username(), n.get_url()) except Exception, e: self.error(e)