Guest User

Untitled

a guest
Aug 2nd, 2016
114
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.85 KB | None | 0 0
  1. #!/usr/bin/env python
  2. # -*- coding: utf-8 -*-
  3.  
  4. import sys
  5. import jinja2
  6. #import codecs
  7.  
  8. #Do some pre-processing here that is later used to populate the context variables in the menu
  9. menu_info={}
  10.  
  11. #Render the menu in the output
  12. #With codecs, in case it was the UTF-8 that was causing problems
  13. #T = jinja2.Template(codecs.open("./resourcesMenu.xml","rt","utf-8").read())
  14. T = jinja2.Template(open("./resourcesMenu.xml","rb").read())
  15. #With stdout.write of the rendered template
  16. sys.stdout.write(T.render(info=menu_info))
  17. #With print of the rendered template
  18. #print(T.render())
  19.  
  20. #Bare open (in binary) and dump
  21. #L = open("./resourcesMenu.xml","rb").read()
  22. #sys.stdout.write(L)
  23.  
  24. # With print
  25. #print("<?xml version=\"1.0\" encoding=\"UTF-8\"?>")
  26. #print("<openbox_pipe_menu>")
  27. #print("    <item label=\"blah\"/>")
  28. #print("</openbox_pipe_menu>")
Advertisement
Add Comment
Please, Sign In to add comment