mirror of
https://github.com/gryf/ebook-converter.git
synced 2026-04-21 13:41:30 +02:00
Removing couple of "buildins" polyglot types
This commit is contained in:
@@ -8,7 +8,6 @@ from functools import partial
|
||||
from ebook_converter.ebooks.htmlz.oeb2html import OEB2HTML
|
||||
from ebook_converter.ebooks.oeb.base import XHTML, XHTML_NS, barename, namespace, rewrite_links
|
||||
from ebook_converter.ebooks.oeb.stylizer import Stylizer
|
||||
from ebook_converter.polyglot.builtins import string_or_bytes
|
||||
|
||||
|
||||
__license__ = 'GPL 3'
|
||||
@@ -110,10 +109,10 @@ class MarkdownMLizer(OEB2HTML):
|
||||
'''
|
||||
|
||||
# We can only processes tags. If there isn't a tag return any text.
|
||||
if not isinstance(elem.tag, string_or_bytes) \
|
||||
if not isinstance(elem.tag, (str, bytes)) \
|
||||
or namespace(elem.tag) != XHTML_NS:
|
||||
p = elem.getparent()
|
||||
if p is not None and isinstance(p.tag, string_or_bytes) and namespace(p.tag) == XHTML_NS \
|
||||
if p is not None and isinstance(p.tag, (str, bytes)) and namespace(p.tag) == XHTML_NS \
|
||||
and elem.tail:
|
||||
return [elem.tail]
|
||||
return ['']
|
||||
|
||||
@@ -8,7 +8,7 @@ from ebook_converter.ebooks.metadata.opf2 import OPFCreator
|
||||
|
||||
from ebook_converter.ebooks.conversion.preprocess import DocAnalysis
|
||||
from ebook_converter.utils.cleantext import clean_ascii_chars
|
||||
from ebook_converter.polyglot.builtins import iteritems, long_type
|
||||
from ebook_converter.polyglot.builtins import iteritems
|
||||
|
||||
|
||||
__license__ = 'GPL v3'
|
||||
@@ -62,7 +62,7 @@ def split_txt(txt, epub_split_size_kb=0):
|
||||
txt = txt.encode('utf-8')
|
||||
length_byte = len(txt)
|
||||
# Calculating the average chunk value for easy splitting as EPUB (+2 as a safe margin)
|
||||
chunk_size = long_type(length_byte / (int(length_byte / (epub_split_size_kb * 1024)) + 2))
|
||||
chunk_size = int(length_byte / (int(length_byte / (epub_split_size_kb * 1024)) + 2))
|
||||
# if there are chunks with a superior size then go and break
|
||||
parts = txt.split(b'\n\n')
|
||||
lengths = tuple(map(len, parts))
|
||||
|
||||
@@ -10,7 +10,6 @@ from ebook_converter.ebooks.oeb.base import XHTML, XHTML_NS, barename, namespace
|
||||
from ebook_converter.ebooks.oeb.stylizer import Stylizer
|
||||
from ebook_converter.ebooks import unit_convert
|
||||
from ebook_converter.ebooks.textile.unsmarten import unsmarten
|
||||
from ebook_converter.polyglot.builtins import string_or_bytes
|
||||
|
||||
|
||||
__license__ = 'GPL 3'
|
||||
@@ -225,10 +224,10 @@ class TextileMLizer(OEB2HTML):
|
||||
'''
|
||||
|
||||
# We can only processes tags. If there isn't a tag return any text.
|
||||
if not isinstance(elem.tag, string_or_bytes) \
|
||||
if not isinstance(elem.tag, (str, bytes)) \
|
||||
or namespace(elem.tag) != XHTML_NS:
|
||||
p = elem.getparent()
|
||||
if p is not None and isinstance(p.tag, string_or_bytes) and namespace(p.tag) == XHTML_NS \
|
||||
if p is not None and isinstance(p.tag, (str, bytes)) and namespace(p.tag) == XHTML_NS \
|
||||
and elem.tail:
|
||||
return [elem.tail]
|
||||
return ['']
|
||||
|
||||
@@ -4,7 +4,6 @@ Transform OEB content into plain text
|
||||
import re
|
||||
|
||||
from lxml import etree
|
||||
from ebook_converter.polyglot.builtins import string_or_bytes
|
||||
|
||||
|
||||
__license__ = 'GPL 3'
|
||||
@@ -189,10 +188,10 @@ class TXTMLizer(object):
|
||||
'''
|
||||
from ebook_converter.ebooks.oeb.base import XHTML_NS, barename, namespace
|
||||
|
||||
if not isinstance(elem.tag, string_or_bytes) \
|
||||
if not isinstance(elem.tag, (str, bytes)) \
|
||||
or namespace(elem.tag) != XHTML_NS:
|
||||
p = elem.getparent()
|
||||
if p is not None and isinstance(p.tag, string_or_bytes) and namespace(p.tag) == XHTML_NS \
|
||||
if p is not None and isinstance(p.tag, (str, bytes)) and namespace(p.tag) == XHTML_NS \
|
||||
and elem.tail:
|
||||
return [elem.tail]
|
||||
return ['']
|
||||
|
||||
Reference in New Issue
Block a user