Back to index

moin  1.9.0~rc2
StatsChart.py
Go to the documentation of this file.
00001 # -*- coding: iso-8859-1 -*-
00002 """
00003     MoinMoin - StatsChart Macro
00004 
00005     This macro creates charts from the data in "event.log".
00006 
00007     @copyright: 2002-2004 Juergen Hermann <jh@web.de>
00008     @license: GNU GPL, see COPYING for details.
00009 """
00010 
00011 from MoinMoin.util import pysupport
00012 
00013 Dependencies = ["time24:00"]
00014 
00015 def macro_StatsChart(macro, chart_type=''):
00016     _ = macro.request.getText
00017     formatter = macro.request.formatter
00018 
00019     if not chart_type:
00020         return (formatter.sysmsg(1) +
00021                 formatter.text(_('You need to provide a chart type!')) +
00022                 formatter.sysmsg(0))
00023 
00024     try:
00025         # stats module without 'linkto' will raise AttributeError
00026         func = pysupport.importName("MoinMoin.stats.%s" % chart_type, "linkto")
00027     except ImportError:
00028         return (formatter.sysmsg(1) +
00029                 formatter.text(_('Bad chart type "%s"!') % chart_type) +
00030                 formatter.sysmsg(0))
00031 
00032     return func(macro.formatter.page.page_name, macro.request)
00033