def _command_add(self, args): if len(args.args) < 3: print "usage: add account_key username password [note]" return account = Account(args.args[0], args.key) account.setUsername(args.args[1]) account.setPassword(args.args[2]) if len(args.args) > 3: account.setNote(args.args[3]) kernel.queue(events.NewAccount(account))
def readfp(fp, encryption_key=None): config = SafeConfigParser() config.readfp(fp) accounts = [] for key in config.sections(): acct = Account(key, encryption_key) if config.has_option(key, 'username'): acct.setUsername(config.get(key, 'username')) if config.has_option(key, 'password'): acct.setEncryptedPassword(config.get(key, 'password')) if config.has_option(key, 'note'): acct.setNote(config.get(key, 'note')) accounts.append(acct) return accounts