Back to index

moin  1.9.0~rc2
Public Member Functions | Public Attributes
MoinMoin.script.maint.mailtranslators.PluginScript Class Reference
Inheritance diagram for MoinMoin.script.maint.mailtranslators.PluginScript:
Inheritance graph
[legend]
Collaboration diagram for MoinMoin.script.maint.mailtranslators.PluginScript:
Collaboration graph
[legend]

List of all members.

Public Member Functions

def __init__
def mainloop
def init_request
def run
def logRuntime

Public Attributes

 request
 argv
 def_values
 parser
 args

Detailed Description

\
Purpose:
========
This tool allows you to have a message read in from standard input, and
then sent to all translators via email. If you use %(lang)s in the message
it will be replaced with the appropriate language code for the translator.

Detailed Instructions:
======================
General syntax: moin [options] maint mailtranslators [mailtranslators-options]

[options] usually should be:
--config-dir=/path/to/my/cfg/ --wiki-url=wiki.example.org/

[mailtranslators-options] see below:
0. To send an email to all translaters, from john@smith.com, and with a subject
   of 'Please update your translations!' and a body of 'Please update your language,
   %(lang)s'
   moin ... maint mailtranslators --from-address john@smith.com --subject 'Please update your translations!'
   Please update your language, %(lang)s
   ^D

Definition at line 15 of file mailtranslators.py.


Constructor & Destructor Documentation

def MoinMoin.script.maint.mailtranslators.PluginScript.__init__ (   self,
  argv,
  def_values 
)

Reimplemented from MoinMoin.script.MoinScript.

Definition at line 39 of file mailtranslators.py.

00039 
00040     def __init__(self, argv, def_values):
00041         MoinScript.__init__(self, argv, def_values)
00042         self.parser.add_option(
00043             "-f", "--from-address", dest="from_address",
00044             help="use as from: for email."
00045         )
00046         self.parser.add_option(
00047             "-s", "--subject", dest="subject",
00048             help="use as subject: for email."
00049         )


Member Function Documentation

def MoinMoin.script.MoinScript.init_request (   self) [inherited]
create request 

Definition at line 174 of file __init__.py.

00174 
00175     def init_request(self):
00176         """ create request """
00177         from MoinMoin.web.contexts import ScriptContext
00178         url = self.options.wiki_url or None
00179         self.request = ScriptContext(url, self.options.page)

Here is the caller graph for this function:

def MoinMoin.script.Script.logRuntime (   self) [inherited]
Print the total command run time. 

Definition at line 148 of file __init__.py.

00148 
00149     def logRuntime(self):
00150         """ Print the total command run time. """
00151         if self.options.show_timing:
00152             log("Needed %.3f secs." % (time.clock() - _start_time, ))
00153 

Here is the call graph for this function:

Reimplemented from MoinMoin.script.MoinScript.

Definition at line 50 of file mailtranslators.py.

00050 
00051     def mainloop(self):
00052         self.init_request()
00053         request = self.request
00054 
00055         from_address = unicode(self.options.from_address or "tw-public@gmx.de")
00056         subject = unicode(self.options.subject or "MoinMoin i18n notification")
00057         text_template = unicode(sys.stdin.read())
00058 
00059         languages = i18n.wikiLanguages()
00060         langs = languages.keys()
00061         langs.remove('en') # nothing to do for english, so remove it
00062         #langs = ['de', ] # for testing
00063 
00064         if len(text_template) > 10: # do not send mails w/o real content
00065             for lang in langs:
00066                 to_address = languages[lang]['last-translator']
00067                 rc = None
00068                 if to_address and '***vacant***' not in to_address:
00069                     text = text_template % locals()
00070                     rc = sendmail(request, [to_address], subject, text, mail_from=from_address)
00071                     print lang, repr(from_address), repr(to_address), subject, repr(rc)
00072 

Here is the call graph for this function:

def MoinMoin.script.Script.run (   self,
  showtime = 1 
) [inherited]
Run the main function of a command. 

Definition at line 130 of file __init__.py.

00130 
00131     def run(self, showtime=1):
00132         """ Run the main function of a command. """
00133         global flag_quiet
00134         try:
00135             try:
00136                 self.options, self.args = self.parser.parse_args(self.argv)
00137                 flag_quiet = self.options.quiet
00138                 # ToDo check if we need to initialize request (self.init_request())
00139                 self.mainloop()
00140             except KeyboardInterrupt:
00141                 log("*** Interrupted by user!")
00142             except SystemExit:
00143                 showtime = 0
00144                 raise
00145         finally:
00146             if showtime:
00147                 self.logRuntime()

Here is the caller graph for this function:


Member Data Documentation

Definition at line 135 of file __init__.py.

Definition at line 102 of file __init__.py.

Definition at line 113 of file __init__.py.

Definition at line 178 of file __init__.py.


The documentation for this class was generated from the following file: