diff options
Diffstat (limited to 'bin/list_members')
-rwxr-xr-x | bin/list_members | 26 |
1 files changed, 17 insertions, 9 deletions
diff --git a/bin/list_members b/bin/list_members index 3ad10f51..b4fdbb27 100755 --- a/bin/list_members +++ b/bin/list_members @@ -1,6 +1,6 @@ #! @PYTHON@ # -# Copyright (C) 1998,1999,2000,2001,2002 by the Free Software Foundation, Inc. +# Copyright (C) 1998-2003 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 @@ -61,6 +61,7 @@ status. """ import sys +from types import UnicodeType import paths from Mailman import mm_cfg @@ -72,6 +73,8 @@ from Mailman.i18n import _ from email.Utils import formataddr PROGRAM = sys.argv[0] +ENC = sys.getdefaultencoding() + WHYCHOICES = {'enabled' : MemberAdaptor.ENABLED, 'unknown' : MemberAdaptor.UNKNOWN, 'byuser' : MemberAdaptor.BYUSER, @@ -92,6 +95,15 @@ def usage(code, msg=''): +def safe(s): + if not s: + return '' + if isinstance(s, UnicodeType): + return s.encode(ENC, 'replace') + return unicode(s, ENC, 'replace').encode(ENC, 'replace') + + + def whymatches(mlist, addr, why): # Return true if the `why' matches the reason the address is enabled, or # in the case of why is None, that they are disabled for any reason @@ -199,17 +211,15 @@ def main(): if regular: rmembers.sort() for addr in rmembers: - name = fullnames and mlist.getMemberName(addr) + name = fullnames and mlist.getMemberName(addr) or '' # Filter out nomails if nomail and not whymatches(mlist, addr, why): continue - enc = sys.getdefaultencoding() - s = formataddr((name, addr)).encode(enc, 'replace') - print >> fp, s + print >> fp, formataddr((safe(name), addr)) if digest: dmembers.sort() for addr in dmembers: - name = fullnames and mlist.getMemberName(addr) + name = fullnames and mlist.getMemberName(addr) or '' # Filter out nomails if nomail and not whymatches(mlist, addr, why): continue @@ -222,9 +232,7 @@ def main(): # They're getting MIME digests if kind == 'plain': continue - enc = sys.getdefaultencoding() - s = formataddr((name, addr)).encode(enc, 'replace') - print >> fp, s + print >> fp, formataddr((safe(name), addr)) |