summaryrefslogtreecommitdiff
path: root/mailman/bin/list_lists.py
diff options
context:
space:
mode:
authorBarry Warsaw2008-02-27 01:26:18 -0500
committerBarry Warsaw2008-02-27 01:26:18 -0500
commita1c73f6c305c7f74987d99855ba59d8fa823c253 (patch)
tree65696889450862357c9e05c8e9a589f1bdc074ac /mailman/bin/list_lists.py
parent3f31f8cce369529d177cfb5a7c66346ec1e12130 (diff)
downloadmailman-a1c73f6c305c7f74987d99855ba59d8fa823c253.tar.gz
mailman-a1c73f6c305c7f74987d99855ba59d8fa823c253.tar.zst
mailman-a1c73f6c305c7f74987d99855ba59d8fa823c253.zip
Diffstat (limited to 'mailman/bin/list_lists.py')
-rw-r--r--mailman/bin/list_lists.py105
1 files changed, 105 insertions, 0 deletions
diff --git a/mailman/bin/list_lists.py b/mailman/bin/list_lists.py
new file mode 100644
index 000000000..2bd85a947
--- /dev/null
+++ b/mailman/bin/list_lists.py
@@ -0,0 +1,105 @@
+# Copyright (C) 1998-2008 by the Free Software Foundation, Inc.
+#
+# This program 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 2
+# of the License, or (at your option) any later version.
+#
+# This program 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 this program; if not, write to the Free Software
+# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
+# USA.
+
+import optparse
+
+from mailman import Defaults
+from mailman import Version
+from mailman.configuration import config
+from mailman.i18n import _
+from mailman.initialize import initialize
+
+
+
+def parseargs():
+ parser = optparse.OptionParser(version=Version.MAILMAN_VERSION,
+ usage=_("""\
+%prog [options]
+
+List all mailing lists."""))
+ parser.add_option('-a', '--advertised',
+ default=False, action='store_true',
+ help=_("""\
+List only those mailing lists that are publicly advertised"""))
+ parser.add_option('-b', '--bare',
+ default=False, action='store_true',
+ help=_("""\
+Displays only the list name, with no description."""))
+ parser.add_option('-d', '--domain',
+ default=[], type='string', action='append',
+ dest='domains', help=_("""\
+List only those mailing lists that match the given virtual domain, which may
+be either the email host or the url host name. Multiple -d options may be
+given."""))
+ parser.add_option('-f', '--full',
+ default=False, action='store_true',
+ help=_("""\
+Print the full list name, including the posting address."""))
+ parser.add_option('-C', '--config',
+ help=_('Alternative configuration file to use'))
+ opts, args = parser.parse_args()
+ if args:
+ parser.print_help()
+ parser.error(_('Unexpected arguments'))
+ return parser, opts, args
+
+
+
+def main():
+ parser, opts, args = parseargs()
+ initialize(opts.config)
+
+ mlists = []
+ longest = 0
+
+ listmgr = config.db.list_manager
+ for fqdn_name in sorted(listmgr.names):
+ mlist = listmgr.get(fqdn_name)
+ if opts.advertised and not mlist.advertised:
+ continue
+ if opts.domains:
+ for domain in opts.domains:
+ if domain in mlist.web_page_url or domain == mlist.host_name:
+ mlists.append(mlist)
+ break
+ else:
+ mlists.append(mlist)
+ if opts.full:
+ name = mlist.fqdn_listname
+ else:
+ name = mlist.real_name
+ longest = max(len(name), longest)
+
+ if not mlists and not opts.bare:
+ print _('No matching mailing lists found')
+ return
+
+ if not opts.bare:
+ num_mlists = len(mlists)
+ print _('$num_mlists matching mailing lists found:')
+
+ format = '%%%ds - %%.%ds' % (longest, 77 - longest)
+ for mlist in mlists:
+ if opts.full:
+ name = mlist.fqdn_listname
+ else:
+ name = mlist.real_name
+ if opts.bare:
+ print name
+ else:
+ description = mlist.description or _('[no description available]')
+ print ' ', format % (name, description)