def get_tags(self, default=None): defaultstr = "" if default: for t in default: defaultstr += "%s " % (t) else: tags = self._db.currenttags() for t in tags: defaultstr += "%s " % (t) strings = [] tags = self._db.listtags(True) for t in tags: # strings.append(t.get_name()) strings.append(t) def complete(text, state): count = 0 for s in strings: if s.startswith(text): if count == state: return s else: count += 1 taglist = tools.getinput("Tags: ", defaultstr, complete) tagstrings = taglist.split() tags = [] for tn in tagstrings: _Tag = Tag(tn) tags.append(_Tag) return tags
def get_tags(self, default=None, reader=raw_input): """read tags from user""" defaultstr = '' if default: for t in default: defaultstr += "%s " % (t) else: # tags = self._db.currenttags() tags = self._db._filtertags for t in tags: defaultstr += "%s " % (t) # strings = [] tags = self._db.listtags(True) # for t in tags: # strings.append(t.get_name()) # strings.append(t) strings = [t for t in tags] def complete(text, state): count = 0 for s in strings: if s.startswith(text): if count == state: return s else: count += 1 taglist = tools.getinput("Tags: ", defaultstr, completer=complete, reader=reader) tagstrings = taglist.split() tags = [TagNew(tn) for tn in tagstrings] return tags
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, args): ids = self._get_ids(args) ans = tools.getinput("Are you sure you want to delete node{} {}" " [y/N]?".format("s" if len(ids) > 1 else "", ",".join(ids) if len(ids) > 1 else ids[0])) # noqa if ans.lower() == 'y': self._do_rm(args)
def _do_rm(self, args): for i in args.split(): if not i.isdigit(): print("%s is not a node ID" % i) return None for i in args.split(): ans = tools.getinput(("Are you sure you want to delete node {}" " [y/N]?".format(i))) if ans.lower() == 'y': self._db.removenodes([i])
def get_password(self, argsgiven, numerics=False, leetify=False, symbols=False, special_signs=False): """ in the config file: numerics -> numerics leetify -> symbols special_chars -> special_signs """ if argsgiven == 1: length = tools.getinput("Password length (default 7): ", "7") length = int(length) password, dumpme = generator.generate_password(length, length, True, leetify, numerics, special_signs) print "New password: %s" % (password) return password # no args given password = tools.getpassword("Password (Blank to generate): ", tools._defaultwidth, False) if len(password) == 0: length = tools.getinput("Password length (default 7): ", "7") length = int(length) (password, dumpme) = generator.generate_password(length, length, True, leetify, numerics, special_signs) print "New password: %s" % (password) return password
def do_delete(self, args): ce = CryptoEngine.get() ce.encrypt("") ids = self._get_ids(args) if not ids: return ans = tools.getinput("Are you sure you want to delete node{} {}" " [y/N]?".format("s" if len(ids) > 1 else "", ",".join(ids) if len(ids) > 1 else ids[0])) # noqa if ans.lower() == 'y': self._do_rm(ids)
def do_delete(self, arg): ids = self.get_ids(arg) try: nodes = self._db.getnodes(ids) for n in nodes: ans = '' while True: ans = tools.getinput(("Are you sure you want to" " delete '%s@%s' ([y/N])?" ) % (n.username, n.url)).lower().strip('\n') if ans == '' or ans == 'y' or ans == 'n': break if ans == 'y': self._db.removenodes([n]) print ("%s@%s deleted" % (n.username, n.url)) except Exception as e: self.error(e)
def do_import(self, arg): try: args = arg.split() if len(args) == 0: types = importer.Importer.types() intype = tools.select("Select filetype:", types) imp = importer.Importer.get(intype) infile = tools.getinput("Select file:") imp.import_data(self._db, infile) else: for i in args: types = importer.Importer.types() intype = tools.select("Select filetype:", types) imp = importer.Importer.get(intype) imp.import_data(self._db, i) except Exception, e: self.error(e)
def get_filesystem_path(self, default=""): return tools.getinput("Enter filename: ", default)
def get_url(self, default=""): return tools.getinput("Url: ", default)
def get_notes(self, default="", reader=raw_input): return tools.getinput("Notes: ", default, reader)
def get_url(self, default="", reader=raw_input): return tools.getinput("Url: ", default, reader)
def get_username(self, default="", reader=raw_input): return tools.getinput("Username: ", default, reader)
def get_notes(self, default=""): return tools.getinput("Notes: ", default)
def get_username(self, default=""): return tools.getinput("Username: ", default)