Skip to content

Commit

Permalink
adicionado string.strip ao render_xml (#77)
Browse files Browse the repository at this point in the history
  • Loading branch information
felipepaloschi authored and danimaribeiro committed Dec 18, 2017
1 parent 26f4f4c commit 4f8bf2b
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions pytrustnfe/xml/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,20 @@ def recursively_empty(e):
return all((recursively_empty(c) for c in e.iterchildren()))


def recursively_normalize(vals):
for item in vals:
if type(vals[item]) is str:
vals[item] = vals[item].strip()
elif type(vals[item]) is dict:
recursively_normalize(vals[item])
elif type(vals[item]) is list:
for a in vals[item]:
recursively_normalize(a)
return vals


def render_xml(path, template_name, remove_empty, **nfe):
nfe = recursively_normalize(nfe)
env = Environment(
loader=FileSystemLoader(path), extensions=['jinja2.ext.with_'])

Expand Down

0 comments on commit 4f8bf2b

Please sign in to comment.