aboutsummaryrefslogtreecommitdiffstats
path: root/bin/dumpdb
diff options
context:
space:
mode:
authorMark Sapiro <msapiro@value.net>2007-08-03 17:46:05 -0700
committerMark Sapiro <msapiro@value.net>2007-08-03 17:46:05 -0700
commite88e32b83cfa293e1b25f082fc8b44eeb4cf754d (patch)
tree1a194c3970b193139b9dbe8be9bbe4882a1a6560 /bin/dumpdb
parent9c3b3a39505b01e74eb013958355c81192f41b45 (diff)
downloadmailman2-e88e32b83cfa293e1b25f082fc8b44eeb4cf754d.tar.gz
mailman2-e88e32b83cfa293e1b25f082fc8b44eeb4cf754d.tar.xz
mailman2-e88e32b83cfa293e1b25f082fc8b44eeb4cf754d.zip
Backported dumpdb changes from the 3.0 branch to allow dumping of marshals.
This has been broken since 2.1.5!
Diffstat (limited to '')
-rw-r--r--bin/dumpdb63
1 files changed, 30 insertions, 33 deletions
diff --git a/bin/dumpdb b/bin/dumpdb
index 0bde09b8..28aadff0 100644
--- a/bin/dumpdb
+++ b/bin/dumpdb
@@ -1,4 +1,4 @@
-#! @PYTHON@
+#! /usr/bin/python
#
# Copyright (C) 1998-2005 by the Free Software Foundation, Inc.
#
@@ -45,16 +45,15 @@ Python pickle. In either case, if you want to override the default assumption
-- or if the file ends in neither suffix -- use the -p or -m flags.
"""
-import os
import sys
import getopt
import pprint
-from cPickle import load
+import cPickle
+import marshal
from types import StringType
import paths
# Import this /after/ paths so that the sys.path is properly hacked
-from email.Generator import Generator
from Mailman.i18n import _
PROGRAM = sys.argv[0]
@@ -121,37 +120,35 @@ def main():
# Handle dbs
pp = pprint.PrettyPrinter(indent=4)
if filetype == 1:
- # BAW: this probably doesn't work if there are mixed types of .db
- # files (i.e. some marshals, some bdbs).
- d = DumperSwitchboard().read(filename)
- if doprint:
- pp.pprint(d)
- return d
+ load = marshal.load
+ typename = 'marshal'
else:
- fp = open(filename)
- m = []
- try:
- cnt = 1
- if doprint:
- print _('[----- start pickle file -----]')
- while True:
- try:
- obj = load(fp)
- except EOFError:
- if doprint:
- print _('[----- end pickle file -----]')
- break
+ load = cPickle.load
+ typename = 'pickle'
+ fp = open(filename)
+ m = []
+ try:
+ cnt = 1
+ if doprint:
+ print _('[----- start %(typename)s file -----]')
+ while True:
+ try:
+ obj = load(fp)
+ except EOFError:
if doprint:
- print _('<----- start object %(cnt)s ----->')
- if isinstance(obj, StringType):
- print obj
- else:
- pp.pprint(obj)
- cnt += 1
- m.append(obj)
- finally:
- fp.close()
- return m
+ print _('[----- end %(typename)s file -----]')
+ break
+ if doprint:
+ print _('<----- start object %(cnt)s ----->')
+ if isinstance(obj, StringType):
+ print obj
+ else:
+ pp.pprint(obj)
+ cnt += 1
+ m.append(obj)
+ finally:
+ fp.close()
+ return m