view MoinMoin/macro/StatsChart.py @ 51:54d5932d5a03

merge moin--main--1.3--patch-930: fix error handling in plugins, fix broken chart action Patches applied: * arch@arch.thinkmo.de--2003-archives/moin--main--1.3--patch-930 fix error handling in plugins, fix broken chart action * nirs@freeshell.org--2005/moin--fix--1.3--patch-50 merge from main * nirs@freeshell.org--2005/moin--fix--1.3--patch-51 fix error handling in plugins * nirs@freeshell.org--2005/moin--fix--1.3--patch-52 merge from main * nirs@freeshell.org--2005/moin--fix--1.3--patch-53 update changes with chart action fix imported from: moin--main--1.5--patch-52
author Nir Soffer <nirs@freeshell.org>
date Thu, 29 Sep 2005 00:36:27 +0000
parents 77665d8e2254
children bb2e053067fb
line wrap: on
line source
# -*- coding: iso-8859-1 -*-
"""
    MoinMoin - StatsChart Macro

    This macro creates charts from the data in "event.log".

    @copyright: 2002-2004 by Jürgen Hermann <jh@web.de>
    @license: GNU GPL, see COPYING for details.
"""

from MoinMoin.util import pysupport

Dependencies = ["time24:00"]

def execute(macro, args, **kw):
    _ = macro.request.getText
    formatter = macro.request.formatter

    if not args:
        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")
    except ImportError:
        return (formatter.sysmsg(1) +
                formatter.text(_('Bad chart type "%s"!') % args) +
                formatter.sysmsg(0))

    return func(macro.formatter.page.page_name, macro.request)