Mercurial > sqlpython
comparison output_templates.py @ 153:ebdd20cfba69
plots finally editable
author | catherine@Elli.myhome.westell.com |
---|---|
date | Mon, 29 Sep 2008 05:28:28 -0400 |
parents | 3b1e25cc0e38 |
children |
comparison
equal
deleted
inserted
replaced
152:c26bc528cb05 | 153:ebdd20cfba69 |
---|---|
1 import genshi.template | 1 import genshi.template |
2 | 2 |
3 xml_template = genshi.template.NewTextTemplate(""" | 3 # To make more output formats available to sqlpython, just edit this |
4 # file, or place a copy in your local directory and edit that. | |
5 | |
6 output_templates = { | |
7 | |
8 '\\x': genshi.template.NewTextTemplate(""" | |
4 <xml> | 9 <xml> |
5 <${tblname}_resultset>{% for row in rows %} | 10 <${tblname}_resultset>{% for row in rows %} |
6 <$tblname>{% for (colname, itm) in zip(colnames, row) %} | 11 <$tblname>{% for (colname, itm) in zip(colnames, row) %} |
7 <${colname.lower()}>$itm</${colname.lower()}>{% end %} | 12 <${colname.lower()}>$itm</${colname.lower()}>{% end %} |
8 </$tblname>{% end %} | 13 </$tblname>{% end %} |
9 </${tblname}_resultset> | 14 </${tblname}_resultset> |
10 </xml>""") | 15 </xml>"""), |
11 | 16 |
12 html_template = genshi.template.MarkupTemplate(""" | 17 '\\h': genshi.template.MarkupTemplate(""" |
13 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> | 18 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> |
14 <html xmlns:py="http://genshi.edgewall.org/" xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"> | 19 <html xmlns:py="http://genshi.edgewall.org/" xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"> |
15 <head> | 20 <head> |
16 <title py:content="tblname">Table Name</title> | 21 <title py:content="tblname">Table Name</title> |
17 <meta http-equiv="content-type" content="text/html;charset=utf-8" /> | 22 <meta http-equiv="content-type" content="text/html;charset=utf-8" /> |
30 <span py:replace="str(itm)">Value</span> | 35 <span py:replace="str(itm)">Value</span> |
31 </td> | 36 </td> |
32 </tr> | 37 </tr> |
33 </table> | 38 </table> |
34 </body> | 39 </body> |
35 </html>""") | 40 </html>"""), |
36 | 41 |
37 list_template = genshi.template.NewTextTemplate(""" | 42 '\\g': genshi.template.NewTextTemplate(""" |
38 {% for (rowNum, row) in enumerate(rows) %} | 43 {% for (rowNum, row) in enumerate(rows) %} |
39 **** Row: ${rowNum + 1} | 44 **** Row: ${rowNum + 1} |
40 {% for (colname, itm) in zip(colnames, row) %}$colname: $itm | 45 {% for (colname, itm) in zip(colnames, row) %}$colname: $itm |
41 {% end %}{% end %}""") | 46 {% end %}{% end %}"""), |
42 | 47 |
43 aligned_list_template = genshi.template.NewTextTemplate(""" | 48 '\\G': genshi.template.NewTextTemplate(""" |
44 {% for (rowNum, row) in enumerate(rows) %} | 49 {% for (rowNum, row) in enumerate(rows) %} |
45 **** Row: ${rowNum + 1} | 50 **** Row: ${rowNum + 1} |
46 {% for (colname, itm) in zip(colnames, row) %}${colname.ljust(colnamelen)}: $itm | 51 {% for (colname, itm) in zip(colnames, row) %}${colname.ljust(colnamelen)}: $itm |
47 {% end %}{% end %}""") | 52 {% end %}{% end %}"""), |
53 | |
54 } |