- pw = PW(file, writep = True)
- tag = av[0]
- try: del pw[tag]
- except KeyError, exc: die("Password `%s' not found." % exc.args[0])
+ with PW(file, writep = True) as pw:
+ tag = _bin(av[0])
+ try: del pw[tag]
+ except KeyError: die("Password `%s' not found" % _excval().args[0])
+
+def cmd_xfer(av):
+
+ ## Parse the command line.
+ try: opts, args = getopt(av, 'd:', ['database='])
+ except GetoptError: return 1
+ dbty = 'flat'
+ for o, a in opts:
+ if o in ('-d', '--database'): dbty = a
+ else: raise Exception("barf")
+ if len(args) != 1: return 1
+ try: dbcls = StorageBackend.byname(dbty)
+ except KeyError: die("Unknown database backend `%s'" % dbty)
+
+ ## Create the target database.
+ with StorageBackend.open(file) as db_in:
+ with dbcls.create(args[0]) as db_out:
+ for k, v in db_in.iter_meta(): db_out.put_meta(k, v)
+ for k, v in db_in.iter_passwds(): db_out.put_passwd(k, v)