summaryrefslogtreecommitdiff
path: root/src/mailman/commands/docs
diff options
context:
space:
mode:
authorBarry Warsaw2015-12-22 23:14:44 -0500
committerBarry Warsaw2015-12-22 23:14:44 -0500
commita11e089cc1e0e5aff2502e584014295a414a43f9 (patch)
tree2cd85ac193e1bcaf3d17582f0cbe8614b3932fe1 /src/mailman/commands/docs
parentea1d7f360edd8f9ac70be5ed55caeaec27feb128 (diff)
downloadmailman-a11e089cc1e0e5aff2502e584014295a414a43f9.tar.gz
mailman-a11e089cc1e0e5aff2502e584014295a414a43f9.tar.zst
mailman-a11e089cc1e0e5aff2502e584014295a414a43f9.zip
The ``mailman members`` command can now be used to display members based on
subscription roles. Also, the positional "list" argument can now accept list names or list-ids.
Diffstat (limited to 'src/mailman/commands/docs')
-rw-r--r--src/mailman/commands/docs/members.rst97
1 files changed, 47 insertions, 50 deletions
diff --git a/src/mailman/commands/docs/members.rst b/src/mailman/commands/docs/members.rst
index 86e5c3ceb..c40afb122 100644
--- a/src/mailman/commands/docs/members.rst
+++ b/src/mailman/commands/docs/members.rst
@@ -6,15 +6,16 @@ The ``mailman members`` command allows a site administrator to display, add,
and remove members from a mailing list.
::
- >>> mlist1 = create_list('test1@example.com')
+ >>> ant = create_list('ant@example.com')
>>> class FakeArgs:
... input_filename = None
... output_filename = None
- ... listname = []
+ ... list = []
... regular = False
... digest = None
... nomail = None
+ ... role = None
>>> args = FakeArgs()
>>> from mailman.commands.cli_members import Members
@@ -27,19 +28,18 @@ Listing members
You can list all the members of a mailing list by calling the command with no
options. To start with, there are no members of the mailing list.
- >>> args.listname = [mlist1.fqdn_listname]
+ >>> args.list = ['ant.example.com']
>>> command.process(args)
- test1@example.com has no members
+ ant.example.com has no members
Once the mailing list add some members, they will be displayed.
-::
>>> from mailman.testing.helpers import subscribe
- >>> subscribe(mlist1, 'Anne', email='anne@example.com')
- <Member: Anne Person <anne@example.com> on test1@example.com
+ >>> subscribe(ant, 'Anne', email='anne@example.com')
+ <Member: Anne Person <anne@example.com> on ant@example.com
as MemberRole.member>
- >>> subscribe(mlist1, 'Bart', email='bart@example.com')
- <Member: Bart Person <bart@example.com> on test1@example.com
+ >>> subscribe(ant, 'Bart', email='bart@example.com')
+ <Member: Bart Person <bart@example.com> on ant@example.com
as MemberRole.member>
>>> command.process(args)
Anne Person <anne@example.com>
@@ -48,8 +48,8 @@ Once the mailing list add some members, they will be displayed.
Members are displayed in alphabetical order based on their address.
::
- >>> subscribe(mlist1, 'Anne', email='anne@aaaxample.com')
- <Member: Anne Person <anne@aaaxample.com> on test1@example.com
+ >>> subscribe(ant, 'Anne', email='anne@aaaxample.com')
+ <Member: Anne Person <anne@aaaxample.com> on ant@example.com
as MemberRole.member>
>>> command.process(args)
Anne Person <anne@aaaxample.com>
@@ -58,17 +58,15 @@ Members are displayed in alphabetical order based on their address.
You can also output this list to a file.
- >>> from tempfile import mkstemp
- >>> fd, args.output_filename = mkstemp()
- >>> import os
- >>> os.close(fd)
- >>> command.process(args)
- >>> with open(args.output_filename) as fp:
- ... print(fp.read())
+ >>> from tempfile import NamedTemporaryFile
+ >>> with NamedTemporaryFile() as outfp:
+ ... args.output_filename = outfp.name
+ ... command.process(args)
+ ... with open(args.output_filename) as infp:
+ ... print(infp.read())
Anne Person <anne@aaaxample.com>
Anne Person <anne@example.com>
Bart Person <bart@example.com>
- >>> os.remove(args.output_filename)
>>> args.output_filename = None
The output file can also be standard out.
@@ -88,7 +86,7 @@ You can limit output to just the regular non-digest members...
>>> from mailman.interfaces.member import DeliveryMode
>>> args.regular = True
- >>> member = mlist1.members.get_member('anne@example.com')
+ >>> member = ant.members.get_member('anne@example.com')
>>> member.preferences.delivery_mode = DeliveryMode.plaintext_digests
>>> command.process(args)
Anne Person <anne@aaaxample.com>
@@ -97,7 +95,7 @@ You can limit output to just the regular non-digest members...
...or just the digest members. Furthermore, you can either display all digest
members...
- >>> member = mlist1.members.get_member('anne@aaaxample.com')
+ >>> member = ant.members.get_member('anne@aaaxample.com')
>>> member.preferences.delivery_mode = DeliveryMode.mime_digests
>>> args.regular = False
>>> args.digest = 'any'
@@ -132,16 +130,16 @@ status is enabled...
>>> from mailman.interfaces.member import DeliveryStatus
- >>> member = mlist1.members.get_member('anne@aaaxample.com')
+ >>> member = ant.members.get_member('anne@aaaxample.com')
>>> member.preferences.delivery_status = DeliveryStatus.by_moderator
- >>> member = mlist1.members.get_member('bart@example.com')
+ >>> member = ant.members.get_member('bart@example.com')
>>> member.preferences.delivery_status = DeliveryStatus.by_user
- >>> member = subscribe(mlist1, 'Cris', email='cris@example.com')
+ >>> member = subscribe(ant, 'Cris', email='cris@example.com')
>>> member.preferences.delivery_status = DeliveryStatus.unknown
- >>> member = subscribe(mlist1, 'Dave', email='dave@example.com')
+ >>> member = subscribe(ant, 'Dave', email='dave@example.com')
>>> member.preferences.delivery_status = DeliveryStatus.enabled
- >>> member = subscribe(mlist1, 'Elle', email='elle@example.com')
+ >>> member = subscribe(ant, 'Elle', email='elle@example.com')
>>> member.preferences.delivery_status = DeliveryStatus.by_bounces
>>> args.nomail = 'enabled'
@@ -195,23 +193,20 @@ need a file containing email addresses and full names that can be parsed by
``email.utils.parseaddr()``.
::
- >>> mlist2 = create_list('test2@example.com')
-
- >>> import os
- >>> path = os.path.join(config.VAR_DIR, 'addresses.txt')
- >>> with open(path, 'w') as fp:
+ >>> bee = create_list('bee@example.com')
+ >>> with NamedTemporaryFile('w', buffering=1, encoding='utf-8') as fp:
... for address in ('aperson@example.com',
... 'Bart Person <bperson@example.com>',
... 'cperson@example.com (Cate Person)',
... ):
... print(address, file=fp)
-
- >>> args.input_filename = path
- >>> args.listname = [mlist2.fqdn_listname]
- >>> command.process(args)
+ ... fp.flush()
+ ... args.input_filename = fp.name
+ ... args.list = ['bee.example.com']
+ ... command.process(args)
>>> from operator import attrgetter
- >>> dump_list(mlist2.members.addresses, key=attrgetter('email'))
+ >>> dump_list(bee.members.addresses, key=attrgetter('email'))
aperson@example.com
Bart Person <bperson@example.com>
Cate Person <cperson@example.com>
@@ -227,15 +222,17 @@ taken from standard input.
... 'fperson@example.com (Fred Person)',
... ):
... print(address, file=fp)
+ >>> args.input_filename = '-'
>>> filepos = fp.seek(0)
>>> import sys
- >>> sys.stdin = fp
+ >>> try:
+ ... stdin = sys.stdin
+ ... sys.stdin = fp
+ ... command.process(args)
+ ... finally:
+ ... sys.stdin = stdin
- >>> args.input_filename = '-'
- >>> command.process(args)
- >>> sys.stdin = sys.__stdin__
-
- >>> dump_list(mlist2.members.addresses, key=attrgetter('email'))
+ >>> dump_list(bee.members.addresses, key=attrgetter('email'))
aperson@example.com
Bart Person <bperson@example.com>
Cate Person <cperson@example.com>
@@ -246,7 +243,7 @@ taken from standard input.
Blank lines and lines that begin with '#' are ignored.
::
- >>> with open(path, 'w') as fp:
+ >>> with NamedTemporaryFile('w', buffering=1, encoding='utf-8') as fp:
... for address in ('gperson@example.com',
... '# hperson@example.com',
... ' ',
@@ -254,10 +251,10 @@ Blank lines and lines that begin with '#' are ignored.
... 'iperson@example.com',
... ):
... print(address, file=fp)
+ ... args.input_filename = fp.name
+ ... command.process(args)
- >>> args.input_filename = path
- >>> command.process(args)
- >>> dump_list(mlist2.members.addresses, key=attrgetter('email'))
+ >>> dump_list(bee.members.addresses, key=attrgetter('email'))
aperson@example.com
Bart Person <bperson@example.com>
Cate Person <cperson@example.com>
@@ -271,18 +268,18 @@ Addresses which are already subscribed are ignored, although a warning is
printed.
::
- >>> with open(path, 'w') as fp:
+ >>> with NamedTemporaryFile('w', buffering=1, encoding='utf-8') as fp:
... for address in ('gperson@example.com',
... 'aperson@example.com',
... 'jperson@example.com',
... ):
... print(address, file=fp)
-
- >>> command.process(args)
+ ... args.input_filename = fp.name
+ ... command.process(args)
Already subscribed (skipping): gperson@example.com
Already subscribed (skipping): aperson@example.com
- >>> dump_list(mlist2.members.addresses, key=attrgetter('email'))
+ >>> dump_list(bee.members.addresses, key=attrgetter('email'))
aperson@example.com
Bart Person <bperson@example.com>
Cate Person <cperson@example.com>