~ubuntu-branches/ubuntu/hardy/mailman/hardy-updates

« back to all changes in this revision

Viewing changes to bin/config_list

  • Committer: Bazaar Package Importer
  • Author(s): Martin Pitt
  • Date: 2006-07-03 16:59:25 UTC
  • mfrom: (1.1.1 upstream)
  • Revision ID: james.westby@ubuntu.com-20060703165925-175ubna955u796c0
Tags: 0:2.1.8-1ubuntu1
* Merge to Debian; remaining Ubuntu changes:
  - debian/mailman.init: Create /var/{run,lock}/mailman.
  - debian/control: exim4 -> postfix.
* debian/control: Dependency fix: apache -> apache2.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
#! @PYTHON@
2
2
#
3
 
# Copyright (C) 1998-2003 by the Free Software Foundation, Inc.
 
3
# Copyright (C) 1998-2005 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
14
14
#
15
15
# You should have received a copy of the GNU General Public License
16
16
# along with this program; if not, write to the Free Software
17
 
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
 
17
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
 
18
# USA.
18
19
 
19
20
"""Configure a list from a text file description.
20
21
 
72
73
from Mailman import MailList
73
74
from Mailman import Utils
74
75
from Mailman import Errors
75
 
from Mailman.i18n import _
 
76
from Mailman import i18n
 
77
 
 
78
_ = i18n._
76
79
 
77
80
NL = '\n'
 
81
nonasciipat = re.compile(r'[\x80-\xff]')
78
82
 
79
83
 
80
84
 
103
107
            mlist = MailList.MailList(listname, lock=0)
104
108
        except Errors.MMListError:
105
109
            usage(1, _('No such list: %(listname)s'))
106
 
        # get all the list config info.  all this stuff is accessible via the
107
 
        # web interface
 
110
        # Preamble for the config info. PEP263 charset and capture time.
 
111
        language = mlist.preferred_language
 
112
        charset = Utils.GetCharSet(language)
 
113
        i18n.set_language(language)
 
114
        if not charset:
 
115
            charset = 'us-ascii'
108
116
        when = time.ctime(time.time())
109
117
        print >> outfp, _('''\
110
 
## "%(listname)s" mailing list configuration settings -*- python -*-
 
118
# -*- python -*-
 
119
# -*- coding: %(charset)s -*-
 
120
## "%(listname)s" mailing list configuration settings
111
121
## captured on %(when)s
112
122
''')
113
 
 
 
123
        # get all the list config info.  all this stuff is accessible via the
 
124
        # web interface
114
125
        for k in mm_cfg.ADMIN_CATEGORIES:
115
126
            subcats = mlist.GetConfigSubCategories(k)
116
127
            if subcats is None:
128
139
    label, gui = mlist.GetConfigCategories()[k]
129
140
    if info is None:
130
141
        return
 
142
    charset = Utils.GetCharSet(mlist.preferred_language)
131
143
    print >> outfp, '##', k.capitalize(), _('options')
132
144
    print >> outfp, '#'
133
145
    # First, massage the descripton text, which could have obnoxious
166
178
            value = gui.getValue(mlist, vtype, varname, data[2])
167
179
        if value is None and not varname.startswith('_'):
168
180
            value = getattr(mlist, varname)
169
 
        if vtype in (mm_cfg.Text, mm_cfg.FileUpload):
 
181
        if vtype in (mm_cfg.String, mm_cfg.Text, mm_cfg.FileUpload):
170
182
            print >> outfp, varname, '=',
171
183
            lines = value.splitlines()
172
184
            if not lines:
173
185
                print >> outfp, "''"
174
186
            elif len(lines) == 1:
175
 
                print >> outfp, repr(lines[0])
 
187
                if charset <> 'us-ascii' and nonasciipat.search(lines[0]):
 
188
                    # This is more readable for non-english list.
 
189
                    print >> outfp, '"' + lines[0].replace('"', '\\"') + '"'
 
190
                else:
 
191
                    print >> outfp, repr(lines[0])
176
192
            else:
177
 
                first = 1
178
 
                outfp.write(' """')
179
 
                for line in lines:
180
 
                    if first:
181
 
                        first = 0
182
 
                    else:
183
 
                        print >> outfp
184
 
                    outfp.write(line.replace('"', '\\"'))
185
 
                print >> outfp, '"""'
 
193
                if charset == 'us-ascii' and nonasciipat.search(value):
 
194
                    # Normally, an english list should not have non-ascii char.
 
195
                    print >> outfp, repr(NL.join(lines))
 
196
                else:
 
197
                    outfp.write(' """')
 
198
                    outfp.write(NL.join(lines).replace('"', '\\"'))
 
199
                    outfp.write('"""\n')
186
200
        elif vtype in (mm_cfg.Radio, mm_cfg.Toggle):
187
201
            print >> outfp, '#'
188
202
            print >> outfp, '#', _('legal values are:')