This file is indexed.

/usr/share/pyshared/MoinMoin/stats/chart.py is in python-moinmoin 1.9.3-1ubuntu2.3.

This file is owned by root:root, with mode 0o644.

The actual contents of the file can be viewed below.

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
# -*- coding: iso-8859-1 -*-
"""
    MoinMoin - Charts

    This is a wrapper for the "gdchart" module.

    Example:
        import random
        c = Chart()
        c.addData(ChartData([random.gauss(0, 5.0) for i in range(20)], color='blue'))
        c.option(title = 'gdchart Demo')
        c.draw(Chart.GDC_LINE, (600, 300), 'test.gif')

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

import gdchart
from MoinMoin.util.web import Color


class ChartData:
    """ Data set for one line in a chart, including
        properties like the color of that line.
    """
    def __init__(self, data, color='black'):
        """
        Create a data set.

        @param data: tuple / list of numbers
        @param color: rendering color (triple, '#RRGGBB' or color name)
        """
        self.data = data
        self.color = color


class Chart:
    """ Wrapper for "gdchart".

        All GDC* constants are available as class attributes.
    """

    DEFAULTS = gdchart.option()

    def __init__(self):
        # Get a copy of the default options
        self.options = self.DEFAULTS.copy()
        self.datasets = []

        self.option(
            bg_color=0xffffff,
            line_color=0x000000,
        )

    def addData(self, data):
        self.datasets.append(data)

    def option(self, **args):
        # Save option values in the object's dictionary.
        self.options.update(args)

    def draw(self, style, size, output, labels=None):
        args = []
        colors = []
        for dataset in self.datasets:
            if isinstance(dataset, ChartData):
                args.append(dataset.data)
                colors.append(dataset.color)
            else:
                args.append(dataset)
                colors.append('black')

        # Default for X axis labels (numbered 1..n)
        if not labels:
            labels = [str(i) for i in range(1, len(args[0])+1)]

        # set colors for the data sets
        if colors:
            self.option(set_color=[int(Color(c)) for c in colors])

        # pass options to gdchart and render the chart
        gdchart.option(**self.options)

        # limit label length in order to workaround bugs in gdchart
        labels = [x[:32] for x in labels]
        gdchart.chart(*((style, size, output, labels) + tuple(args)))


# copy GDC constants to Chart's namespace
for key, val in vars(gdchart).items():
    if key.startswith('GDC'):
        setattr(Chart, key, val)


if __name__ == "__main__":
    import os, sys, random
    c = Chart()
    c.addData(ChartData([random.randrange(0, i+1) for i in range(20)], color='green'))
    c.addData(ChartData([random.gauss(30, 5.0) for i in range(20)], color='blue'))
    c.option(
        title='gdchart Demo',
        xtitle='X axis',
        ytitle='random values',
    )
    c.draw(Chart.GDC_LINE, (600, 300), 'test.gif')
    if sys.platform == "win32":
        os.system("explorer test.gif")
    else:
        os.system("display test.gif &")