mirror of
https://github.com/gryf/ebook-converter.git
synced 2026-03-17 15:23:43 +01:00
Removing is_py3 method and duplicated by urllib.
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
import textwrap
|
||||
import urllib.parse
|
||||
|
||||
from ebook_converter import guess_type
|
||||
from ebook_converter.utils.imghdr import identify
|
||||
@@ -93,7 +94,6 @@ class CoverManager(object):
|
||||
return -1, -1
|
||||
|
||||
def insert_cover(self):
|
||||
from ebook_converter.ebooks.oeb.base import urldefrag
|
||||
g, m = self.oeb.guide, self.oeb.manifest
|
||||
item = None
|
||||
href = None
|
||||
@@ -124,7 +124,7 @@ class CoverManager(object):
|
||||
data=safe_xml_fromstring(tp))
|
||||
else:
|
||||
item = self.oeb.manifest.hrefs[
|
||||
urldefrag(self.oeb.guide['titlepage'].href)[0]]
|
||||
urllib.parse.urldefrag(self.oeb.guide['titlepage'].href)[0]]
|
||||
if item is not None:
|
||||
self.oeb.spine.insert(0, item, True)
|
||||
if 'cover' not in self.oeb.guide.refs:
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
import posixpath
|
||||
import urllib.parse
|
||||
|
||||
from lxml import etree
|
||||
|
||||
from ebook_converter.ebooks.oeb.base import rewrite_links, urlnormalize
|
||||
from ebook_converter.polyglot.urllib import urldefrag, urlparse
|
||||
|
||||
|
||||
__license__ = 'GPL v3'
|
||||
@@ -38,7 +38,7 @@ class RenameFiles(object): # {{{
|
||||
if self.oeb.guide:
|
||||
for ref in self.oeb.guide.values():
|
||||
href = urlnormalize(ref.href)
|
||||
href, frag = urldefrag(href)
|
||||
href, frag = urllib.parse.urldefrag(href)
|
||||
replacement = self.rename_map.get(href, None)
|
||||
if replacement is not None:
|
||||
nhref = replacement
|
||||
@@ -52,7 +52,7 @@ class RenameFiles(object): # {{{
|
||||
def fix_toc_entry(self, toc):
|
||||
if toc.href:
|
||||
href = urlnormalize(toc.href)
|
||||
href, frag = urldefrag(href)
|
||||
href, frag = urllib.parse.urldefrag(href)
|
||||
replacement = self.rename_map.get(href, None)
|
||||
|
||||
if replacement is not None:
|
||||
@@ -66,11 +66,11 @@ class RenameFiles(object): # {{{
|
||||
|
||||
def url_replacer(self, orig_url):
|
||||
url = urlnormalize(orig_url)
|
||||
parts = urlparse(url)
|
||||
parts = urllib.parse.urlparse(url)
|
||||
if parts.scheme:
|
||||
# Only rewrite local URLs
|
||||
return orig_url
|
||||
path, frag = urldefrag(url)
|
||||
path, frag = urllib.parse.urldefrag(url)
|
||||
if self.renamed_items_map:
|
||||
orig_item = self.renamed_items_map.get(self.current_item.href, self.current_item)
|
||||
else:
|
||||
|
||||
@@ -2,10 +2,11 @@ import sys, os, re
|
||||
from xml.sax.saxutils import escape
|
||||
from string import Formatter
|
||||
import pkg_resources
|
||||
import urllib.parse
|
||||
|
||||
from ebook_converter import guess_type, strftime
|
||||
from ebook_converter.constants import iswindows
|
||||
from ebook_converter.ebooks.oeb.base import XPath, XHTML_NS, XHTML, xml2text, urldefrag, urlnormalize
|
||||
from ebook_converter.ebooks.oeb.base import XPath, XHTML_NS, XHTML, xml2text, urlnormalize
|
||||
from ebook_converter.library.comments import comments_to_html, markdown
|
||||
from ebook_converter.utils.date import is_date_undefined, as_local_time
|
||||
from ebook_converter.ebooks.chardet import strip_encoding_declarations
|
||||
@@ -73,7 +74,7 @@ class RemoveFirstImage(Base):
|
||||
self.log.warn('Could not find first image to remove')
|
||||
if deleted_item is not None:
|
||||
for item in list(self.oeb.toc):
|
||||
href = urldefrag(item.href)[0]
|
||||
href = urllib.parse.urldefrag(item.href)[0]
|
||||
if href == deleted_item.href:
|
||||
self.oeb.toc.remove(item)
|
||||
self.oeb.guide.remove_by_href(deleted_item.href)
|
||||
|
||||
@@ -1,7 +1,9 @@
|
||||
"""
|
||||
SVG rasterization transform.
|
||||
"""
|
||||
import os, re
|
||||
import os
|
||||
import re
|
||||
import urllib.parse
|
||||
|
||||
# from PyQt5.Qt import (
|
||||
# Qt, QByteArray, QBuffer, QIODevice, QColor, QImage, QPainter, QSvgRenderer)
|
||||
@@ -14,7 +16,6 @@ from ebook_converter.ebooks.oeb.stylizer import Stylizer
|
||||
from ebook_converter.ptempfile import PersistentTemporaryFile
|
||||
from ebook_converter.utils.imghdr import what
|
||||
from ebook_converter.polyglot.builtins import unicode_type
|
||||
from ebook_converter.polyglot.urllib import urldefrag
|
||||
|
||||
|
||||
__license__ = 'GPL v3'
|
||||
@@ -114,7 +115,7 @@ class SVGRasterizer(object):
|
||||
hrefs = self.oeb.manifest.hrefs
|
||||
for elem in xpath(svg, '//svg:*[@xl:href]'):
|
||||
href = urlnormalize(elem.attrib[XLINK('href')])
|
||||
path = urldefrag(href)[0]
|
||||
path = urllib.parse.urldefrag(href)[0]
|
||||
if not path:
|
||||
continue
|
||||
abshref = item.abshref(path)
|
||||
|
||||
@@ -5,6 +5,7 @@ assumes a prior call to the flatcss transform.
|
||||
"""
|
||||
import os, functools, collections, re, copy
|
||||
from collections import OrderedDict
|
||||
import urllib.parse
|
||||
|
||||
from lxml.etree import XPath as _XPath
|
||||
from lxml import etree
|
||||
@@ -12,7 +13,7 @@ from lxml import etree
|
||||
from ebook_converter import as_unicode, force_unicode
|
||||
from ebook_converter.ebooks.epub import rules
|
||||
from ebook_converter.ebooks.oeb.base import (OEB_STYLES, XPNSMAP as NAMESPACES,
|
||||
urldefrag, rewrite_links, XHTML, urlnormalize)
|
||||
rewrite_links, XHTML, urlnormalize)
|
||||
from ebook_converter.ebooks.oeb.polish.split import do_split
|
||||
from ebook_converter.polyglot.builtins import iteritems, unicode_type
|
||||
from ebook_converter.polyglot.urllib import unquote
|
||||
@@ -162,7 +163,7 @@ class Split(object):
|
||||
rewrite_links(item.data, self.rewrite_links)
|
||||
|
||||
def rewrite_links(self, url):
|
||||
href, frag = urldefrag(url)
|
||||
href, frag = urllib.parse.urldefrag(url)
|
||||
try:
|
||||
href = self.current_item.abshref(href)
|
||||
except ValueError:
|
||||
@@ -453,7 +454,7 @@ class FlowSplitter(object):
|
||||
|
||||
if self.oeb.guide:
|
||||
for ref in self.oeb.guide.values():
|
||||
href, frag = urldefrag(ref.href)
|
||||
href, frag = urllib.parse.urldefrag(ref.href)
|
||||
if href == self.item.href:
|
||||
nhref = self.anchor_map[frag if frag else None]
|
||||
if frag:
|
||||
@@ -462,7 +463,7 @@ class FlowSplitter(object):
|
||||
|
||||
def fix_toc_entry(toc):
|
||||
if toc.href:
|
||||
href, frag = urldefrag(toc.href)
|
||||
href, frag = urllib.parse.urldefrag(toc.href)
|
||||
if href == self.item.href:
|
||||
nhref = self.anchor_map[frag if frag else None]
|
||||
if frag:
|
||||
@@ -476,7 +477,7 @@ class FlowSplitter(object):
|
||||
|
||||
if self.oeb.pages:
|
||||
for page in self.oeb.pages:
|
||||
href, frag = urldefrag(page.href)
|
||||
href, frag = urllib.parse.urldefrag(page.href)
|
||||
if href == self.item.href:
|
||||
nhref = self.anchor_map[frag if frag else None]
|
||||
if frag:
|
||||
|
||||
@@ -1,4 +1,6 @@
|
||||
import re, uuid
|
||||
import re
|
||||
import uuid
|
||||
import urllib.parse
|
||||
|
||||
from lxml import etree
|
||||
from collections import OrderedDict, Counter
|
||||
@@ -6,7 +8,6 @@ from collections import OrderedDict, Counter
|
||||
from ebook_converter.ebooks.oeb.base import XPNSMAP, TOC, XHTML, xml2text, barename
|
||||
from ebook_converter.ebooks import ConversionError
|
||||
from ebook_converter.polyglot.builtins import itervalues, unicode_type
|
||||
from ebook_converter.polyglot.urllib import urlparse
|
||||
|
||||
|
||||
__license__ = 'GPL v3'
|
||||
@@ -209,7 +210,7 @@ class DetectStructure(object):
|
||||
for a in XPath('//h:a[@href]')(item.data):
|
||||
href = a.get('href')
|
||||
try:
|
||||
purl = urlparse(href)
|
||||
purl = urllib.parse.urlparse(href)
|
||||
except ValueError:
|
||||
self.log.warning('Ignoring malformed URL:', href)
|
||||
continue
|
||||
|
||||
@@ -1,9 +1,10 @@
|
||||
"""
|
||||
OPF manifest trimming transform.
|
||||
"""
|
||||
import urllib.parse
|
||||
|
||||
from ebook_converter.ebooks.oeb.base import CSS_MIME, OEB_DOCS
|
||||
from ebook_converter.ebooks.oeb.base import urlnormalize, iterlinks
|
||||
from ebook_converter.polyglot.urllib import urldefrag
|
||||
|
||||
|
||||
__license__ = 'GPL v3'
|
||||
@@ -32,7 +33,7 @@ class ManifestTrimmer(object):
|
||||
elif item.value in oeb.manifest.ids:
|
||||
used.add(oeb.manifest.ids[item.value])
|
||||
for ref in oeb.guide.values():
|
||||
path, _ = urldefrag(ref.href)
|
||||
path, _ = urllib.parse.urldefrag(ref.href)
|
||||
if path in oeb.manifest.hrefs:
|
||||
used.add(oeb.manifest.hrefs[path])
|
||||
# TOC items are required to be in the spine
|
||||
|
||||
Reference in New Issue
Block a user