------------------------------------------------------------
revno: 986
committer: Mark Sapiro <[EMAIL PROTECTED]>
branch nick: 2.2
timestamp: Fri 2007-08-03 17:44:44 -0700
message:
  Backported dumpdb changes from the 3.0 branch to allow dumping of marshals.
  This has been broken since 2.1.5!
modified:
  bin/dumpdb

=== modified file 'bin/dumpdb'
--- a/bin/dumpdb        2005-08-27 01:40:17 +0000
+++ b/bin/dumpdb        2007-08-04 00:44:44 +0000
@@ -1,4 +1,4 @@
-#! @PYTHON@
+#! /usr/bin/python
 #
 # Copyright (C) 1998-2005 by the Free Software Foundation, Inc.
 #
@@ -45,16 +45,15 @@
 -- 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 @@
     # 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)
+        load = marshal.load
+        typename = 'marshal'
+    else:
+        load = cPickle.load
+        typename = 'pickle'
+    fp = open(filename)
+    m = []
+    try:
+        cnt = 1
         if doprint:
-            pp.pprint(d)
-        return d
-    else:
-        fp = open(filename)
-        m = []
-        try:
-            cnt = 1
+            print _('[----- start %(typename)s file -----]')
+        while True:
+            try:
+                obj = load(fp)
+            except EOFError:
+                if doprint:
+                    print _('[----- end %(typename)s file -----]')
+                break
             if doprint:
-                print _('[----- start pickle file -----]')
-            while True:
-                try:
-                    obj = load(fp)
-                except EOFError:
-                    if doprint:
-                        print _('[----- end pickle 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
+                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
 
 
 



--
(no title)
https://code.launchpad.net/~mailman-coders/mailman/2.2

You are receiving this branch notification because you are subscribed to it.
To unsubscribe from this branch go to 
https://code.launchpad.net/~mailman-coders/mailman/2.2/+subscription/mailman-checkins.
_______________________________________________
Mailman-checkins mailing list
Mailman-checkins@python.org
Unsubscribe: 
http://mail.python.org/mailman/options/mailman-checkins/archive%40jab.org

Reply via email to