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))
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

View File

@ -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 <llasram@gmail.com>'
@ -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)

View File

@ -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 <llasram@gmail.com>'

View File

@ -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 <llasram@gmail.com>'

View File

@ -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 <llasram@gmail.com>'