annotate data/plugin/macro/DataRevPlot.py @ 653:127da830be6c

updated copyright
author Reimar Bauer <rb.proj AT googlemail DOT com>
date Tue, 19 Apr 2016 16:29:54 +0200
parents 6e5f50c5855f
children
rev   line source
464
328f45d3937e macro.DataRevPlot: macro to graph data by svgfig extracted from revisions of the page where it is called from
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
1 # -*- coding: iso-8859-1 -*-
328f45d3937e macro.DataRevPlot: macro to graph data by svgfig extracted from revisions of the page where it is called from
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
2 """
328f45d3937e macro.DataRevPlot: macro to graph data by svgfig extracted from revisions of the page where it is called from
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
3 MoinMoin - DataRevPlot Macro
328f45d3937e macro.DataRevPlot: macro to graph data by svgfig extracted from revisions of the page where it is called from
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
4
328f45d3937e macro.DataRevPlot: macro to graph data by svgfig extracted from revisions of the page where it is called from
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
5 This macro is a used to graph by
328f45d3937e macro.DataRevPlot: macro to graph data by svgfig extracted from revisions of the page where it is called from
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
6 http://code.google.com/p/svgfig/
328f45d3937e macro.DataRevPlot: macro to graph data by svgfig extracted from revisions of the page where it is called from
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
7 data of all revisions from a table
328f45d3937e macro.DataRevPlot: macro to graph data by svgfig extracted from revisions of the page where it is called from
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
8 on the page where it is called from.
328f45d3937e macro.DataRevPlot: macro to graph data by svgfig extracted from revisions of the page where it is called from
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
9
653
127da830be6c updated copyright
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 467
diff changeset
10 @copyright: 2009-2016 MoinMoin:ReimarBauer
464
328f45d3937e macro.DataRevPlot: macro to graph data by svgfig extracted from revisions of the page where it is called from
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
11 @license: GNU GPL, see COPYING for details.
328f45d3937e macro.DataRevPlot: macro to graph data by svgfig extracted from revisions of the page where it is called from
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
12 """
328f45d3937e macro.DataRevPlot: macro to graph data by svgfig extracted from revisions of the page where it is called from
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
13 import re, svgfig
328f45d3937e macro.DataRevPlot: macro to graph data by svgfig extracted from revisions of the page where it is called from
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
14 from MoinMoin import wikiutil
328f45d3937e macro.DataRevPlot: macro to graph data by svgfig extracted from revisions of the page where it is called from
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
15 from MoinMoin.Page import Page
328f45d3937e macro.DataRevPlot: macro to graph data by svgfig extracted from revisions of the page where it is called from
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
16 from MoinMoin.action import cache
328f45d3937e macro.DataRevPlot: macro to graph data by svgfig extracted from revisions of the page where it is called from
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
17
328f45d3937e macro.DataRevPlot: macro to graph data by svgfig extracted from revisions of the page where it is called from
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
18 # svg frame sizes
328f45d3937e macro.DataRevPlot: macro to graph data by svgfig extracted from revisions of the page where it is called from
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
19 svgfig._canvas_defaults["width"] = '400px'
328f45d3937e macro.DataRevPlot: macro to graph data by svgfig extracted from revisions of the page where it is called from
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
20 svgfig._canvas_defaults["height"] = '400px'
328f45d3937e macro.DataRevPlot: macro to graph data by svgfig extracted from revisions of the page where it is called from
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
21
328f45d3937e macro.DataRevPlot: macro to graph data by svgfig extracted from revisions of the page where it is called from
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
22
328f45d3937e macro.DataRevPlot: macro to graph data by svgfig extracted from revisions of the page where it is called from
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
23 class DictBase(dict):
328f45d3937e macro.DataRevPlot: macro to graph data by svgfig extracted from revisions of the page where it is called from
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
24 """ Base class for wiki dicts
328f45d3937e macro.DataRevPlot: macro to graph data by svgfig extracted from revisions of the page where it is called from
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
25
328f45d3937e macro.DataRevPlot: macro to graph data by svgfig extracted from revisions of the page where it is called from
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
26 To use this class, subclass it and override regex and initFromText.
328f45d3937e macro.DataRevPlot: macro to graph data by svgfig extracted from revisions of the page where it is called from
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
27
328f45d3937e macro.DataRevPlot: macro to graph data by svgfig extracted from revisions of the page where it is called from
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
28 @copyright: 2003-2007 MoinMoin:ThomasWaldmann,
328f45d3937e macro.DataRevPlot: macro to graph data by svgfig extracted from revisions of the page where it is called from
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
29 2003 by Gustavo Niemeyer
328f45d3937e macro.DataRevPlot: macro to graph data by svgfig extracted from revisions of the page where it is called from
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
30 """
328f45d3937e macro.DataRevPlot: macro to graph data by svgfig extracted from revisions of the page where it is called from
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
31 def __init__(self, request=None, pagename=None, rev=0):
328f45d3937e macro.DataRevPlot: macro to graph data by svgfig extracted from revisions of the page where it is called from
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
32 dict.__init__(self)
328f45d3937e macro.DataRevPlot: macro to graph data by svgfig extracted from revisions of the page where it is called from
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
33 self.name = None
328f45d3937e macro.DataRevPlot: macro to graph data by svgfig extracted from revisions of the page where it is called from
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
34 if request is not None and pagename is not None:
328f45d3937e macro.DataRevPlot: macro to graph data by svgfig extracted from revisions of the page where it is called from
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
35 self.loadFromPage(request, pagename, rev=rev)
328f45d3937e macro.DataRevPlot: macro to graph data by svgfig extracted from revisions of the page where it is called from
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
36
328f45d3937e macro.DataRevPlot: macro to graph data by svgfig extracted from revisions of the page where it is called from
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
37 # Regular expression used to parse text - subclass must override this
328f45d3937e macro.DataRevPlot: macro to graph data by svgfig extracted from revisions of the page where it is called from
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
38 regex = None # re.compile(u'...', re.MULTILINE | re.UNICODE)
328f45d3937e macro.DataRevPlot: macro to graph data by svgfig extracted from revisions of the page where it is called from
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
39
328f45d3937e macro.DataRevPlot: macro to graph data by svgfig extracted from revisions of the page where it is called from
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
40 def loadFromPage(self, request, name, rev=0):
328f45d3937e macro.DataRevPlot: macro to graph data by svgfig extracted from revisions of the page where it is called from
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
41 """ load the dict from wiki page <name>'s content """
328f45d3937e macro.DataRevPlot: macro to graph data by svgfig extracted from revisions of the page where it is called from
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
42 self.name = name
328f45d3937e macro.DataRevPlot: macro to graph data by svgfig extracted from revisions of the page where it is called from
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
43 text = Page(request, name, rev=rev).get_raw_body()
328f45d3937e macro.DataRevPlot: macro to graph data by svgfig extracted from revisions of the page where it is called from
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
44 self.initFromText(text)
328f45d3937e macro.DataRevPlot: macro to graph data by svgfig extracted from revisions of the page where it is called from
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
45
328f45d3937e macro.DataRevPlot: macro to graph data by svgfig extracted from revisions of the page where it is called from
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
46 def initFromText(self, text):
328f45d3937e macro.DataRevPlot: macro to graph data by svgfig extracted from revisions of the page where it is called from
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
47 """ parse the wiki page text and init the dict from it """
328f45d3937e macro.DataRevPlot: macro to graph data by svgfig extracted from revisions of the page where it is called from
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
48 raise NotImplementedError('subclasses should override this')
328f45d3937e macro.DataRevPlot: macro to graph data by svgfig extracted from revisions of the page where it is called from
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
49
328f45d3937e macro.DataRevPlot: macro to graph data by svgfig extracted from revisions of the page where it is called from
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
50 class Dict(DictBase):
328f45d3937e macro.DataRevPlot: macro to graph data by svgfig extracted from revisions of the page where it is called from
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
51 """ Mapping of keys to values from a wiki page.
328f45d3937e macro.DataRevPlot: macro to graph data by svgfig extracted from revisions of the page where it is called from
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
52
328f45d3937e macro.DataRevPlot: macro to graph data by svgfig extracted from revisions of the page where it is called from
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
53 = Tue Dec 15 23:30:01 CET 2009 =
328f45d3937e macro.DataRevPlot: macro to graph data by svgfig extracted from revisions of the page where it is called from
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
54 ||<tableclass="sortable" bgcolor="#cccccc"> order || GB || user || graph||
328f45d3937e macro.DataRevPlot: macro to graph data by svgfig extracted from revisions of the page where it is called from
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
55 ||<bgcolor="#cccccc"> 1 || 70 || usera || <<SvgWsStats(parameter=usera)>> ||
328f45d3937e macro.DataRevPlot: macro to graph data by svgfig extracted from revisions of the page where it is called from
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
56 ||<bgcolor="#cccccc"> 2 || 10 || userb || <<SvgWsStats(parameter=userb)>> ||
328f45d3937e macro.DataRevPlot: macro to graph data by svgfig extracted from revisions of the page where it is called from
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
57
328f45d3937e macro.DataRevPlot: macro to graph data by svgfig extracted from revisions of the page where it is called from
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
58 @copyright: 2003-2007 MoinMoin:ThomasWaldmann,
328f45d3937e macro.DataRevPlot: macro to graph data by svgfig extracted from revisions of the page where it is called from
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
59 2003 by Gustavo Niemeyer
328f45d3937e macro.DataRevPlot: macro to graph data by svgfig extracted from revisions of the page where it is called from
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
60 2009 by MoinMoin:ReimarBauer
328f45d3937e macro.DataRevPlot: macro to graph data by svgfig extracted from revisions of the page where it is called from
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
61 """
328f45d3937e macro.DataRevPlot: macro to graph data by svgfig extracted from revisions of the page where it is called from
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
62 # only data from the table line is extracted
328f45d3937e macro.DataRevPlot: macro to graph data by svgfig extracted from revisions of the page where it is called from
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
63 regex = re.compile(ur'\|\| (?P<value>\w*?) \|\| (?P<key>\w*?)\s|$',
328f45d3937e macro.DataRevPlot: macro to graph data by svgfig extracted from revisions of the page where it is called from
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
64 re.MULTILINE | re.UNICODE)
328f45d3937e macro.DataRevPlot: macro to graph data by svgfig extracted from revisions of the page where it is called from
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
65
328f45d3937e macro.DataRevPlot: macro to graph data by svgfig extracted from revisions of the page where it is called from
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
66 def initFromText(self, text):
328f45d3937e macro.DataRevPlot: macro to graph data by svgfig extracted from revisions of the page where it is called from
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
67 for match in self.regex.finditer(text):
328f45d3937e macro.DataRevPlot: macro to graph data by svgfig extracted from revisions of the page where it is called from
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
68 value, key = match.groups()
328f45d3937e macro.DataRevPlot: macro to graph data by svgfig extracted from revisions of the page where it is called from
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
69 self[key] = value
328f45d3937e macro.DataRevPlot: macro to graph data by svgfig extracted from revisions of the page where it is called from
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
70
328f45d3937e macro.DataRevPlot: macro to graph data by svgfig extracted from revisions of the page where it is called from
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
71 def __repr__(self):
328f45d3937e macro.DataRevPlot: macro to graph data by svgfig extracted from revisions of the page where it is called from
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
72 return "<Dict name=%r items=%r>" % (self.name, self.items())
328f45d3937e macro.DataRevPlot: macro to graph data by svgfig extracted from revisions of the page where it is called from
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
73
328f45d3937e macro.DataRevPlot: macro to graph data by svgfig extracted from revisions of the page where it is called from
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
74 Dependencies = ['page']
328f45d3937e macro.DataRevPlot: macro to graph data by svgfig extracted from revisions of the page where it is called from
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
75
328f45d3937e macro.DataRevPlot: macro to graph data by svgfig extracted from revisions of the page where it is called from
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
76 def macro_DataRevPlot(macro,
328f45d3937e macro.DataRevPlot: macro to graph data by svgfig extracted from revisions of the page where it is called from
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
77 width=u'50px',
328f45d3937e macro.DataRevPlot: macro to graph data by svgfig extracted from revisions of the page where it is called from
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
78 height=u'50px',
328f45d3937e macro.DataRevPlot: macro to graph data by svgfig extracted from revisions of the page where it is called from
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
79 parameter=u'username'
328f45d3937e macro.DataRevPlot: macro to graph data by svgfig extracted from revisions of the page where it is called from
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
80 ):
328f45d3937e macro.DataRevPlot: macro to graph data by svgfig extracted from revisions of the page where it is called from
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
81
328f45d3937e macro.DataRevPlot: macro to graph data by svgfig extracted from revisions of the page where it is called from
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
82 request = macro.request
328f45d3937e macro.DataRevPlot: macro to graph data by svgfig extracted from revisions of the page where it is called from
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
83 pagename = request.page.page_name
328f45d3937e macro.DataRevPlot: macro to graph data by svgfig extracted from revisions of the page where it is called from
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
84 content_type = 'image/svg+xml'
328f45d3937e macro.DataRevPlot: macro to graph data by svgfig extracted from revisions of the page where it is called from
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
85 current_rev = Page(request, pagename).current_rev()
328f45d3937e macro.DataRevPlot: macro to graph data by svgfig extracted from revisions of the page where it is called from
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
86 rev_list = range(current_rev)
328f45d3937e macro.DataRevPlot: macro to graph data by svgfig extracted from revisions of the page where it is called from
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
87 rev_list.reverse()
328f45d3937e macro.DataRevPlot: macro to graph data by svgfig extracted from revisions of the page where it is called from
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
88
328f45d3937e macro.DataRevPlot: macro to graph data by svgfig extracted from revisions of the page where it is called from
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
89 # data
328f45d3937e macro.DataRevPlot: macro to graph data by svgfig extracted from revisions of the page where it is called from
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
90 y = []
328f45d3937e macro.DataRevPlot: macro to graph data by svgfig extracted from revisions of the page where it is called from
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
91 for rev in rev_list:
328f45d3937e macro.DataRevPlot: macro to graph data by svgfig extracted from revisions of the page where it is called from
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
92 try:
328f45d3937e macro.DataRevPlot: macro to graph data by svgfig extracted from revisions of the page where it is called from
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
93 page_dict = Dict(request, pagename, rev=rev)
328f45d3937e macro.DataRevPlot: macro to graph data by svgfig extracted from revisions of the page where it is called from
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
94 y.append(float(page_dict[parameter].split()[0]))
328f45d3937e macro.DataRevPlot: macro to graph data by svgfig extracted from revisions of the page where it is called from
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
95 except:
328f45d3937e macro.DataRevPlot: macro to graph data by svgfig extracted from revisions of the page where it is called from
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
96 pass
328f45d3937e macro.DataRevPlot: macro to graph data by svgfig extracted from revisions of the page where it is called from
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
97
328f45d3937e macro.DataRevPlot: macro to graph data by svgfig extracted from revisions of the page where it is called from
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
98 x = range(len(y))
328f45d3937e macro.DataRevPlot: macro to graph data by svgfig extracted from revisions of the page where it is called from
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
99 if current_rev < 10:
328f45d3937e macro.DataRevPlot: macro to graph data by svgfig extracted from revisions of the page where it is called from
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
100 xrange = (0, 10)
328f45d3937e macro.DataRevPlot: macro to graph data by svgfig extracted from revisions of the page where it is called from
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
101 else:
328f45d3937e macro.DataRevPlot: macro to graph data by svgfig extracted from revisions of the page where it is called from
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
102 xrange = (0, max(x))
328f45d3937e macro.DataRevPlot: macro to graph data by svgfig extracted from revisions of the page where it is called from
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
103 points1 = svgfig.Dots(zip(x, y),
328f45d3937e macro.DataRevPlot: macro to graph data by svgfig extracted from revisions of the page where it is called from
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
104 svgfig.make_symbol("data1", stroke="black", fill="red",
328f45d3937e macro.DataRevPlot: macro to graph data by svgfig extracted from revisions of the page where it is called from
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
105 stroke_width="0.25pt"))
467
6e5f50c5855f PEP8 whitespace cleanup
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 464
diff changeset
106 # define scientific plot
464
328f45d3937e macro.DataRevPlot: macro to graph data by svgfig extracted from revisions of the page where it is called from
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
107 svgfig.Frame.text_ytitle_offset = 16
328f45d3937e macro.DataRevPlot: macro to graph data by svgfig extracted from revisions of the page where it is called from
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
108 myFrame = svgfig.Frame(xrange[0], xrange[1], 0, max(y) + 0.05 * max(y),
328f45d3937e macro.DataRevPlot: macro to graph data by svgfig extracted from revisions of the page where it is called from
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
109 points1, xtitle='days (%d = today)' % len(y),
328f45d3937e macro.DataRevPlot: macro to graph data by svgfig extracted from revisions of the page where it is called from
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
110 ytitle=parameter).SVG()
467
6e5f50c5855f PEP8 whitespace cleanup
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 464
diff changeset
111 # create complete svg xml
464
328f45d3937e macro.DataRevPlot: macro to graph data by svgfig extracted from revisions of the page where it is called from
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
112 data = myFrame.standalone_xml()
328f45d3937e macro.DataRevPlot: macro to graph data by svgfig extracted from revisions of the page where it is called from
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
113 # create key
328f45d3937e macro.DataRevPlot: macro to graph data by svgfig extracted from revisions of the page where it is called from
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
114 key = cache.key(request, itemname=pagename, content=data)
328f45d3937e macro.DataRevPlot: macro to graph data by svgfig extracted from revisions of the page where it is called from
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
115 size_str = "%s_%s" % (svgfig._canvas_defaults["width"].replace('px', ''),
328f45d3937e macro.DataRevPlot: macro to graph data by svgfig extracted from revisions of the page where it is called from
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
116 svgfig._canvas_defaults["height"].replace('px', ''))
328f45d3937e macro.DataRevPlot: macro to graph data by svgfig extracted from revisions of the page where it is called from
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
117 key = '%s_%s_%s' % (wikiutil.escape(content_type.replace('/', '_')),
328f45d3937e macro.DataRevPlot: macro to graph data by svgfig extracted from revisions of the page where it is called from
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
118 size_str, key)
328f45d3937e macro.DataRevPlot: macro to graph data by svgfig extracted from revisions of the page where it is called from
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
119 # check caching status
328f45d3937e macro.DataRevPlot: macro to graph data by svgfig extracted from revisions of the page where it is called from
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
120 if not cache.exists(request, key):
328f45d3937e macro.DataRevPlot: macro to graph data by svgfig extracted from revisions of the page where it is called from
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
121 cache.put(request, key, data, content_type=content_type)
328f45d3937e macro.DataRevPlot: macro to graph data by svgfig extracted from revisions of the page where it is called from
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
122 # create url to cache file
328f45d3937e macro.DataRevPlot: macro to graph data by svgfig extracted from revisions of the page where it is called from
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
123 url = "%s%s%s" % (request.getQualifiedURL(),
328f45d3937e macro.DataRevPlot: macro to graph data by svgfig extracted from revisions of the page where it is called from
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
124 Page(request, pagename).url(request), cache.url(request, key))
328f45d3937e macro.DataRevPlot: macro to graph data by svgfig extracted from revisions of the page where it is called from
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
125 from MoinMoin import macro
328f45d3937e macro.DataRevPlot: macro to graph data by svgfig extracted from revisions of the page where it is called from
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
126 from MoinMoin.parser.text import Parser
328f45d3937e macro.DataRevPlot: macro to graph data by svgfig extracted from revisions of the page where it is called from
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
127 macro.request = request
328f45d3937e macro.DataRevPlot: macro to graph data by svgfig extracted from revisions of the page where it is called from
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
128 macro.formatter = request.html_formatter
328f45d3937e macro.DataRevPlot: macro to graph data by svgfig extracted from revisions of the page where it is called from
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
129 p = Parser("##\n", request)
328f45d3937e macro.DataRevPlot: macro to graph data by svgfig extracted from revisions of the page where it is called from
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
130 m = macro.Macro(p)
328f45d3937e macro.DataRevPlot: macro to graph data by svgfig extracted from revisions of the page where it is called from
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
131 return m.execute('EmbedObject',
328f45d3937e macro.DataRevPlot: macro to graph data by svgfig extracted from revisions of the page where it is called from
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
132 u'width=%s, height=%s, target=%s, url_mimetype=%s' % (
328f45d3937e macro.DataRevPlot: macro to graph data by svgfig extracted from revisions of the page where it is called from
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
133 width, height, url, content_type))
467
6e5f50c5855f PEP8 whitespace cleanup
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 464
diff changeset
134