mirror of
https://github.com/gryf/ebook-converter.git
synced 2026-04-19 20:53:35 +02:00
Moved misc functions from polyglot package to single polyglot module.
This commit is contained in:
@@ -5,7 +5,7 @@ import urllib.parse
|
||||
from lxml import etree
|
||||
|
||||
from ebook_converter.utils.imghdr import identify
|
||||
from ebook_converter.polyglot.urllib import unquote
|
||||
from ebook_converter import polyglot
|
||||
|
||||
|
||||
class CoverManager(object):
|
||||
@@ -113,7 +113,7 @@ class CoverManager(object):
|
||||
if href is not None:
|
||||
templ = self.non_svg_template if self.no_svg_cover \
|
||||
else self.svg_template
|
||||
tp = templ % unquote(href)
|
||||
tp = templ % polyglot.unquote(href)
|
||||
id, href = m.generate('titlepage', 'titlepage.xhtml')
|
||||
item = m.add(id, href, mimetypes.guess_type('t.xhtml')[0],
|
||||
data=etree.fromstring(tp))
|
||||
|
||||
@@ -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 '
|
||||
|
||||
@@ -17,7 +17,7 @@ from ebook_converter import constants as const
|
||||
from ebook_converter.ebooks.epub import rules
|
||||
from ebook_converter.ebooks.oeb import base
|
||||
from ebook_converter.ebooks.oeb.polish.split import do_split
|
||||
from ebook_converter.polyglot.urllib import unquote
|
||||
from ebook_converter import polyglot
|
||||
from ebook_converter.css_selectors import Select, SelectorError
|
||||
from ebook_converter.utils import encoding as uenc
|
||||
|
||||
@@ -189,7 +189,7 @@ class Split(object):
|
||||
nhref = anchor_map[frag if frag else None]
|
||||
nhref = self.current_item.relhref(nhref)
|
||||
if frag:
|
||||
nhref = '#'.join((unquote(nhref), frag))
|
||||
nhref = '#'.join((polyglot.unquote(nhref), frag))
|
||||
|
||||
return nhref
|
||||
return url
|
||||
|
||||
Reference in New Issue
Block a user