summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorbwarsaw2000-12-26 16:52:39 +0000
committerbwarsaw2000-12-26 16:52:39 +0000
commit97643acdcc1bdfd2812415041073b7f7d129e20f (patch)
tree040f9f0beb16ef1bc633977689b1c01b98684011
parentc5f9b7818cb6d5ec6ba0276573441019f7cdd300 (diff)
downloadmailman-97643acdcc1bdfd2812415041073b7f7d129e20f.tar.gz
mailman-97643acdcc1bdfd2812415041073b7f7d129e20f.tar.zst
mailman-97643acdcc1bdfd2812415041073b7f7d129e20f.zip
intermediate
Diffstat (limited to '')
-rw-r--r--bin/rmlang115
1 files changed, 115 insertions, 0 deletions
diff --git a/bin/rmlang b/bin/rmlang
new file mode 100644
index 000000000..1dbef1902
--- /dev/null
+++ b/bin/rmlang
@@ -0,0 +1,115 @@
+#! /usr/bin/env python
+#
+# Copyright (C) 2000 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+
+"""Remove language[s] support to a mailing list.
+
+Usage:
+
+ rmlang [options] code1 code2 ...
+
+Options:
+
+ --help/-h
+ Print this message and exit.
+
+ --listname=listname
+ -l listname
+ The name of the mailing list to remove the language support from.
+
+code must exist in list._template_dir as a directory. code corresponding to
+mm_cfg.DEFAULT_SERVER_LANGUAGE can not be removed.
+"""
+
+import sys
+import os
+import getopt
+
+import paths # path hacking
+from Mailman import mm_cfg
+from Mailman import Utils
+from Mailman import MailList
+from Mailman.HTMLFormatter import HTMLFormatter
+from Mailman.i18n import _
+
+
+
+def usage(code, msg=''):
+ print >> sys.stderr, _(__doc__)
+ if msg:
+ print >> sys.stderr, msg
+ sys.exit(code)
+
+
+
+def remove_it(listname, dir, msg):
+ if os.path.islink(dir):
+ print _('Removing'), msg
+ os.unlink(dir)
+ elif os.path.exists(dir):
+ print _('Removing'), msg
+ os.system('rm -rf ' + dir)
+ else:
+ print listname, msg, _('not found as'), dir
+
+
+
+def main():
+ try:
+ opts, args = getopt.getopt(sys.argv[1:], 'l:h',
+ ['listname=', 'help'])
+ except getopt.error, msg:
+ usage(1, msg)
+
+ listname = None
+ for opt, arg in opts:
+ if opt in ('-h', '--help'):
+ usage(0)
+ elif opt in ('-l', '--listname'):
+ listname = arg
+
+ languages = args
+ if listname is None:
+ usage(1, _('--listname/-l is required'))
+ if not languages:
+ usage(1, _('no languages given'))
+
+ listname = listname.lower()
+ try:
+ mlist = MailList.MailList(listname)
+ except Errors.MMListError, e:
+ usage(1, _('Could not open mailing list: %(listname)s\n%(e)s'))
+
+ # BAW: hmm... same question as with newlist
+ HTMLFormatter.InitVars(list)
+
+ for lang in languages:
+ dir = os.path.join(list._template_dir, lang)
+ if lang == mm_cfg.DEFAULT_SERVER_LANGUAGE:
+ print >> sys.stderr, _('%(lang)s is the server default language '
+ 'and cannot be removed')
+ continue
+ if not os.path.exists(dir):
+ print >> sys.stderr, _('Language %(lang)s not supported by list')
+ continue
+
+ remove_it(listname, directory, _('language support for %(lang)s'))
+
+
+
+if __name__ == '__main__':
+ main()