mirror of
https://github.com/gryf/ebook-converter.git
synced 2026-04-27 17:13:32 +02:00
Removing couple of "buildins" polyglot types
This commit is contained in:
@@ -51,7 +51,7 @@ DEFAULT_GENREADING = "fs" # default is yes to both lrf and lrs
|
||||
|
||||
from ebook_converter import __appname__, __version__
|
||||
from ebook_converter import entity_to_unicode
|
||||
from ebook_converter.polyglot.builtins import string_or_bytes, iteritems, native_string_type
|
||||
from ebook_converter.polyglot.builtins import iteritems, native_string_type
|
||||
|
||||
|
||||
class LrsError(Exception):
|
||||
@@ -90,7 +90,7 @@ def ElementWithReading(tag, text, reading=False):
|
||||
|
||||
if text is None:
|
||||
readingText = ""
|
||||
elif isinstance(text, string_or_bytes):
|
||||
elif isinstance(text, (str, bytes)):
|
||||
readingText = text
|
||||
else:
|
||||
# assumed to be a sequence of (name, sortas)
|
||||
@@ -148,7 +148,7 @@ class Delegator(object):
|
||||
|
||||
"""
|
||||
for setting in d.getSettings():
|
||||
if isinstance(setting, string_or_bytes):
|
||||
if isinstance(setting, (str, bytes)):
|
||||
setting = (d, setting)
|
||||
delegates = \
|
||||
self.delegatedSettingsDict.setdefault(setting[1], [])
|
||||
@@ -286,7 +286,7 @@ class LrsContainer(object):
|
||||
(content.__class__.__name__,
|
||||
self.__class__.__name__))
|
||||
|
||||
if convertText and isinstance(content, string_or_bytes):
|
||||
if convertText and isinstance(content, (str, bytes)):
|
||||
content = Text(content)
|
||||
|
||||
content.setParent(self)
|
||||
@@ -580,14 +580,14 @@ class Book(Delegator):
|
||||
ts.attrs['baselineskip'] = rescale(ts.attrs['baselineskip'])
|
||||
|
||||
def renderLrs(self, lrsFile, encoding="UTF-8"):
|
||||
if isinstance(lrsFile, string_or_bytes):
|
||||
if isinstance(lrsFile, (str, bytes)):
|
||||
lrsFile = codecs.open(lrsFile, "wb", encoding=encoding)
|
||||
self.render(lrsFile, outputEncodingName=encoding)
|
||||
lrsFile.close()
|
||||
|
||||
def renderLrf(self, lrfFile):
|
||||
self.appendReferencedObjects(self)
|
||||
if isinstance(lrfFile, string_or_bytes):
|
||||
if isinstance(lrfFile, (str, bytes)):
|
||||
lrfFile = open(lrfFile, "wb")
|
||||
lrfWriter = LrfWriter(self.sourceencoding)
|
||||
|
||||
@@ -1488,7 +1488,7 @@ class Paragraph(LrsContainer):
|
||||
LrsContainer.__init__(self, [Text, CR, DropCaps, CharButton,
|
||||
LrsSimpleChar1, bytes, str])
|
||||
if text is not None:
|
||||
if isinstance(text, string_or_bytes):
|
||||
if isinstance(text, (str, bytes)):
|
||||
text = Text(text)
|
||||
self.append(text)
|
||||
|
||||
@@ -1807,7 +1807,7 @@ class Span(LrsSimpleChar1, LrsContainer):
|
||||
def __init__(self, text=None, **attrs):
|
||||
LrsContainer.__init__(self, [LrsSimpleChar1, Text, bytes, str])
|
||||
if text is not None:
|
||||
if isinstance(text, string_or_bytes):
|
||||
if isinstance(text, (str, bytes)):
|
||||
text = Text(text)
|
||||
self.append(text)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user