view MoinMoin/script/maint/ @ 3080:7dcd8b937fd0

small fixes to i18n maintainer mailings script and text (ported from 1.6 and updated for 1.7)
author Thomas Waldmann <tw AT waldmann-edv DOT de>
date Fri, 22 Feb 2008 22:46:10 +0100
parents 75f431e6d632
children 2572688e031a
line wrap: on
line source

# -*- coding: iso-8859-1 -*-
    MoinMoin - mailtranslators script
    read mail text from standard input and send an email to all translators -
    %(lang)s will be replaced by language.

    Usage: moin ... maint mailtranslators
    @copyright: 2004-2007 MoinMoin:ThomasWaldmann
    @license: GPL, see COPYING for details

import sys, os

from MoinMoin import config, i18n
from MoinMoin.mail.sendmail import sendmail
from MoinMoin.script import MoinScript

class PluginScript(MoinScript):
    def __init__(self, argv, def_values):
        MoinScript.__init__(self, argv, def_values)
            "-f", "--from-address", dest="from_address",
            help="use as from: for email."
            "-s", "--subject", dest="subject",
            help="use as subject: for email."

    def mainloop(self):
        request = self.request
        request.form = request.args = request.setup_args()

        from_address = unicode(self.options.from_address or "")
        subject = unicode(self.options.subject or "MoinMoin i18n notification")
        text_template = unicode(

        languages = i18n.wikiLanguages()
        langs = languages.keys()
        langs.remove('en') # nothing to do for english, so remove it
        #langs = ['de', ] # for testing

        if len(text_template) > 10: # do not send mails w/o real content
            for lang in langs:
                to_address = languages[lang]['last-translator']
                rc = None
                if to_address and '***vacant***' not in to_address:
                    text = text_template % locals()
                    rc = sendmail(request, [to_address], subject, text, mail_from=from_address)
                    print lang, repr(from_address), repr(to_address), subject, repr(rc)