#!/usr/bin/env python
"""
-Synopsis: %(prog)s [-h|-b|-r] dbfile [ picklefile ]
+Synopsis: %(prog)s [-h|-g|-b|-r|-a] dbfile [ picklefile ]
Convert the database file given on the command line to a pickle
representation. The optional flags indicate the type of the database (hash,
import dbm
except ImportError:
dbm = None
+try:
+ import gdbm
+except ImportError:
+ gdbm = None
try:
import anydbm
except ImportError:
def main(args):
try:
- opts, args = getopt.getopt(args, "hbrda",
- ["hash", "btree", "recno", "dbm", "anydbm"])
+ opts, args = getopt.getopt(args, "hbrdag",
+ ["hash", "btree", "recno", "dbm",
+ "gdbm", "anydbm"])
except getopt.error:
usage()
return 1
except AttributeError:
sys.stderr.write("anydbm module unavailable.\n")
return 1
+ elif opt in ("-g", "--gdbm"):
+ try:
+ dbopen = gdbm.open
+ except AttributeError:
+ sys.stderr.write("gdbm module unavailable.\n")
+ return 1
elif opt in ("-d", "--dbm"):
try:
dbopen = dbm.open
#!/usr/bin/env python
"""
-Synopsis: %(prog)s [-h|-b|-r|-a|-d] dbfile [ picklefile ]
+Synopsis: %(prog)s [-h|-b|-g|-r|-a|-d] dbfile [ picklefile ]
Read the given picklefile as a series of key/value pairs and write to a new
database. If the database already exists, any contents are deleted. The
import dbm
except ImportError:
dbm = None
+try:
+ import gdbm
+except ImportError:
+ gdbm = None
try:
import anydbm
except ImportError:
def main(args):
try:
- opts, args = getopt.getopt(args, "hbrda",
- ["hash", "btree", "recno", "dbm", "anydbm"])
+ opts, args = getopt.getopt(args, "hbrdag",
+ ["hash", "btree", "recno", "dbm", "anydbm",
+ "gdbm"])
except getopt.error:
usage()
return 1
except AttributeError:
sys.stderr.write("anydbm module unavailable.\n")
return 1
+ elif opt in ("-g", "--gdbm"):
+ try:
+ dbopen = gdbm.open
+ except AttributeError:
+ sys.stderr.write("gdbm module unavailable.\n")
+ return 1
elif opt in ("-d", "--dbm"):
try:
dbopen = dbm.open