Fix bug in lit-meta where successive invocations in the same program were causing OPF concatenation.

This commit is contained in:
Kovid Goyal 2007-11-14 18:59:01 +00:00
parent 441eb8f3da
commit 79fc36113d

View File

@ -164,7 +164,6 @@ class UnBinary(object):
pending_indent = 0 pending_indent = 0
lingering_space = 0 lingering_space = 0
was_in_text = 0 was_in_text = 0
buf = cStringIO.StringIO()
def __init__(self, bin, manifest, attr_map=OPF_ATTR_MAP, tag_map=OPF_TAG_MAP, def __init__(self, bin, manifest, attr_map=OPF_ATTR_MAP, tag_map=OPF_TAG_MAP,
tag_to_attr_map=[[] for i in range(43)]): tag_to_attr_map=[[] for i in range(43)]):
@ -174,6 +173,7 @@ class UnBinary(object):
self.tag_to_attr_map = tag_to_attr_map self.tag_to_attr_map = tag_to_attr_map
self.opf = self.attr_map is OPF_ATTR_MAP self.opf = self.attr_map is OPF_ATTR_MAP
self.bin = bin self.bin = bin
self.buf = cStringIO.StringIO()
self.binary_to_text() self.binary_to_text()
def write_spaces(self, depth): def write_spaces(self, depth):
@ -691,7 +691,7 @@ class LitFile(object):
def get_metadata(stream): def get_metadata(stream):
try: try:
litfile = LitFile(stream) litfile = LitFile(stream)
mi = OPFReader(cStringIO.StringIO(litfile.meta)) mi = OPFReader(cStringIO.StringIO(litfile.meta))
except: except:
title = stream.name if hasattr(stream, 'name') and stream.name else 'Unknown' title = stream.name if hasattr(stream, 'name') and stream.name else 'Unknown'
mi = MetaInformation(title, ['Unknown']) mi = MetaInformation(title, ['Unknown'])