mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
Txt output mostly fixed
This commit is contained in:
parent
fca3f98e6a
commit
e6e9a20586
@ -39,9 +39,9 @@ class TXTOutput(OutputFormatPlugin):
|
|||||||
def convert(self, oeb_book, output_path, input_plugin, opts, log):
|
def convert(self, oeb_book, output_path, input_plugin, opts, log):
|
||||||
metadata = TxtMetadata()
|
metadata = TxtMetadata()
|
||||||
if opts.prepend_author.lower() == 'true':
|
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':
|
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)
|
writer = TxtWriter(TxtNewlines(opts.newline).newline, log)
|
||||||
txt = writer.dump(oeb_book.spine, metadata)
|
txt = writer.dump(oeb_book.spine, metadata)
|
||||||
|
@ -22,8 +22,7 @@ class TxtWriter(object):
|
|||||||
def dump(self, spine, metadata):
|
def dump(self, spine, metadata):
|
||||||
out = u''
|
out = u''
|
||||||
for item in spine:
|
for item in spine:
|
||||||
with open(item, 'r') as itemf:
|
content = unicode(item)
|
||||||
content = itemf.read().decode(item.encoding)
|
|
||||||
# Convert newlines to unix style \n for processing. These
|
# Convert newlines to unix style \n for processing. These
|
||||||
# will be changed to the specified type later in the process.
|
# will be changed to the specified type later in the process.
|
||||||
content = self.unix_newlines(content)
|
content = self.unix_newlines(content)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user