aboutsummaryrefslogtreecommitdiffstats
path: root/bin/config_list
diff options
context:
space:
mode:
authortkikuchi <>2005-11-04 03:55:14 +0000
committertkikuchi <>2005-11-04 03:55:14 +0000
commit7173d6f28fc7dbafaafeb42806a96eda28ec4846 (patch)
treed66d6102d60d5713dd143c393d02b13ebb4bdb7d /bin/config_list
parentd5744efcc70452a500730dabcc8a9202218f7506 (diff)
downloadmailman2-7173d6f28fc7dbafaafeb42806a96eda28ec4846.tar.gz
mailman2-7173d6f28fc7dbafaafeb42806a96eda28ec4846.tar.xz
mailman2-7173d6f28fc7dbafaafeb42806a96eda28ec4846.zip
bin/config_list PEP263 and i18n improvement.
Diffstat (limited to 'bin/config_list')
-rw-r--r--bin/config_list47
1 files changed, 30 insertions, 17 deletions
diff --git a/bin/config_list b/bin/config_list
index 6f410a61..18ced8f9 100644
--- a/bin/config_list
+++ b/bin/config_list
@@ -1,6 +1,6 @@
#! @PYTHON@
#
-# Copyright (C) 1998-2003 by the Free Software Foundation, Inc.
+# Copyright (C) 1998-2005 by the Free Software Foundation, Inc.
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
@@ -72,9 +72,12 @@ from Mailman import mm_cfg
from Mailman import MailList
from Mailman import Utils
from Mailman import Errors
-from Mailman.i18n import _
+from Mailman import i18n
+
+_ = i18n._
NL = '\n'
+nonasciipat = re.compile(r'[\x80-\xff]')
@@ -103,14 +106,21 @@ def do_output(listname, outfile):
mlist = MailList.MailList(listname, lock=0)
except Errors.MMListError:
usage(1, _('No such list: %(listname)s'))
- # get all the list config info. all this stuff is accessible via the
- # web interface
+ # Preamble for the config info. PEP263 charset and capture time.
+ language = mlist.preferred_language
+ charset = Utils.GetCharSet(language)
+ i18n.set_language(language)
+ if not charset:
+ charset = 'us-ascii'
when = time.ctime(time.time())
print >> outfp, _('''\
-## "%(listname)s" mailing list configuration settings -*- python -*-
+# -*- python -*-
+# -*- coding: %(charset)s -*-
+## "%(listname)s" mailing list configuration settings
## captured on %(when)s
''')
-
+ # get all the list config info. all this stuff is accessible via the
+ # web interface
for k in mm_cfg.ADMIN_CATEGORIES:
subcats = mlist.GetConfigSubCategories(k)
if subcats is None:
@@ -128,6 +138,7 @@ def do_list_categories(mlist, k, subcat, outfp):
label, gui = mlist.GetConfigCategories()[k]
if info is None:
return
+ charset = Utils.GetCharSet(mlist.preferred_language)
print >> outfp, '##', k.capitalize(), _('options')
print >> outfp, '#'
# First, massage the descripton text, which could have obnoxious
@@ -166,23 +177,25 @@ def do_list_categories(mlist, k, subcat, outfp):
value = gui.getValue(mlist, vtype, varname, data[2])
if value is None and not varname.startswith('_'):
value = getattr(mlist, varname)
- if vtype in (mm_cfg.Text, mm_cfg.FileUpload):
+ if vtype in (mm_cfg.String, mm_cfg.Text, mm_cfg.FileUpload):
print >> outfp, varname, '=',
lines = value.splitlines()
if not lines:
print >> outfp, "''"
elif len(lines) == 1:
- print >> outfp, repr(lines[0])
+ if charset <> 'us-ascii' and nonasciipat.search(lines[0]):
+ # This is more readable for non-english list.
+ print >> outfp, '"' + lines[0].replace('"', '\\"') + '"'
+ else:
+ print >> outfp, repr(lines[0])
else:
- first = 1
- outfp.write(' """')
- for line in lines:
- if first:
- first = 0
- else:
- print >> outfp
- outfp.write(line.replace('"', '\\"'))
- print >> outfp, '"""'
+ if charset == 'us-ascii' and nonasciipat.search(value):
+ # Normally, an english list should not have non-ascii char.
+ print >> outfp, repr(NL.join(lines))
+ else:
+ outfp.write(' """')
+ outfp.write(NL.join(lines).replace('"', '\\"'))
+ outfp.write('"""\n')
elif vtype in (mm_cfg.Radio, mm_cfg.Toggle):
print >> outfp, '#'
print >> outfp, '#', _('legal values are:')