changeset 3242:924a9abe5689

macros: refactored for 1.7 arg parser
author Thomas Waldmann <tw AT waldmann-edv DOT de>
date Tue, 11 Mar 2008 22:46:26 +0100
parents 03b3c6fd70e3
children 1ad6243cdf06
files MoinMoin/macro/StatsChart.py MoinMoin/macro/SystemInfo.py MoinMoin/macro/Verbatim.py
diffstat 3 files changed, 10 insertions(+), 11 deletions(-) [+]
line wrap: on
line diff
--- a/MoinMoin/macro/StatsChart.py	Tue Mar 11 00:04:39 2008 +0100
+++ b/MoinMoin/macro/StatsChart.py	Tue Mar 11 22:46:26 2008 +0100
@@ -12,21 +12,21 @@
 
 Dependencies = ["time24:00"]
 
-def execute(macro, args, **kw):
+def macro_StatsChart(macro, chart_type=''):
     _ = macro.request.getText
     formatter = macro.request.formatter
 
-    if not args:
+    if not chart_type:
         return (formatter.sysmsg(1) +
                 formatter.text(_('You need to provide a chart type!')) +
                 formatter.sysmsg(0))
 
     try:
         # stats module without 'linkto' will raise AttributeError
-        func = pysupport.importName("MoinMoin.stats." + args, "linkto")
+        func = pysupport.importName("MoinMoin.stats.%s" % chart_type, "linkto")
     except ImportError:
         return (formatter.sysmsg(1) +
-                formatter.text(_('Bad chart type "%s"!') % args) +
+                formatter.text(_('Bad chart type "%s"!') % chart_type) +
                 formatter.sysmsg(0))
 
     return func(macro.formatter.page.page_name, macro.request)
--- a/MoinMoin/macro/SystemInfo.py	Tue Mar 11 00:04:39 2008 +0100
+++ b/MoinMoin/macro/SystemInfo.py	Tue Mar 11 22:46:26 2008 +0100
@@ -4,7 +4,7 @@
 
     This macro shows some info about your wiki, wiki software and your system.
 
-    @copyright: 2006 MoinMoin:ThomasWaldmann,
+    @copyright: 2006-2008 MoinMoin:ThomasWaldmann,
                 2007 MoinMoin:ReimarBauer
     @license: GNU GPL, see COPYING for details.
 """
@@ -20,11 +20,10 @@
 from MoinMoin.Page import Page
 
 class SystemInfo:
-    def __init__(self, macro, args):
+    def __init__(self, macro):
         self.macro = macro
         self.request = macro.request
         self.formatter = macro.formatter
-        self.args = args
 
     def formatInReadableUnits(self, size):
         size = float(size)
@@ -180,8 +179,8 @@
 
         return buf.getvalue()
 
-def execute(macro, args):
+def macro_SystemInfo(macro):
     if macro.request.isSpiderAgent: # reduce bot cpu usage
         return ''
-    return SystemInfo(macro, args).render()
+    return SystemInfo(macro).render()
 
--- a/MoinMoin/macro/Verbatim.py	Tue Mar 11 00:04:39 2008 +0100
+++ b/MoinMoin/macro/Verbatim.py	Tue Mar 11 22:46:26 2008 +0100
@@ -8,5 +8,5 @@
 
 Dependencies = []
 
-def execute(macro, args):
-    return macro.formatter.escapedText(args)
+def macro_Verbatim(macro, text=u''):
+    return macro.formatter.escapedText(text)