mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
py3 compat
This commit is contained in:
parent
99a478ae88
commit
6272c2b1eb
@ -7,11 +7,13 @@ __copyright__ = '2014, Kovid Goyal <kovid at kovidgoyal.net>'
|
||||
|
||||
import re
|
||||
from calibre.ebooks.oeb.base import XPath, urlunquote
|
||||
from polyglot.builtins import as_bytes
|
||||
|
||||
|
||||
class DataURL(object):
|
||||
|
||||
def __call__(self, oeb, opts):
|
||||
from calibre.utils.imghdr import what
|
||||
self.log = oeb.log
|
||||
attr_path = XPath('//h:img[@src]')
|
||||
for item in oeb.spine:
|
||||
@ -35,7 +37,7 @@ class DataURL(object):
|
||||
continue
|
||||
else:
|
||||
data = urlunquote(data)
|
||||
from imghdr import what
|
||||
data = as_bytes(data)
|
||||
fmt = what(None, data)
|
||||
if not fmt:
|
||||
self.log.warn('Image encoded as data URL has unknown format, ignoring')
|
||||
|
Loading…
x
Reference in New Issue
Block a user