Mark Sapiro pushed to branch master at GNU Mailman / Mailman Core
Commits: 39f5bf70 by Peter Williams at 2020-06-02T02:41:31+00:00 Add option to list membership containing only addresses and not display names. - - - - - d5139fad by Mark Sapiro at 2020-06-02T02:41:31+00:00 Merge branch 'patch-1' into 'master' Add option to list membership containing only addresses and not display names. See merge request mailman/mailman!656 - - - - - 2 changed files: - src/mailman/commands/cli_members.py - src/mailman/commands/tests/test_cli_members.py Changes: ===================================== src/mailman/commands/cli_members.py ===================================== @@ -39,7 +39,8 @@ from zope.component import getUtility from zope.interface import implementer -def display_members(ctx, mlist, role, regular, digest, nomail, outfp): +def display_members(ctx, mlist, role, regular, digest, + nomail, outfp, email_only): # Which type of digest recipients should we display? if digest == 'any': digest_types = [ @@ -103,8 +104,11 @@ def display_members(ctx, mlist, role, regular, digest, nomail, outfp): member = roster.get_member(address.email) if member.delivery_status not in status_types: continue - print(formataddr((address.display_name, address.original_email)), - file=outfp) + if email_only: + print(address.original_email, file=outfp) + else: + print(formataddr((address.display_name, address.original_email)), + file=outfp) @transactional @@ -294,6 +298,12 @@ def sync_members(mlist, sync_infp, no_change): is_flag=True, default=False, help=_("""\ [output filter] Display only regular delivery members.""")) +@click.option( + '--email-only', '-e', 'email_only', + is_flag=True, default=False, + help=("""\ + [output filter] Display member addresses only, without the display name. + """)) @click.option( '--no-change', '-N', 'no_change', is_flag=True, default=False, @@ -324,7 +334,7 @@ def sync_members(mlist, sync_infp, no_change): @click.argument('listspec') @click.pass_context def members(ctx, add_infp, del_infp, sync_infp, outfp, - role, regular, no_change, digest, nomail, listspec): + role, regular, no_change, digest, nomail, listspec, email_only): mlist = getUtility(IListManager).get(listspec) if mlist is None: ctx.fail(_('No such list: $listspec')) @@ -335,7 +345,8 @@ def members(ctx, add_infp, del_infp, sync_infp, outfp, elif sync_infp is not None: sync_members(mlist, sync_infp, no_change) else: - display_members(ctx, mlist, role, regular, digest, nomail, outfp) + display_members(ctx, mlist, role, regular, + digest, nomail, outfp, email_only) @public ===================================== src/mailman/commands/tests/test_cli_members.py ===================================== @@ -321,3 +321,11 @@ class TestCLIMembers(unittest.TestCase): lines = infp.readlines() self.assertEqual(len(lines), 1) self.assertEqual(lines[0], 'aper...@example.com\n') + + def test_email_only(self): + subscribe(self._mlist, 'Anne') + subscribe(self._mlist, 'Bart') + result = self._command.invoke(members, ( + '--email-only', 'ant.example.com')) + self.assertEqual(result.output, + 'aper...@example.com\nbper...@example.com\n') View it on GitLab: https://gitlab.com/mailman/mailman/-/compare/576407f2ba024b4b05466127aabd4b384a4fcb61...d5139fad36a14607e75cca0867783eb05e877834 -- View it on GitLab: https://gitlab.com/mailman/mailman/-/compare/576407f2ba024b4b05466127aabd4b384a4fcb61...d5139fad36a14607e75cca0867783eb05e877834 You're receiving this email because of your account on gitlab.com.
_______________________________________________ Mailman-checkins mailing list -- mailman-checkins@python.org To unsubscribe send an email to mailman-checkins-le...@python.org https://mail.python.org/mailman3/lists/mailman-checkins.python.org/ Member address: arch...@jab.org