diff --git a/src/calibre/ebooks/epub/from_html.py b/src/calibre/ebooks/epub/from_html.py index 6341519c61..ca50fe7a5d 100644 --- a/src/calibre/ebooks/epub/from_html.py +++ b/src/calibre/ebooks/epub/from_html.py @@ -454,12 +454,9 @@ def convert(htmlfile, opts, notification=None, create_epub=True, cpath = os.path.join(tdir, 'content', 'resources', '_cover_.jpg') if os.path.exists(cpath): - opf.add_path_to_manifest(cpath, 'image/jpeg') + opf.add_path_to_manifest(cpath, 'image/jpeg') with open(opf_path, 'wb') as f: - raw = opf.render() - if not raw.startswith('\n'+raw - f.write(raw) + f.write(opf.render()) ncx_path = os.path.join(os.path.dirname(opf_path), 'toc.ncx') if os.path.exists(ncx_path) and os.stat(ncx_path).st_size > opts.profile.flow_size: logger.info('Condensing NCX from %d bytes...'%os.stat(ncx_path).st_size) @@ -475,7 +472,7 @@ def convert(htmlfile, opts, notification=None, create_epub=True, logger.info(_('Output written to ')+opts.output) if opts.show_opf: - print open(os.path.join(tdir, 'metadata.opf')).read() + print open(opf_path, 'rb').read() if opts.extract_to is not None: if os.path.exists(opts.extract_to): diff --git a/src/calibre/ebooks/html.py b/src/calibre/ebooks/html.py index 6d1b405a28..9a273c42ce 100644 --- a/src/calibre/ebooks/html.py +++ b/src/calibre/ebooks/html.py @@ -1007,7 +1007,6 @@ def merge_metadata(htmlfile, opf, opts): mi = get_metadata(open(htmlfile, 'rb'), 'html') except: mi = MetaInformation(None, None) - if opts.from_opf is not None and os.access(opts.from_opf, os.R_OK): mi.smart_update(OPF(open(opts.from_opf, 'rb'), os.path.abspath(os.path.dirname(opts.from_opf)))) for attr in ('title', 'authors', 'publisher', 'tags', 'comments'): diff --git a/src/calibre/ebooks/metadata/__init__.py b/src/calibre/ebooks/metadata/__init__.py index c7d667c831..f97b413486 100644 --- a/src/calibre/ebooks/metadata/__init__.py +++ b/src/calibre/ebooks/metadata/__init__.py @@ -247,6 +247,12 @@ class MetaInformation(object): if getattr(mi, 'cover_data', None) and mi.cover_data[0] is not None: self.cover_data = mi.cover_data + def format_series_index(self): + try: + x = float(self.series_index) + except ValueError: + x = 1.0 + return '%d'%x if int(x) == x else '%.2f'%x def __unicode__(self): ans = u'' @@ -267,7 +273,7 @@ class MetaInformation(object): if self.tags: ans += u'Tags : ' + u', '.join([unicode(t) for t in self.tags]) + '\n' if self.series: - ans += u'Series : '+unicode(self.series) + ' #%d\n'%self.series_index + ans += u'Series : '+unicode(self.series) + ' #%s\n'%self.format_series_index() if self.language: ans += u'Language : ' + unicode(self.language) + u'\n' return ans.strip() @@ -277,11 +283,11 @@ class MetaInformation(object): ans += [(_('Author(s)'), (authors_to_string(self.authors) if self.authors else _('Unknown')))] ans += [(_('Publisher'), unicode(self.publisher))] ans += [(_('Producer'), unicode(self.book_producer))] - ans += [(_('Category'), unicode(self.category))] ans += [(_('Comments'), unicode(self.comments))] ans += [('ISBN', unicode(self.isbn))] ans += [(_('Tags'), u', '.join([unicode(t) for t in self.tags]))] - ans += [(_('Series'), unicode(self.series))] + if self.series: + ans += [(_('Series'), unicode(self.series))+ ' #%s'%self.format_series_index()] ans += [(_('Language'), unicode(self.language))] for i, x in enumerate(ans): ans[i] = u'