Txt output mostly fixed

This commit is contained in:
John Schember 2009-04-01 21:21:26 -04:00
parent fca3f98e6a
commit e6e9a20586
2 changed files with 12 additions and 13 deletions

View File

@ -39,10 +39,10 @@ class TXTOutput(OutputFormatPlugin):
def convert(self, oeb_book, output_path, input_plugin, opts, log):
metadata = TxtMetadata()
if opts.prepend_author.lower() == 'true':
metadata.author = opts.authors if opts.authors else authors_to_string(oeb_book.metadata.authors)
metadata.author = opts.authors if opts.authors else authors_to_string(oeb_book.metadata.authors.value) if oeb_book.metadata.authors != [] else _('Unknown')
if opts.prepend_title.lower() == 'true':
metadata.title = opts.title if opts.title else oeb_book.metadata.title
metadata.title = opts.title if opts.title else oeb_book.metadata.title[0].value if oeb_book.metadata.title != [] else _('Unknown')
writer = TxtWriter(TxtNewlines(opts.newline).newline, log)
txt = writer.dump(oeb_book.spine, metadata)

View File

@ -22,16 +22,15 @@ class TxtWriter(object):
def dump(self, spine, metadata):
out = u''
for item in spine:
with open(item, 'r') as itemf:
content = itemf.read().decode(item.encoding)
# Convert newlines to unix style \n for processing. These
# will be changed to the specified type later in the process.
content = self.unix_newlines(content)
content = self.strip_html(content)
content = self.replace_html_symbols(content)
content = self.cleanup_text(content)
content = self.specified_newlines(content)
out += content
content = unicode(item)
# Convert newlines to unix style \n for processing. These
# will be changed to the specified type later in the process.
content = self.unix_newlines(content)
content = self.strip_html(content)
content = self.replace_html_symbols(content)
content = self.cleanup_text(content)
content = self.specified_newlines(content)
out += content
# Prepend metadata
if metadata.author != None and metadata.author != '':