[Mailman-Developers] Re: interface dreams
David Champion
dgc at uchicago.edu
Thu Jul 15 17:59:53 CEST 2004
* On 2004.07.15, in <20040715135923.GI24700 at rezo.net>,
* "Fil" <fil at rezo.net> wrote:
>
> As a list admin, I dream of a roster interface that would help me go fast
> when I have 10 people to subscribe and 10 to remove because they don't know
> better than "Reply"-ing to me.
>
> I can make it up with php, with a box for search, another for "add users",
> another for "remove users", and so on ("change address").
>
> However there's something that could be very useful, that would be "search
> fuzzy matches", for instance if <mr.bean at rezo.net> writes to me saying
> that he needs to be unsubscribed, I can't easily locate his subscription if
> it's under <bean at mail.rezo.net>. Any idea on how to do this?
This isn't very webby, but we use it a lot. (With 2500 lists, it really
helps deal with those "please remove me from your list" messages.) It's
probably terrible python, but it does the job.
usage: /opt/bin/grep_members.py [!] regex [list [...]]
/opt/bin/grep_members.py [!] = address [list [...]]
In your example, I might do:
% grep_members.py bean listname
Or, to find all lists that mr.bean is on:
% grep_members.py bean
The second form is to find a precise match among the specified lists, or
among all lists. It also DTRT if called as grep_owners.py instead.
--
-D. dgc at uchicago.edu NSIT::ENSS
-------------- next part --------------
#!/opt/bin/python
##
## $Id: grep_members.py,v 1.6 2003/07/11 01:10:38 dgc Exp $
##
## grep_members.py greps owners instead of members if argv[0]
## contains "owner".
##
import sys
import getopt
import string
import mailman
import re
from Mailman.MailList import MailList
from Mailman.Utils import list_names
self = sys.argv[0]
members = {}
r = None
s = None
i = 1
check_owners = 0 # otherwise, members
show_all = 0
invert = 0
errors = 0
if len(sys.argv) == 1 or sys.argv[1] == "-h" or sys.argv[1] == "--help":
print "usage: %s [!] regex [list [...]]" % (sys.argv[0])
print " %s [!] = address [list [...]]" % (sys.argv[0])
sys.exit(4)
if (re.search("owner", sys.argv[0])):
check_owners = 1
if sys.argv[i] == "!" or sys.argv[1] == '-':
invert = 1
i = i + 1
if sys.argv[i] == "=":
s = sys.argv[i+1]
i = i + 2
elif sys.argv[i] == ".":
show_all = 1
i = i + 1
else:
r = re.compile(sys.argv[i], re.IGNORECASE)
i = i + 1
if len(sys.argv) > i:
names = sys.argv[i:]
else:
names = list_names()
names.sort()
if (invert and show_all):
sys.exit(0) # ! . is no matches all the time
for lname in names:
try:
m = MailList(lname, lock=0)
except:
print "%s: no list named %s" % (sys.argv[0], lname)
errors = 1
continue
if (check_owners):
namelist = m.owner
else:
namelist = m.members.keys() + m.digest_members.keys()
namelist.sort()
for name in namelist:
if (show_all):
print lname + ": " + name
elif (r == None):
# use string matching
if (invert ^ (name == s)):
print lname + ": " + name
else:
# use regex matching
if (r.search(name)):
didmatch = 1
else:
didmatch = 0
if (invert ^ didmatch):
print lname + ": " + name
if errors:
sys.exit(10)
sys.exit(0)
More information about the Mailman-Developers
mailing list