~xav0989/ubuntu/vivid/mailman/ubuntu-logo

« back to all changes in this revision

Viewing changes to bin/dumpdb

  • Committer: Bazaar Package Importer
  • Author(s): Thijs Kinkhorst
  • Date: 2008-04-24 19:30:49 UTC
  • mfrom: (1.1.3 upstream)
  • Revision ID: james.westby@ubuntu.com-20080424193049-jy5fa9tus40tjbmn
Tags: 1:2.1.10-2
Apply upstream patch to fix regression in cmd_subscribe
so that email subscribe to the -subscribe or -join address or the
-request address with a bare 'subscribe' command results in the message
being shunted.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
#! @PYTHON@
2
2
#
3
 
# Copyright (C) 1998-2005 by the Free Software Foundation, Inc.
 
3
# Copyright (C) 1998-2007 by the Free Software Foundation, Inc.
4
4
#
5
5
# This program is free software; you can redistribute it and/or
6
6
# modify it under the terms of the GNU General Public License
45
45
-- or if the file ends in neither suffix -- use the -p or -m flags.
46
46
"""
47
47
 
48
 
import os
49
48
import sys
50
49
import getopt
51
50
import pprint
52
 
from cPickle import load
 
51
import cPickle
 
52
import marshal
53
53
from types import StringType
54
54
 
55
55
import paths
56
56
# Import this /after/ paths so that the sys.path is properly hacked
57
 
from email.Generator import Generator
58
57
from Mailman.i18n import _
59
58
 
60
59
PROGRAM = sys.argv[0]
121
120
    # Handle dbs
122
121
    pp = pprint.PrettyPrinter(indent=4)
123
122
    if filetype == 1:
124
 
        # BAW: this probably doesn't work if there are mixed types of .db
125
 
        # files (i.e. some marshals, some bdbs).
126
 
        d = DumperSwitchboard().read(filename)
 
123
        load = marshal.load
 
124
        typename = 'marshal'
 
125
    else:
 
126
        load = cPickle.load
 
127
        typename = 'pickle'
 
128
    fp = open(filename)
 
129
    m = []
 
130
    try:
 
131
        cnt = 1
127
132
        if doprint:
128
 
            pp.pprint(d)
129
 
        return d
130
 
    else:
131
 
        fp = open(filename)
132
 
        m = []
133
 
        try:
134
 
            cnt = 1
 
133
            print _('[----- start %(typename)s file -----]')
 
134
        while True:
 
135
            try:
 
136
                obj = load(fp)
 
137
            except EOFError:
 
138
                if doprint:
 
139
                    print _('[----- end %(typename)s file -----]')
 
140
                break
135
141
            if doprint:
136
 
                print _('[----- start pickle file -----]')
137
 
            while True:
138
 
                try:
139
 
                    obj = load(fp)
140
 
                except EOFError:
141
 
                    if doprint:
142
 
                        print _('[----- end pickle file -----]')
143
 
                    break
144
 
                if doprint:
145
 
                    print _('<----- start object %(cnt)s ----->')
146
 
                    if isinstance(obj, StringType):
147
 
                        print obj
148
 
                    else:
149
 
                        pp.pprint(obj)
150
 
                cnt += 1
151
 
                m.append(obj)
152
 
        finally:
153
 
            fp.close()
154
 
        return m
 
142
                print _('<----- start object %(cnt)s ----->')
 
143
                if isinstance(obj, StringType):
 
144
                    print obj
 
145
                else:
 
146
                    pp.pprint(obj)
 
147
            cnt += 1
 
148
            m.append(obj)
 
149
    finally:
 
150
        fp.close()
 
151
    return m
155
152
 
156
153
 
157
154