Skip to content

Instantly share code, notes, and snippets.

@aldoah0a
Created April 17, 2013 15:05
Show Gist options
  • Save aldoah0a/5405058 to your computer and use it in GitHub Desktop.
Save aldoah0a/5405058 to your computer and use it in GitHub Desktop.
import spitfire as SpitfireTemplate
import spitfire.compiler.analyzer
import spitfire.compiler.util
table = [dict(a=1,b=2,c=3,d=4,e=5,f=6,g=7,h=8,i=9,j=10)
for x in range(1000)]
html = """
<table xmlns:py="http://spitfire/">
#for $row in $table
<tr>
#for $column in $row.values()
<td>$column</td>
#end for
</tr>
#end for
</table>
"""
enable_filters = False
spitfire_tmpl = spitfire.compiler.util.load_template(
html, 'spitfire_tmpl')
spitfire_tmpl_o1 = spitfire.compiler.util.load_template(
html, 'spitfire_tmpl_o1', spitfire.compiler.analyzer.o1_options,
{'enable_filters':enable_filters})
spitfire_tmpl_o2 = spitfire.compiler.util.load_template(
html, 'spitfire_tmpl_o2', spitfire.compiler.analyzer.o2_options,
{'enable_filters':enable_filters})
spitfire_tmpl_o3 = spitfire.compiler.util.load_template(
html, 'spitfire_tmpl_o3', spitfire.compiler.analyzer.o3_options,
{'enable_filters':enable_filters})
# I did not now how to install psyco so I commented this out :D
# spitfire_tmpl_o4 = spitfire.compiler.util.load_template(
# html, 'spitfire_tmpl_o4', spitfire.compiler.analyzer.o4_options,
# {'enable_filters':enable_filters})
# # run once to get psyco warmed up
# spitfire_tmpl_o4(search_list=[{'table':table}]).main()
def test_spitfire():
"""Spitfire template"""
data = spitfire_tmpl(search_list=[{'table':table}]).main()
print data
#print "spitfire", len(data)
def test_spitfire_o1():
"""Spitfire template -O1"""
data = spitfire_tmpl_o1(search_list=[{'table':table}]).main()
print data
#print "spitfire -O1", len(data)
def test_spitfire_o2():
"""Spitfire template -O2"""
data = spitfire_tmpl_o2(search_list=[{'table':table}]).main()
print data
#print "spitfire -O2", len(data)
def test_spitfire_o3():
"""Spitfire template -O3"""
data = spitfire_tmpl_o3(search_list=[{'table':table}]).main()
print data
#print "spitfire -O3", len(data)
if __name__ == '__main__':
test_spitfire()
test_spitfire_o1()
test_spitfire_o2()
test_spitfire_o3()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment