misc fixes for last py3 merge

This commit is contained in:
Kovid Goyal 2019-07-07 19:03:41 +05:30
parent ec4d9f109d
commit 46afc39739
No known key found for this signature in database
GPG Key ID: 06BC317B515ACE7C
5 changed files with 9 additions and 7 deletions

View File

@ -632,7 +632,7 @@ class OEBReader(object):
path = os.path.join(tdir, unquote(hcover.href)) path = os.path.join(tdir, unquote(hcover.href))
data = render_html_svg_workaround(path, self.logger) data = render_html_svg_workaround(path, self.logger)
if not data: if not data:
data = '' data = b''
id, href = self.oeb.manifest.generate('cover', 'cover.jpg') id, href = self.oeb.manifest.generate('cover', 'cover.jpg')
item = self.oeb.manifest.add(id, href, JPEG_MIME, data=data) item = self.oeb.manifest.add(id, href, JPEG_MIME, data=data)
return item return item

View File

@ -1,9 +1,9 @@
# -*- encoding: utf-8 -*- # -*- encoding: utf-8 -*-
from __future__ import absolute_import, division, print_function, unicode_literals
''' '''
CSS property propagation class. CSS property propagation class.
''' '''
from __future__ import absolute_import, division, print_function, unicode_literals
__license__ = 'GPL v3' __license__ = 'GPL v3'
__copyright__ = '2008, Marshall T. Vandegrift <llasram@gmail.com>' __copyright__ = '2008, Marshall T. Vandegrift <llasram@gmail.com>'
@ -33,7 +33,7 @@ def html_css_stylesheet():
global _html_css_stylesheet global _html_css_stylesheet
if _html_css_stylesheet is None: if _html_css_stylesheet is None:
with open(P('templates/html.css'), 'rb') as f: 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) _html_css_stylesheet = parseString(html_css, validate=False)
return _html_css_stylesheet return _html_css_stylesheet
@ -96,6 +96,7 @@ def test_media_ok():
assert media_ok('screen, (device-width:10px)') assert media_ok('screen, (device-width:10px)')
assert not media_ok('screen and (device-width:10px)') assert not media_ok('screen and (device-width:10px)')
class StylizerRules(object): class StylizerRules(object):
def __init__(self, opts, profile, stylesheets): def __init__(self, opts, profile, stylesheets):
@ -181,6 +182,7 @@ class StylizerRules(object):
return False return False
return True return True
class Stylizer(object): class Stylizer(object):
STYLESHEETS = WeakKeyDictionary() STYLESHEETS = WeakKeyDictionary()
@ -280,7 +282,7 @@ class Stylizer(object):
stylesheet = parser.parseString(text, href=cssname, stylesheet = parser.parseString(text, href=cssname,
validate=False) validate=False)
stylesheets.append(stylesheet) stylesheets.append(stylesheet)
except: except Exception:
self.logger.exception('Failed to parse %s, ignoring.'%w) self.logger.exception('Failed to parse %s, ignoring.'%w)
self.logger.debug('Bad css: ') self.logger.debug('Bad css: ')
self.logger.debug(x) self.logger.debug(x)

View File

@ -1,7 +1,7 @@
from __future__ import absolute_import, division, print_function, unicode_literals
''' '''
HTML-TOC-adding transform. HTML-TOC-adding transform.
''' '''
from __future__ import absolute_import, division, print_function, unicode_literals
__license__ = 'GPL v3' __license__ = 'GPL v3'
__copyright__ = '2008, Marshall T. Vandegrift <llasram@gmail.com>' __copyright__ = '2008, Marshall T. Vandegrift <llasram@gmail.com>'

View File

@ -1,7 +1,7 @@
from __future__ import absolute_import, division, print_function, unicode_literals
''' '''
CSS case-mangling transform. CSS case-mangling transform.
''' '''
from __future__ import absolute_import, division, print_function, unicode_literals
__license__ = 'GPL v3' __license__ = 'GPL v3'
__copyright__ = '2008, Marshall T. Vandegrift <llasram@gmail.com>' __copyright__ = '2008, Marshall T. Vandegrift <llasram@gmail.com>'

View File

@ -1,7 +1,7 @@
from __future__ import absolute_import, division, print_function, unicode_literals
''' '''
SVG rasterization transform. SVG rasterization transform.
''' '''
from __future__ import absolute_import, division, print_function, unicode_literals
__license__ = 'GPL v3' __license__ = 'GPL v3'
__copyright__ = '2008, Marshall T. Vandegrift <llasram@gmail.com>' __copyright__ = '2008, Marshall T. Vandegrift <llasram@gmail.com>'