summaryrefslogtreecommitdiff
path: root/src/mailman/commands/cmd_who.py
diff options
context:
space:
mode:
authorBarry Warsaw2009-03-29 15:40:22 -0500
committerBarry Warsaw2009-03-29 15:40:22 -0500
commit5388a2358749a1774bb801e6e6839c1798998a1f (patch)
tree6bf6f2a10f1f1f588d5ca6d2f4c8ec8e6530cb4a /src/mailman/commands/cmd_who.py
parentf90c651d85050b9ad3b33bdf210672452d2ba1f0 (diff)
downloadmailman-5388a2358749a1774bb801e6e6839c1798998a1f.tar.gz
mailman-5388a2358749a1774bb801e6e6839c1798998a1f.tar.zst
mailman-5388a2358749a1774bb801e6e6839c1798998a1f.zip
Add argparse 'cause I think this might end up being cool.
Refactor the finding of components so that it's much easier to find and register the ones that come with Mailman by default. Move all the old cmd_*.py commands into the attic. These will eventually be ported to the new framework.
Diffstat (limited to 'src/mailman/commands/cmd_who.py')
-rw-r--r--src/mailman/commands/cmd_who.py152
1 files changed, 0 insertions, 152 deletions
diff --git a/src/mailman/commands/cmd_who.py b/src/mailman/commands/cmd_who.py
deleted file mode 100644
index 6c66610b3..000000000
--- a/src/mailman/commands/cmd_who.py
+++ /dev/null
@@ -1,152 +0,0 @@
-# Copyright (C) 2002-2009 by the Free Software Foundation, Inc.
-#
-# This file is part of GNU Mailman.
-#
-# GNU Mailman 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 3 of the License, or (at your option)
-# any later version.
-#
-# GNU Mailman 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
-# GNU Mailman. If not, see <http://www.gnu.org/licenses/>.
-
-from email.Utils import parseaddr
-
-from mailman import i18n
-from mailman.config import config
-
-STOP = 1
-
-def _(s): return s
-
-PUBLICHELP = _("""
- who
- See the non-hidden members of this mailing list.
- who password
- See everyone who is on this mailing list. The password is the
- list's admin or moderator password.
-""")
-
-MEMBERSONLYHELP = _("""
- who password [address=<address>]
- See the non-hidden members of this mailing list. The roster is
- limited to list members only, and you must supply your membership
- password to retrieve it. If you're posting from an address other
- than your membership address, specify your membership address with
- `address=<address>' (no brackets around the email address, and no
- quotes!). If you provide the list's admin or moderator password,
- hidden members will be included.
-""")
-
-ADMINONLYHELP = _("""
- who password
- See everyone who is on this mailing list. The roster is limited to
- list administrators and moderators only; you must supply the list
- admin or moderator password to retrieve the roster.
-""")
-
-_ = i18n._
-
-
-
-def gethelp(mlist):
- if mlist.private_roster == 0:
- return _(PUBLICHELP)
- elif mlist.private_roster == 1:
- return _(MEMBERSONLYHELP)
- elif mlist.private_roster == 2:
- return _(ADMINONLYHELP)
-
-
-def usage(res):
- res.results.append(_('Usage:'))
- res.results.append(gethelp(res.mlist))
-
-
-
-def process(res, args):
- mlist = res.mlist
- address = None
- password = None
- ok = False
- full = False
- if mlist.private_roster == 0:
- # Public rosters
- if args:
- if len(args) == 1:
- if mlist.Authenticate((config.AuthListModerator,
- config.AuthListAdmin),
- args[0]):
- full = True
- else:
- usage(res)
- return STOP
- else:
- usage(res)
- return STOP
- ok = True
- elif mlist.private_roster == 1:
- # List members only
- if len(args) == 1:
- password = args[0]
- realname, address = parseaddr(res.msg['from'])
- elif len(args) == 2 and args[1].startswith('address='):
- password = args[0]
- address = args[1][8:]
- else:
- usage(res)
- return STOP
- if mlist.isMember(address) and mlist.Authenticate(
- (config.AuthUser,
- config.AuthListModerator,
- config.AuthListAdmin),
- password, address):
- # Then
- ok = True
- if mlist.Authenticate(
- (config.AuthListModerator,
- config.AuthListAdmin),
- password):
- # Then
- ok = full = True
- else:
- # Admin only
- if len(args) <> 1:
- usage(res)
- return STOP
- if mlist.Authenticate((config.AuthListModerator,
- config.AuthListAdmin),
- args[0]):
- ok = full = True
- if not ok:
- res.results.append(
- _('You are not allowed to retrieve the list membership.'))
- return STOP
- # It's okay for this person to see the list membership
- dmembers = mlist.getDigestMemberKeys()
- rmembers = mlist.getRegularMemberKeys()
- if not dmembers and not rmembers:
- res.results.append(_('This list has no members.'))
- return
- # Convenience function
- def addmembers(members):
- for member in members:
- if not full and mlist.getMemberOption(member,
- config.ConcealSubscription):
- continue
- realname = mlist.getMemberName(member)
- if realname:
- res.results.append(' %s (%s)' % (member, realname))
- else:
- res.results.append(' %s' % member)
- if rmembers:
- res.results.append(_('Non-digest (regular) members:'))
- addmembers(rmembers)
- if dmembers:
- res.results.append(_('Digest members:'))
- addmembers(dmembers)