def do_new(self, arg): try: username = self.get_username() password = self.get_password() url = self.get_url() notes = self.get_notes() node = Node(username, password, url, notes) tags = self.get_tags() node.set_tags(tags) self._db.addnodes([node]) print "Password ID: %d" % (node.get_id()) except Exception, e: self.error(e)
def import_data(self, db, file): tree = ET.parse(file) root = tree.getroot() nodes = root.findall("Node") nodesarray = [] for n in nodes: username = n.findtext("username") password = n.findtext("password") url = n.findtext("url") notes = n.findtext("notes") node = Node(username, password, url, notes) tagnames = n.find("tags").findall("name") tags = [] for t in tagnames: tags.append(Tag(t.text)) node.set_tags(tags) nodesarray.append(node) db.addnodes(nodesarray)
def parse_list(self, db, list): lists = list.findall("PwList") for l in lists: name = l.get("name").lower().replace(' ', '') self.tagstack.append(name) self.parse_list(db, l) self.tagstack.pop() items = list.findall("PwItem") tags = [] for t in self.tagstack: tags.append(Tag(t)) for i in items: username = i.findtext("user") password = i.findtext("passwd") url = i.findtext("host") notes = "%s | %s" % (i.findtext("name"), i.findtext("launch")) n = Node(username, password, url, notes) n.set_tags(tags) self.nodes.append(n)
def do_new(self, args): """ can override default config settings the following way: Pwman3 0.2.1 (c) visit: http://github.com/pwman3/pwman3 pwman> n {'leetify':False, 'numerics':True, 'special_chars':True} Password (Blank to generate): """ errmsg = ( """could not parse config override, please input some""" + """ kind of dictionary, e.g.: n {'leetify':False, """ + """'numerics':True, 'special_chars':True}""" ) try: username = self.get_username() if args: try: args = ast.literal_eval(args) except Exception: raise Exception(errmsg) if not isinstance(args, dict): raise Exception(errmsg) password = self.get_password(1, **args) else: numerics = config.get_value("Generator", "numerics").lower() == "true" # TODO: allow custom leetifying through the config leetify = config.get_value("Generator", "leetify").lower() == "true" special_chars = config.get_value("Generator", "special_chars").lower() == "true" password = self.get_password(0, numerics=numerics, symbols=leetify, special_signs=special_chars) url = self.get_url() notes = self.get_notes() node = Node(username, password, url, notes) tags = self.get_tags() node.set_tags(tags) self._db.addnodes([node]) print "Password ID: %d" % (node.get_id()) except Exception, e: self.error(e)