diff --git a/src/calibre/ebooks/oeb/reader.py b/src/calibre/ebooks/oeb/reader.py index c1961ed0e2..bcdade1eec 100644 --- a/src/calibre/ebooks/oeb/reader.py +++ b/src/calibre/ebooks/oeb/reader.py @@ -632,7 +632,7 @@ class OEBReader(object): path = os.path.join(tdir, unquote(hcover.href)) data = render_html_svg_workaround(path, self.logger) if not data: - data = '' + data = b'' id, href = self.oeb.manifest.generate('cover', 'cover.jpg') item = self.oeb.manifest.add(id, href, JPEG_MIME, data=data) return item diff --git a/src/calibre/ebooks/oeb/stylizer.py b/src/calibre/ebooks/oeb/stylizer.py index d834e26ad3..109cccd06f 100644 --- a/src/calibre/ebooks/oeb/stylizer.py +++ b/src/calibre/ebooks/oeb/stylizer.py @@ -1,9 +1,9 @@ # -*- encoding: utf-8 -*- +from __future__ import absolute_import, division, print_function, unicode_literals ''' CSS property propagation class. ''' -from __future__ import absolute_import, division, print_function, unicode_literals __license__ = 'GPL v3' __copyright__ = '2008, Marshall T. Vandegrift ' @@ -33,7 +33,7 @@ def html_css_stylesheet(): global _html_css_stylesheet if _html_css_stylesheet is None: with open(P('templates/html.css'), 'rb') as f: - html_css = f.read() + html_css = f.read().decode('utf-8') _html_css_stylesheet = parseString(html_css, validate=False) return _html_css_stylesheet @@ -96,6 +96,7 @@ def test_media_ok(): assert media_ok('screen, (device-width:10px)') assert not media_ok('screen and (device-width:10px)') + class StylizerRules(object): def __init__(self, opts, profile, stylesheets): @@ -181,6 +182,7 @@ class StylizerRules(object): return False return True + class Stylizer(object): STYLESHEETS = WeakKeyDictionary() @@ -280,7 +282,7 @@ class Stylizer(object): stylesheet = parser.parseString(text, href=cssname, validate=False) stylesheets.append(stylesheet) - except: + except Exception: self.logger.exception('Failed to parse %s, ignoring.'%w) self.logger.debug('Bad css: ') self.logger.debug(x) diff --git a/src/calibre/ebooks/oeb/transforms/htmltoc.py b/src/calibre/ebooks/oeb/transforms/htmltoc.py index bab65763b8..df6f69925e 100644 --- a/src/calibre/ebooks/oeb/transforms/htmltoc.py +++ b/src/calibre/ebooks/oeb/transforms/htmltoc.py @@ -1,7 +1,7 @@ +from __future__ import absolute_import, division, print_function, unicode_literals ''' HTML-TOC-adding transform. ''' -from __future__ import absolute_import, division, print_function, unicode_literals __license__ = 'GPL v3' __copyright__ = '2008, Marshall T. Vandegrift ' diff --git a/src/calibre/ebooks/oeb/transforms/manglecase.py b/src/calibre/ebooks/oeb/transforms/manglecase.py index c3a198949c..24c1a9aaca 100644 --- a/src/calibre/ebooks/oeb/transforms/manglecase.py +++ b/src/calibre/ebooks/oeb/transforms/manglecase.py @@ -1,7 +1,7 @@ +from __future__ import absolute_import, division, print_function, unicode_literals ''' CSS case-mangling transform. ''' -from __future__ import absolute_import, division, print_function, unicode_literals __license__ = 'GPL v3' __copyright__ = '2008, Marshall T. Vandegrift ' diff --git a/src/calibre/ebooks/oeb/transforms/rasterize.py b/src/calibre/ebooks/oeb/transforms/rasterize.py index 83651b23e5..cfa320e85f 100644 --- a/src/calibre/ebooks/oeb/transforms/rasterize.py +++ b/src/calibre/ebooks/oeb/transforms/rasterize.py @@ -1,7 +1,7 @@ +from __future__ import absolute_import, division, print_function, unicode_literals ''' SVG rasterization transform. ''' -from __future__ import absolute_import, division, print_function, unicode_literals __license__ = 'GPL v3' __copyright__ = '2008, Marshall T. Vandegrift '