diff options
Diffstat (limited to 'Tools/scripts/pickle2db.py')
-rw-r--r-- | Tools/scripts/pickle2db.py | 17 |
1 files changed, 14 insertions, 3 deletions
diff --git a/Tools/scripts/pickle2db.py b/Tools/scripts/pickle2db.py index a35021f..7e699f4 100644 --- a/Tools/scripts/pickle2db.py +++ b/Tools/scripts/pickle2db.py @@ -1,7 +1,7 @@ #!/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 @@ -25,6 +25,10 @@ try: except ImportError: dbm = None try: + import gdbm +except ImportError: + gdbm = None +try: import anydbm except ImportError: anydbm = None @@ -41,8 +45,9 @@ def usage(): 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 @@ -87,6 +92,12 @@ def main(args): 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 |