summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorbwarsaw2006-05-08 02:06:11 +0000
committerbwarsaw2006-05-08 02:06:11 +0000
commitbda25c546ef3964a3772c8dc8a3eefdd592ebd31 (patch)
tree55d46accf26b7192a0face80cf417111aea0c189
parentc46466663967674964c17ac33f31ce93079fa773 (diff)
downloadmailman-bda25c546ef3964a3772c8dc8a3eefdd592ebd31.tar.gz
mailman-bda25c546ef3964a3772c8dc8a3eefdd592ebd31.tar.zst
mailman-bda25c546ef3964a3772c8dc8a3eefdd592ebd31.zip
-rwxr-xr-xMailman/bin/find_member.py135
-rw-r--r--bin/Makefile.in8
-rwxr-xr-xbin/find_member184
-rwxr-xr-xconfigure9
-rw-r--r--configure.in3
5 files changed, 144 insertions, 195 deletions
diff --git a/Mailman/bin/find_member.py b/Mailman/bin/find_member.py
new file mode 100755
index 000000000..e249fb30b
--- /dev/null
+++ b/Mailman/bin/find_member.py
@@ -0,0 +1,135 @@
+# Copyright (C) 1998-2006 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
+# as published by the Free Software Foundation; either version 2
+# of the License, or (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
+# USA.
+
+import re
+import sys
+import optparse
+
+from Mailman import Errors
+from Mailman import MailList
+from Mailman import Utils
+from Mailman import mm_cfg
+from Mailman.i18n import _
+
+
+__i18n_templates__ = True
+
+AS_MEMBER = 0x01
+AS_OWNER = 0x02
+
+
+
+def parseargs():
+ parser = optparse.OptionParser(version=mm_cfg.MAILMAN_VERSION,
+ usage=_("""\
+%prog [options] regex [regex ...]
+
+Find all lists that a member's address is on.
+
+The interaction between -l and -x (see below) is as follows. If any -l option
+is given then only the named list will be included in the search. If any -x
+option is given but no -l option is given, then all lists will be search
+except those specifically excluded.
+
+Regular expression syntax uses the Python 're' module. Complete
+specifications are at:
+
+http://www.python.org/doc/current/lib/module-re.html
+
+Address matches are case-insensitive, but case-preserved addresses are
+displayed."""))
+ parser.add_option('-l', '--listname',
+ type='string', default=[], action='append',
+ dest='listnames',
+ help=_('Include only the named list in the search'))
+ parser.add_option('-x', '--exclude',
+ type='string', default=[], action='append',
+ dest='excludes',
+ help=_('Exclude the named list from the search'))
+ parser.add_option('-w', '--owners',
+ default=False, action='store_true',
+ help=_('Search list owners as well as members'))
+ opts, args = parser.parse_args()
+ if not args:
+ parser.print_help()
+ print >> sys.stderr, _('Search regular expression required')
+ sys.exit(1)
+ if not opts.listnames and opts.excludes:
+ opts.listnames = Utils.list_names()
+ return parser, opts, args
+
+
+
+def main():
+ parser, opts, args = parseargs()
+
+ includes = set(listname.lower() for listname in opts.listnames)
+ excludes = set(listname.lower() for listname in opts.excludes)
+ listnames = includes - excludes
+
+ if not listnames:
+ print _('No lists to search')
+ return
+
+ cres = []
+ for r in args:
+ cres.append(re.compile(r, re.IGNORECASE))
+ # dictionary of {address, (listname, ownerp)}
+ matches = {}
+ for listname in listnames:
+ try:
+ mlist = MailList.MailList(listname, lock=False)
+ except Errors.MMListError:
+ print _('No such list: $listname')
+ continue
+ if opts.owners:
+ owners = mlist.owner
+ else:
+ owners = []
+ for cre in cres:
+ for member in mlist.getMembers():
+ if cre.search(member):
+ addr = mlist.getMemberCPAddress(member)
+ entries = matches.get(addr, {})
+ aswhat = entries.get(listname, 0)
+ aswhat |= AS_MEMBER
+ entries[listname] = aswhat
+ matches[addr] = entries
+ for owner in owners:
+ if cre.search(owner):
+ entries = matches.get(owner, {})
+ aswhat = entries.get(listname, 0)
+ aswhat |= AS_OWNER
+ entries[listname] = aswhat
+ matches[owner] = entries
+ addrs = matches.keys()
+ addrs.sort()
+ for k in addrs:
+ hits = matches[k]
+ lists = hits.keys()
+ print k, _('found in:')
+ for name in lists:
+ aswhat = hits[name]
+ if aswhat & AS_MEMBER:
+ print ' ', name
+ if aswhat & AS_OWNER:
+ print ' ', name, _('(as owner)')
+
+
+
+if __name__ == '__main__':
+ main()
diff --git a/bin/Makefile.in b/bin/Makefile.in
index dbf6bc295..67ceef621 100644
--- a/bin/Makefile.in
+++ b/bin/Makefile.in
@@ -46,16 +46,16 @@ SHELL= /bin/sh
SCRIPTS= mmshell \
remove_members clone_member update \
- sync_members check_db withlist check_perms find_member \
+ sync_members check_db withlist check_perms \
config_list dumpdb cleanarch \
list_admins genaliases mailmanctl qrunner \
fix_url.py convert.py transcheck \
msgfmt.py discard \
reset_pw.py templ2pot.py po2templ.py
-LN_SCRIPTS= add_members arch change_pw inject list_lists list_members \
- list_owners mmsitepass newlist rmlist show_qfiles unshunt \
- version
+LN_SCRIPTS= add_members arch change_pw find_member inject list_lists \
+ list_members list_owners mmsitepass newlist rmlist \
+ show_qfiles unshunt version
BUILDDIR= ../build/bin
diff --git a/bin/find_member b/bin/find_member
deleted file mode 100755
index 0c5d8711d..000000000
--- a/bin/find_member
+++ /dev/null
@@ -1,184 +0,0 @@
-#! @PYTHON@
-#
-# 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
-# as published by the Free Software Foundation; either version 2
-# of the License, or (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with this program; if not, write to the Free Software
-# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
-
-"""Find all lists that a member's address is on.
-
-Usage:
- find_member [options] regex [regex [...]]
-
-Where:
- --listname=listname
- -l listname
- Include only the named list in the search.
-
- --exclude=listname
- -x listname
- Exclude the named list from the search.
-
- --owners
- -w
- Search list owners as well as members.
-
- --help
- -h
- Print this help message and exit.
-
- regex
- A Python regular expression to match against.
-
-The interaction between -l and -x is as follows. If any -l option is given
-then only the named list will be included in the search. If any -x option is
-given but no -l option is given, then all lists will be search except those
-specifically excluded.
-
-Regular expression syntax is Perl5-like, using the Python re module. Complete
-specifications are at:
-
-http://www.python.org/doc/current/lib/module-re.html
-
-Address matches are case-insensitive, but case-preserved addresses are
-displayed.
-
-"""
-
-import sys
-import re
-import getopt
-
-import paths
-from Mailman import Utils
-from Mailman import MailList
-from Mailman import Errors
-from Mailman.i18n import _
-
-AS_MEMBER = 0x01
-AS_OWNER = 0x02
-
-
-
-def usage(code, msg=''):
- if code:
- fd = sys.stderr
- else:
- fd = sys.stdout
- print >> fd, _(__doc__)
- if msg:
- print >> fd, msg
- sys.exit(code)
-
-
-
-def scanlists(options):
- cres = []
- for r in options.regexps:
- cres.append(re.compile(r, re.IGNORECASE))
- #
- # dictionary of {address, (listname, ownerp)}
- matches = {}
- for listname in options.listnames:
- try:
- mlist = MailList.MailList(listname, lock=0)
- except Errors.MMListError:
- print _('No such list: %(listname)s')
- continue
- if options.owners:
- owners = mlist.owner
- else:
- owners = []
- for cre in cres:
- for member in mlist.getMembers():
- if cre.search(member):
- addr = mlist.getMemberCPAddress(member)
- entries = matches.get(addr, {})
- aswhat = entries.get(listname, 0)
- aswhat |= AS_MEMBER
- entries[listname] = aswhat
- matches[addr] = entries
- for owner in owners:
- if cre.search(owner):
- entries = matches.get(owner, {})
- aswhat = entries.get(listname, 0)
- aswhat |= AS_OWNER
- entries[listname] = aswhat
- matches[owner] = entries
- return matches
-
-
-
-class Options:
- listnames = Utils.list_names()
- owners = None
-
-
-def main():
- try:
- opts, args = getopt.getopt(sys.argv[1:], 'l:x:wh',
- ['listname=', 'exclude=', 'owners',
- 'help'])
- except getopt.error, msg:
- usage(1, msg)
-
- options = Options()
- loptseen = 0
- excludes = []
- for opt, arg in opts:
- if opt in ('-h', '--help'):
- usage(0)
- elif opt in ('-l', '--listname'):
- if not loptseen:
- options.listnames = []
- loptseen = 1
- options.listnames.append(arg.lower())
- elif opt in ('-x', '--exclude'):
- excludes.append(arg.lower())
- elif opt in ('-w', '--owners'):
- options.owners = 1
-
- for ex in excludes:
- try:
- options.listnames.remove(ex)
- except ValueError:
- pass
-
- if not args:
- usage(1, _('Search regular expression required'))
-
- options.regexps = args
-
- if not options.listnames:
- print _('No lists to search')
- return
-
- matches = scanlists(options)
- addrs = matches.keys()
- addrs.sort()
- for k in addrs:
- hits = matches[k]
- lists = hits.keys()
- print k, _('found in:')
- for name in lists:
- aswhat = hits[name]
- if aswhat & AS_MEMBER:
- print ' ', name
- if aswhat & AS_OWNER:
- print ' ', name, _('(as owner)')
-
-
-
-if __name__ == '__main__':
- main()
diff --git a/configure b/configure
index 208a971a1..34bfbf06c 100755
--- a/configure
+++ b/configure
@@ -1,5 +1,5 @@
#! /bin/sh
-# From configure.in Revision: 7891 .
+# From configure.in Revision: 7892 .
# Guess values for system-dependent variables and create Makefiles.
# Generated by GNU Autoconf 2.59.
#
@@ -721,13 +721,13 @@ echo X"$0" |
/^X\(\/\).*/{ s//\1/; q; }
s/.*/./; q'`
srcdir=$ac_confdir
- if test ! -r "$srcdir/$ac_unique_file"; then
+ if test ! -r $srcdir/$ac_unique_file; then
srcdir=..
fi
else
ac_srcdir_defaulted=no
fi
-if test ! -r "$srcdir/$ac_unique_file"; then
+if test ! -r $srcdir/$ac_unique_file; then
if test "$ac_srcdir_defaulted" = yes; then
{ echo "$as_me: error: cannot find sources ($ac_unique_file) in $ac_confdir or .." >&2
{ (exit 1); exit 1; }; }
@@ -736,7 +736,7 @@ if test ! -r "$srcdir/$ac_unique_file"; then
{ (exit 1); exit 1; }; }
fi
fi
-(cd $srcdir && test -r "./$ac_unique_file") 2>/dev/null ||
+(cd $srcdir && test -r ./$ac_unique_file) 2>/dev/null ||
{ echo "$as_me: error: sources are in $srcdir, but \`cd $srcdir' does not work" >&2
{ (exit 1); exit 1; }; }
srcdir=`echo "$srcdir" | sed 's%\([^\\/]\)[\\/]*$%\1%'`
@@ -4284,7 +4284,6 @@ build/bin/config_list:bin/config_list \
build/bin/convert.py:bin/convert.py \
build/bin/discard:bin/discard \
build/bin/dumpdb:bin/dumpdb \
-build/bin/find_member:bin/find_member \
build/bin/fix_url.py:bin/fix_url.py \
build/bin/genaliases:bin/genaliases \
build/bin/list_admins:bin/list_admins \
diff --git a/configure.in b/configure.in
index 78cc5e0a6..41ad22893 100644
--- a/configure.in
+++ b/configure.in
@@ -15,7 +15,7 @@
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
dnl Process this file with autoconf to produce a configure script.
-AC_REVISION($Revision: 7892 $)
+AC_REVISION($Revision: 7893 $)
AC_PREREQ(2.0)
AC_INIT(src/common.h)
@@ -602,7 +602,6 @@ bin/config_list \
bin/convert.py \
bin/discard \
bin/dumpdb \
-bin/find_member \
bin/fix_url.py \
bin/genaliases \
bin/list_admins \