示例#1
0
文件: ui.py 项目: pboyd/passwdr
    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))
示例#2
0
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