annotate output_templates.py @ 151:802d8df993da

midway through making plots saveable
author catherine@dellzilla
date Fri, 26 Sep 2008 16:11:29 -0400
parents 3b1e25cc0e38
children ebdd20cfba69
rev   line source
149
3b1e25cc0e38 html output now valid xhtml 1.0 strict
catherine@dellzilla
parents:
diff changeset
1 import genshi.template
3b1e25cc0e38 html output now valid xhtml 1.0 strict
catherine@dellzilla
parents:
diff changeset
2
3b1e25cc0e38 html output now valid xhtml 1.0 strict
catherine@dellzilla
parents:
diff changeset
3 xml_template = genshi.template.NewTextTemplate("""
3b1e25cc0e38 html output now valid xhtml 1.0 strict
catherine@dellzilla
parents:
diff changeset
4 <xml>
3b1e25cc0e38 html output now valid xhtml 1.0 strict
catherine@dellzilla
parents:
diff changeset
5 <${tblname}_resultset>{% for row in rows %}
3b1e25cc0e38 html output now valid xhtml 1.0 strict
catherine@dellzilla
parents:
diff changeset
6 <$tblname>{% for (colname, itm) in zip(colnames, row) %}
3b1e25cc0e38 html output now valid xhtml 1.0 strict
catherine@dellzilla
parents:
diff changeset
7 <${colname.lower()}>$itm</${colname.lower()}>{% end %}
3b1e25cc0e38 html output now valid xhtml 1.0 strict
catherine@dellzilla
parents:
diff changeset
8 </$tblname>{% end %}
3b1e25cc0e38 html output now valid xhtml 1.0 strict
catherine@dellzilla
parents:
diff changeset
9 </${tblname}_resultset>
3b1e25cc0e38 html output now valid xhtml 1.0 strict
catherine@dellzilla
parents:
diff changeset
10 </xml>""")
3b1e25cc0e38 html output now valid xhtml 1.0 strict
catherine@dellzilla
parents:
diff changeset
11
3b1e25cc0e38 html output now valid xhtml 1.0 strict
catherine@dellzilla
parents:
diff changeset
12 html_template = genshi.template.MarkupTemplate("""
3b1e25cc0e38 html output now valid xhtml 1.0 strict
catherine@dellzilla
parents:
diff changeset
13 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
3b1e25cc0e38 html output now valid xhtml 1.0 strict
catherine@dellzilla
parents:
diff changeset
14 <html xmlns:py="http://genshi.edgewall.org/" xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
3b1e25cc0e38 html output now valid xhtml 1.0 strict
catherine@dellzilla
parents:
diff changeset
15 <head>
3b1e25cc0e38 html output now valid xhtml 1.0 strict
catherine@dellzilla
parents:
diff changeset
16 <title py:content="tblname">Table Name</title>
3b1e25cc0e38 html output now valid xhtml 1.0 strict
catherine@dellzilla
parents:
diff changeset
17 <meta http-equiv="content-type" content="text/html;charset=utf-8" />
3b1e25cc0e38 html output now valid xhtml 1.0 strict
catherine@dellzilla
parents:
diff changeset
18 </head>
3b1e25cc0e38 html output now valid xhtml 1.0 strict
catherine@dellzilla
parents:
diff changeset
19 <body>
3b1e25cc0e38 html output now valid xhtml 1.0 strict
catherine@dellzilla
parents:
diff changeset
20 <table py:attrs="{'id':tblname,
3b1e25cc0e38 html output now valid xhtml 1.0 strict
catherine@dellzilla
parents:
diff changeset
21 'summary':'Result set from query on table ' + tblname}">
3b1e25cc0e38 html output now valid xhtml 1.0 strict
catherine@dellzilla
parents:
diff changeset
22 <tr>
3b1e25cc0e38 html output now valid xhtml 1.0 strict
catherine@dellzilla
parents:
diff changeset
23 <th py:for="colname in colnames"
3b1e25cc0e38 html output now valid xhtml 1.0 strict
catherine@dellzilla
parents:
diff changeset
24 py:attrs="{'id':'header_' + colname.lower()}">
3b1e25cc0e38 html output now valid xhtml 1.0 strict
catherine@dellzilla
parents:
diff changeset
25 <span py:replace="colname.lower()">Column Name</span>
3b1e25cc0e38 html output now valid xhtml 1.0 strict
catherine@dellzilla
parents:
diff changeset
26 </th>
3b1e25cc0e38 html output now valid xhtml 1.0 strict
catherine@dellzilla
parents:
diff changeset
27 </tr>
3b1e25cc0e38 html output now valid xhtml 1.0 strict
catherine@dellzilla
parents:
diff changeset
28 <tr py:for="(colname, row) in zip(colnames, rows)">
3b1e25cc0e38 html output now valid xhtml 1.0 strict
catherine@dellzilla
parents:
diff changeset
29 <td py:for="itm in row" py:attrs="{'headers':'header_' + colname.lower()}">
3b1e25cc0e38 html output now valid xhtml 1.0 strict
catherine@dellzilla
parents:
diff changeset
30 <span py:replace="str(itm)">Value</span>
3b1e25cc0e38 html output now valid xhtml 1.0 strict
catherine@dellzilla
parents:
diff changeset
31 </td>
3b1e25cc0e38 html output now valid xhtml 1.0 strict
catherine@dellzilla
parents:
diff changeset
32 </tr>
3b1e25cc0e38 html output now valid xhtml 1.0 strict
catherine@dellzilla
parents:
diff changeset
33 </table>
3b1e25cc0e38 html output now valid xhtml 1.0 strict
catherine@dellzilla
parents:
diff changeset
34 </body>
3b1e25cc0e38 html output now valid xhtml 1.0 strict
catherine@dellzilla
parents:
diff changeset
35 </html>""")
3b1e25cc0e38 html output now valid xhtml 1.0 strict
catherine@dellzilla
parents:
diff changeset
36
3b1e25cc0e38 html output now valid xhtml 1.0 strict
catherine@dellzilla
parents:
diff changeset
37 list_template = genshi.template.NewTextTemplate("""
3b1e25cc0e38 html output now valid xhtml 1.0 strict
catherine@dellzilla
parents:
diff changeset
38 {% for (rowNum, row) in enumerate(rows) %}
3b1e25cc0e38 html output now valid xhtml 1.0 strict
catherine@dellzilla
parents:
diff changeset
39 **** Row: ${rowNum + 1}
3b1e25cc0e38 html output now valid xhtml 1.0 strict
catherine@dellzilla
parents:
diff changeset
40 {% for (colname, itm) in zip(colnames, row) %}$colname: $itm
3b1e25cc0e38 html output now valid xhtml 1.0 strict
catherine@dellzilla
parents:
diff changeset
41 {% end %}{% end %}""")
3b1e25cc0e38 html output now valid xhtml 1.0 strict
catherine@dellzilla
parents:
diff changeset
42
3b1e25cc0e38 html output now valid xhtml 1.0 strict
catherine@dellzilla
parents:
diff changeset
43 aligned_list_template = genshi.template.NewTextTemplate("""
3b1e25cc0e38 html output now valid xhtml 1.0 strict
catherine@dellzilla
parents:
diff changeset
44 {% for (rowNum, row) in enumerate(rows) %}
3b1e25cc0e38 html output now valid xhtml 1.0 strict
catherine@dellzilla
parents:
diff changeset
45 **** Row: ${rowNum + 1}
3b1e25cc0e38 html output now valid xhtml 1.0 strict
catherine@dellzilla
parents:
diff changeset
46 {% for (colname, itm) in zip(colnames, row) %}${colname.ljust(colnamelen)}: $itm
3b1e25cc0e38 html output now valid xhtml 1.0 strict
catherine@dellzilla
parents:
diff changeset
47 {% end %}{% end %}""")