diff --git a/src/calibre/ebooks/conversion/plugins/epub_input.py b/src/calibre/ebooks/conversion/plugins/epub_input.py index b6024c9b84..5ccf00c643 100644 --- a/src/calibre/ebooks/conversion/plugins/epub_input.py +++ b/src/calibre/ebooks/conversion/plugins/epub_input.py @@ -206,9 +206,11 @@ class EPUBInput(InputFormatPlugin): not_for_spine = set() for y in opf.itermanifest(): id_ = y.get('id', None) - if id_ and y.get('media-type', None) in \ - ('application/vnd.adobe-page-template+xml','application/text'): - not_for_spine.add(id_) + if id_ and y.get('media-type', None) in { + 'application/vnd.adobe-page-template+xml', 'application/vnd.adobe.page-template+xml', + 'application/adobe-page-template+xml', 'application/adobe.page-template+xml', + 'application/text'}: + not_for_spine.add(id_) seen = set() for x in list(opf.iterspine()): diff --git a/src/calibre/ebooks/oeb/transforms/page_margin.py b/src/calibre/ebooks/oeb/transforms/page_margin.py index 67ba490a81..382f0c8f53 100644 --- a/src/calibre/ebooks/oeb/transforms/page_margin.py +++ b/src/calibre/ebooks/oeb/transforms/page_margin.py @@ -20,9 +20,10 @@ class RemoveAdobeMargins(object): self.oeb, self.opts, self.log = oeb, opts, log for item in self.oeb.manifest: - if (item.media_type in ('application/vnd.adobe-page-template+xml', - 'application/vnd.adobe.page-template+xml') and - hasattr(item.data, 'xpath')): + if item.media_type in { + 'application/vnd.adobe-page-template+xml', 'application/vnd.adobe.page-template+xml', + 'application/adobe-page-template+xml', 'application/adobe.page-template+xml', + } and hasattr(item.data, 'xpath'): self.log('Removing page margins specified in the' ' Adobe page template') for elem in item.data.xpath( @@ -84,13 +85,12 @@ class RemoveFakeMargins(object): except: pass else: - if ( (hasattr(ti, 'startswith') and ti.startswith('-')) or + if ((hasattr(ti, 'startswith') and ti.startswith('-')) or isinstance(ti, (int, float)) and ti < 0): raise NegativeTextIndent() return style.marginLeft, style.marginRight, style return '', '', None - def process_level(self, level): elems = self.levels[level] self.stats[level+'_left'] = Counter() @@ -107,7 +107,6 @@ class RemoveFakeMargins(object): remove_left = self.analyze_stats(self.stats[level+'_left']) remove_right = self.analyze_stats(self.stats[level+'_right']) - if remove_left: mcl = self.stats[level+'_left'].most_common(1)[0][0] self.log('Removing level %s left margin of:'%level, mcl)