diff options
| author | Barry Warsaw | 2009-11-24 23:36:14 -0500 |
|---|---|---|
| committer | Barry Warsaw | 2009-11-24 23:36:14 -0500 |
| commit | a26ed5b02a76dd26a72eb8acad819be47dca3049 (patch) | |
| tree | 916a3a0cacd895519e891cef83930e01c6f3503c /src/mailman/commands/cli_members.py | |
| parent | 79d9e36a0b824548a0f2bc83cb948fc5ce668151 (diff) | |
| download | mailman-a26ed5b02a76dd26a72eb8acad819be47dca3049.tar.gz mailman-a26ed5b02a76dd26a72eb8acad819be47dca3049.tar.zst mailman-a26ed5b02a76dd26a72eb8acad819be47dca3049.zip | |
Diffstat (limited to 'src/mailman/commands/cli_members.py')
| -rw-r--r-- | src/mailman/commands/cli_members.py | 21 |
1 files changed, 16 insertions, 5 deletions
diff --git a/src/mailman/commands/cli_members.py b/src/mailman/commands/cli_members.py index b26216785..213bb7a2c 100644 --- a/src/mailman/commands/cli_members.py +++ b/src/mailman/commands/cli_members.py @@ -37,7 +37,7 @@ from mailman.config import config from mailman.core.i18n import _ from mailman.interfaces.command import ICLISubCommand from mailman.interfaces.listmanager import IListManager -from mailman.interfaces.member import DeliveryMode +from mailman.interfaces.member import AlreadySubscribedError, DeliveryMode @@ -53,8 +53,10 @@ class Members: command_parser.add_argument( '-a', '--add', dest='filename', - help=_('Add all member addresses in FILENAME. FILENAME can be ' - "'-' to indicate standard input.")) + help=_("""\ + Add all member addresses in FILENAME. FILENAME can be '-' to + indicate standard input. Blank lines and lines That start with a + '#' are ignored.""")) # Required positional argument. command_parser.add_argument( 'listname', metavar='LISTNAME', nargs=1, @@ -78,14 +80,23 @@ class Members: fp = codecs.open(args.filename, 'r', 'utf-8') try: for line in fp: + # Ignore blank lines and lines that start with a '#'. + if line.startswith('#') or len(line.strip()) == 0: + continue real_name, email = parseaddr(line) # If not given in the input data, parseaddr() will return the # empty string, as opposed to the empty unicode. We need a # unicode real name here. if real_name == '': real_name = u'' - add_member(mlist, email, real_name, None, - DeliveryMode.regular, mlist.preferred_language.code) + try: + add_member(mlist, email, real_name, None, + DeliveryMode.regular, + mlist.preferred_language.code) + except AlreadySubscribedError: + # It's okay if the address is already subscribed, just + # print a warning and continue. + print 'Already subscribed (skipping):', email, real_name finally: if fp is not sys.stdin: fp.close() |
