1
0
mirror of https://github.com/gryf/ebook-converter.git synced 2026-04-19 12:43:35 +02:00

Moved misc functions from polyglot package to single polyglot module.

This commit is contained in:
2021-05-25 19:06:31 +02:00
parent f46984267e
commit f47376830f
32 changed files with 244 additions and 219 deletions

View File

@@ -3,8 +3,7 @@ import re
import urllib.parse
from ebook_converter.ebooks.oeb.base import XPath
from ebook_converter.polyglot.binary import from_base64_bytes
from ebook_converter.polyglot.builtins import as_bytes
from ebook_converter import polyglot
class DataURL(object):
@@ -27,14 +26,14 @@ class DataURL(object):
if ';base64' in header:
data = re.sub(r'\s+', '', data)
try:
data = from_base64_bytes(data)
data = polyglot.from_base64_bytes(data)
except Exception:
self.log.error('Found invalid base64 encoded data '
'URI, ignoring it')
continue
else:
data = urllib.parse.unquote(data)
data = as_bytes(data)
data = polyglot.as_bytes(data)
fmt = what(None, data)
if not fmt:
self.log.warn('Image encoded as data URL has unknown '