From dc3a6a1f618aa964801762dc7ad8dccb945044fc Mon Sep 17 00:00:00 2001 From: John Schember Date: Thu, 2 Apr 2009 06:10:50 -0400 Subject: [PATCH] Finish txt output --- src/calibre/ebooks/txt/output.py | 14 ++++---------- src/calibre/ebooks/txt/writer.py | 6 +++--- 2 files changed, 7 insertions(+), 13 deletions(-) diff --git a/src/calibre/ebooks/txt/output.py b/src/calibre/ebooks/txt/output.py index 5e58d47ef1..c1e48d98fd 100644 --- a/src/calibre/ebooks/txt/output.py +++ b/src/calibre/ebooks/txt/output.py @@ -24,23 +24,17 @@ class TXTOutput(OutputFormatPlugin): 'Use \'old_mac\' for compatibility with Mac OS 9 and earlier. ' 'For Mac OS X use \'unix\'. \'system\' will default to the newline ' 'type used by this OS.' % sorted(TxtNewlines.NEWLINE_TYPES.keys()))), - OptionRecommendation(name='prepend_author', recommended_value='true', - level=OptionRecommendation.LOW, long_switch='prepend_author', + OptionRecommendation(name='prepend_metadata', recommended_value='false', + level=OptionRecommendation.LOW, long_switch='prepend_metadata', choices=['true', 'false'], - help=_('Write the author to the beginning of the file. ' + help=_('Write the title and author to the beginning of the file. ' 'Default is \'true\'. Use \'false\' to disable.')), - OptionRecommendation(name='prepend_title', recommended_value='true', - choices=['true', 'false'], - level=OptionRecommendation.LOW, long_switch='prepend_title', - help=_('Write the title to the beginning of the file. ' - 'Default is \'true\'. Use \'false\' to disable.')) ]) def convert(self, oeb_book, output_path, input_plugin, opts, log): metadata = TxtMetadata() - if opts.prepend_author.lower() == 'true': + if opts.prepend_metadata.lower() == 'true': 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[0].value if oeb_book.metadata.title != [] else _('Unknown') writer = TxtWriter(TxtNewlines(opts.newline).newline, log) diff --git a/src/calibre/ebooks/txt/writer.py b/src/calibre/ebooks/txt/writer.py index 2fb5f9550a..efd3ec0a2f 100644 --- a/src/calibre/ebooks/txt/writer.py +++ b/src/calibre/ebooks/txt/writer.py @@ -34,9 +34,9 @@ class TxtWriter(object): # Prepend metadata if metadata.author != None and metadata.author != '': - out = (u'%s%s%s%s' % (metadata.author.upper(), self.newline, self.newline, self.newline)) + out - if metadata.title != None and metadata.title != '': - out = (u'%s%s%s%s' % (metadata.title.upper(), self.newline, self.newline, self.newline)) + out + if metadata.title != None and metadata.title != '': + out = (u'%s%s%s%s' % (metadata.author.upper(), self.newline, self.newline, self.newline)) + out + out = (u'%s%s%s%s' % (metadata.title.upper(), self.newline, self.newline, self.newline)) + out # Put two blank lines at end of file end = out[-3 * len(self.newline):]