~mailman-coders/mailman/2.1

« back to all changes in this revision

Viewing changes to cron/senddigests

  • Committer: Mark Sapiro
  • Date: 2016-09-02 18:54:08 UTC
  • Revision ID: mark@msapiro.net-20160902185408-mlbhu8l64z411pz3
Added -e/--exceptlist to cron/senddigests.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
#! @PYTHON@
2
2
#
3
 
# Copyright (C) 1998-2007 by the Free Software Foundation, Inc.
 
3
# Copyright (C) 1998-2016 by the Free Software Foundation, Inc.
4
4
#
5
5
# This program is free software; you can redistribute it and/or
6
6
# modify it under the terms of the GNU General Public License
28
28
    -l listname
29
29
    --listname=listname
30
30
        Send the digest for the given list only, otherwise the digests for all
31
 
        lists are sent out.
 
31
        lists are sent out.  May be repeated to do multiple lists.
 
32
 
 
33
    -e listname
 
34
    --exceptlist listname
 
35
        Don't send the digest for the given list.  May be repeated to skip
 
36
        multiple lists.
32
37
"""
33
38
 
34
39
import os
63
68
 
64
69
def main():
65
70
    try:
66
 
        opts, args = getopt.getopt(sys.argv[1:], 'hl:', ['help', 'listname='])
 
71
        opts, args = getopt.getopt(sys.argv[1:], 'hl:e:',
 
72
                                   ['help', 'listname=', 'exceptlist='])
67
73
    except getopt.error, msg:
68
74
        usage(1, msg)
69
75
 
70
76
    if args:
71
77
        usage(1)
72
78
 
 
79
    exceptlists = []
73
80
    listnames = []
74
81
    for opt, arg in opts:
75
82
        if opt in ('-h', '--help'):
76
83
            usage(0)
77
84
        elif opt in ('-l', '--listname'):
78
85
            listnames.append(arg)
 
86
        elif opt in ('-e', '--exceptlist'):
 
87
            exceptlists.append(arg)
79
88
 
80
89
    if not listnames:
81
90
        listnames = Utils.list_names()
 
91
    for listname in exceptlists:
 
92
        try:
 
93
            listnames.remove(listname)
 
94
        except ValueError:
 
95
            pass
82
96
 
83
97
    for listname in listnames:
84
98
        mlist = MailList.MailList(listname, lock=0)