summaryrefslogtreecommitdiffstats
path: root/Tools/scripts/db2pickle.py
diff options
context:
space:
mode:
authorSkip Montanaro <skip@pobox.com>2003-10-28 16:17:54 (GMT)
committerSkip Montanaro <skip@pobox.com>2003-10-28 16:17:54 (GMT)
commit48f9c6dfb899401157f394bdcc0432eac2dbafd3 (patch)
treef8f1df8542a87527b6ba5f709efdb229ea0b148f /Tools/scripts/db2pickle.py
parent9c8f7eafcad308792478c2636dff8fe9110e0d77 (diff)
downloadcpython-48f9c6dfb899401157f394bdcc0432eac2dbafd3.zip
cpython-48f9c6dfb899401157f394bdcc0432eac2dbafd3.tar.gz
cpython-48f9c6dfb899401157f394bdcc0432eac2dbafd3.tar.bz2
allow dump/load of gdbm files
Diffstat (limited to 'Tools/scripts/db2pickle.py')
-rw-r--r--Tools/scripts/db2pickle.py17
1 files changed, 14 insertions, 3 deletions
diff --git a/Tools/scripts/db2pickle.py b/Tools/scripts/db2pickle.py
index 492c1d7..7b0857c 100644
--- a/Tools/scripts/db2pickle.py
+++ b/Tools/scripts/db2pickle.py
@@ -1,7 +1,7 @@
#!/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,
@@ -21,6 +21,10 @@ try:
except ImportError:
dbm = None
try:
+ import gdbm
+except ImportError:
+ gdbm = None
+try:
import anydbm
except ImportError:
anydbm = None
@@ -37,8 +41,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",
+ "gdbm", "anydbm"])
except getopt.error:
usage()
return 1
@@ -83,6 +88,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