Removing trailing spaces

This commit is contained in:
Andrés Reyes Monge 2013-07-31 14:49:54 -06:00
parent d1226e852c
commit dd0bd757e5

View file

@ -3,23 +3,23 @@
# * Copyright (c) 2012 Christopher Ramírez chris.ramirezg [at} gmail (dot] com. # * Copyright (c) 2012 Christopher Ramírez chris.ramirezg [at} gmail (dot] com.
# * All rights reserved. # * All rights reserved.
# * # *
# * Permission is hereby granted, free of charge, to any person obtaining a # * Permission is hereby granted, free of charge, to any person obtaining a
# * copy of this software and associated documentation files (the "Software"), # * copy of this software and associated documentation files (the "Software"),
# * to deal in the Software without restriction, including without limitation # * to deal in the Software without restriction, including without limitation
# * the rights to use, copy, modify, merge, publish, distribute, sublicense, # * the rights to use, copy, modify, merge, publish, distribute, sublicense,
# * and/or sell copies of the Software, and to permit persons to whom the # * and/or sell copies of the Software, and to permit persons to whom the
# * Software is furnished to do so, subject to the following conditions: # * Software is furnished to do so, subject to the following conditions:
# * # *
# * The above copyright notice and this permission notice shall be included in # * The above copyright notice and this permission notice shall be included in
# * all copies or substantial portions of the Software. # * all copies or substantial portions of the Software.
# * # *
# * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR # * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
# * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, # * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE # * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
# * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER # * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
# * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING # * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
# * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER # * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
# * DEALINGS IN THE SOFTWARE. # * DEALINGS IN THE SOFTWARE.
""" """
@ -30,7 +30,7 @@ This file implements Render. Render provides an interface to render
Open Document Format (ODF) documents to be used as templates using Open Document Format (ODF) documents to be used as templates using
the jinja2 template engine. To render a template: the jinja2 template engine. To render a template:
engine = Render(template_file) engine = Render(template_file)
result = engine.render(template_var1=...) result = engine.render(template_var1=...)
""" """
import re import re
@ -67,9 +67,9 @@ class UndefinedSilently(Undefined):
__getattr__ = return_new __getattr__ = return_new
# ************************************************ # ************************************************
# #
# SECRETARY FILTERS # SECRETARY FILTERS
# #
# ************************************************ # ************************************************
def pad_string(value, length=5): def pad_string(value, length=5):
@ -87,7 +87,7 @@ class Render():
engine = Render('template.odt') engine = Render('template.odt')
engine.environment.filters['custom_filer'] = filter_function engine.environment.filters['custom_filer'] = filter_function
result = engine.render() result = engine.render()
Basic use example: Basic use example:
engine = Render('template') engine = Render('template')
result = engine.render() result = engine.render()
@ -127,9 +127,9 @@ class Render():
self.template = template self.template = template
self._environment = Environment(undefined=UndefinedSilently, autoescape=True) self._environment = Environment(undefined=UndefinedSilently, autoescape=True)
self._environment.filters['pad'] = pad_string self._environment.filters['pad'] = pad_string
def unpack_template(self): def unpack_template(self):
""" """
Loads the template into a ZIP file, allowing to make Loads the template into a ZIP file, allowing to make
@ -216,7 +216,7 @@ class Render():
self.pack_document() self.pack_document()
return self.rendered.getvalue() return self.rendered.getvalue()
def node_parents(self, node, parent_type): def node_parents(self, node, parent_type):
""" """
Returns the first node's parent with name of parent_type Returns the first node's parent with name of parent_type
@ -278,7 +278,7 @@ class Render():
parent = field.parentNode parent = field.parentNode
parent.insertBefore(new_node, field) parent.insertBefore(new_node, field)
parent.removeChild(field) parent.removeChild(field)
def render_template(template, **kwargs): def render_template(template, **kwargs):
""" """
@ -310,8 +310,8 @@ if __name__ == "__main__":
render = Render('simple_template.odt') render = Render('simple_template.odt')
result = render.render(countries=countries, document=document) result = render.render(countries=countries, document=document)
output = open('rendered.odt', 'w') output = open('rendered.odt', 'w')
output.write(result) output.write(result)
print "Template rendering finished! Check rendered.odt file." print "Template rendering finished! Check rendered.odt file."