Fix some str vs. unicode issues. Re-add dropped TOC.iterdescendents() method.

This commit is contained in:
Marshall T. Vandegrift 2008-12-16 12:33:27 -05:00
parent 83470f3d6b
commit 0c7a0b831d
2 changed files with 12 additions and 2 deletions

View File

@ -247,6 +247,7 @@ class Manifest(object):
elif self.media_type.startswith('application/') \
and self.media_type.endswith('+xml'):
data = etree.fromstring(data, parser=XML_PARSER)
self._data = data
return data
def fset(self, value):
self._data = value
@ -477,6 +478,12 @@ class TOC(object):
self.nodes.append(node)
return node
def iterdescendents(self):
for node in self.nodes:
yield node
for child in node.iterdescendents():
yield child
def __iter__(self):
for node in self.nodes:
yield node

View File

@ -128,7 +128,7 @@ class UnBinary(object):
self.dir = os.path.dirname(path)
buf = StringIO()
self.binary_to_text(bin, buf)
self.raw = buf.getvalue().lstrip().decode('utf-8')
self.raw = buf.getvalue().lstrip()
self.escape_reserved()
self._tree = None
@ -157,6 +157,9 @@ class UnBinary(object):
return '/'.join(relpath)
def __unicode__(self):
return self.raw.decode('utf-8')
def __str__(self):
return self.raw
def tree():
@ -837,7 +840,7 @@ class LitReader(object):
content += etree.tostring(unbin.tree,
encoding='ascii', pretty_print=True)
else:
content += unicode(unbin)
content += str(unbin)
else:
internal = '/'.join(('/data', entry.internal))
content = self._litfile.get_file(internal)