Skip to content

Commit

Permalink
Removed template variable from Node.serialize. use ''.join instead of…
Browse files Browse the repository at this point in the history
… str % dict
  • Loading branch information
delfick committed Jan 12, 2012
1 parent 6908172 commit 30841ce
Showing 1 changed file with 5 additions and 8 deletions.
13 changes: 5 additions & 8 deletions dict2xml.py
Expand Up @@ -7,10 +7,7 @@ def __init__(self, wrap, tag, data=None):
self.data = data
self.type = self.determine_type()

def serialize(self, indenter, template=None):
if not template:
template = "%(start)s%(value)s%(content)s%(end)s"

def serialize(self, indenter):
wrap = self.wrap
content = ""
start, end = "", ""
Expand All @@ -21,20 +18,20 @@ def serialize(self, indenter, template=None):

if children:
if self.type != "iterable":
content = indenter((c.serialize(indenter, template) for c in children), wrap)
content = indenter((c.serialize(indenter) for c in children), wrap)
else:
result = []
for c in children:
content = c.serialize(indenter, template)
content = c.serialize(indenter)
if c.type == 'unicode':
result.append(content)
else:
content = indenter([content], True)
result.append(template % dict(start=start, value=value, content=content, end=end))
result.append(''.join((start, content, end)))

return indenter(result, False)

return template % dict(start=start, value=value, content=content, end=end)
return ''.join((start, value, content, end))

def determine_type(self):
data = self.data
Expand Down

0 comments on commit 30841ce

Please sign in to comment.