mirror of
git://github.com/kovidgoyal/calibre.git
synced 2026-01-06 17:54:40 +01:00
py3 compat
This commit is contained in:
parent
99a478ae88
commit
6272c2b1eb
1 changed files with 3 additions and 1 deletions
|
|
@ -7,11 +7,13 @@
|
|||
|
||||
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 @@ def __call__(self, oeb, opts):
|
|||
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…
Reference in a new issue