mirror of
https://github.com/gryf/ebook-converter.git
synced 2026-04-16 02:53:33 +02:00
Removing couple of "buildins" polyglot types
This commit is contained in:
@@ -14,7 +14,7 @@ from ebook_converter.utils.config_base import (
|
||||
tweaks, from_json, to_json
|
||||
)
|
||||
from ebook_converter.utils.lock import ExclusiveFile
|
||||
from ebook_converter.polyglot.builtins import string_or_bytes, native_string_type
|
||||
from ebook_converter.polyglot.builtins import native_string_type
|
||||
|
||||
|
||||
__license__ = 'GPL v3'
|
||||
@@ -191,7 +191,7 @@ class OptionParser(optparse.OptionParser):
|
||||
upper.__dict__[dest] = lower.__dict__[dest]
|
||||
|
||||
def add_option_group(self, *args, **kwargs):
|
||||
if isinstance(args[0], string_or_bytes):
|
||||
if isinstance(args[0], (str, bytes)):
|
||||
args = list(args)
|
||||
args[0] = native_string_type(args[0])
|
||||
return optparse.OptionParser.add_option_group(self, *args, **kwargs)
|
||||
|
||||
@@ -17,7 +17,6 @@ from ebook_converter.ptempfile import TemporaryDirectory
|
||||
from ebook_converter.utils.config_base import tweaks
|
||||
from ebook_converter.utils.filenames import atomic_rename
|
||||
from ebook_converter.utils.imghdr import what
|
||||
from ebook_converter.polyglot.builtins import string_or_bytes
|
||||
|
||||
# Utilities {{{
|
||||
# imageops, imageops_err = plugins['imageops']
|
||||
@@ -505,7 +504,7 @@ def quantize_image(img, max_colors=256, dither=True, palette=''):
|
||||
img = image_from_data(img)
|
||||
if img.hasAlphaChannel():
|
||||
img = blend_image(img)
|
||||
if palette and isinstance(palette, string_or_bytes):
|
||||
if palette and isinstance(palette, (str, bytes)):
|
||||
palette = palette.split()
|
||||
return imageops.quantize(img, max_colors, dither, [QColor(x).rgb() for x in palette])
|
||||
|
||||
|
||||
@@ -6,7 +6,6 @@ import os
|
||||
|
||||
from ebook_converter.utils.speedups import ReadOnlyFileBuffer
|
||||
from ebook_converter.constants import ispy3
|
||||
from ebook_converter.polyglot.builtins import string_or_bytes
|
||||
|
||||
|
||||
HSIZE = 120
|
||||
@@ -15,7 +14,7 @@ HSIZE = 120
|
||||
def what(file, h=None):
|
||||
' Recognize image headers '
|
||||
if h is None:
|
||||
if isinstance(file, string_or_bytes):
|
||||
if isinstance(file, (str, bytes)):
|
||||
with lopen(file, 'rb') as f:
|
||||
h = f.read(HSIZE)
|
||||
else:
|
||||
|
||||
@@ -5,7 +5,7 @@ from ebook_converter.constants import isosx, isfrozen, filesystem_encoding, ispy
|
||||
from ebook_converter.utils.config import prefs
|
||||
from ebook_converter.ptempfile import PersistentTemporaryFile, base_dir
|
||||
from ebook_converter.utils.serialize import msgpack_dumps
|
||||
from ebook_converter.polyglot.builtins import iteritems, string_or_bytes, environ_item, native_string_type, getcwd
|
||||
from ebook_converter.polyglot.builtins import iteritems, environ_item, native_string_type, getcwd
|
||||
from ebook_converter.polyglot.binary import as_hex_unicode
|
||||
try:
|
||||
import win32process
|
||||
@@ -191,7 +191,7 @@ class Worker(object):
|
||||
_cwd = cwd
|
||||
if priority is None:
|
||||
priority = prefs['worker_process_priority']
|
||||
cmd = [exe] if isinstance(exe, string_or_bytes) else exe
|
||||
cmd = [exe] if isinstance(exe, (str, bytes)) else exe
|
||||
args = {
|
||||
'env' : env,
|
||||
'cwd' : _cwd,
|
||||
|
||||
@@ -8,7 +8,7 @@ from ebook_converter.utils.ipc import eintr_retry_call
|
||||
from ebook_converter.utils.ipc.launch import Worker
|
||||
from ebook_converter.utils.serialize import msgpack_loads, msgpack_dumps
|
||||
from ebook_converter.utils.monotonic import monotonic
|
||||
from ebook_converter.polyglot.builtins import string_or_bytes, environ_item
|
||||
from ebook_converter.polyglot.builtins import environ_item
|
||||
from ebook_converter.polyglot.binary import as_hex_unicode, from_hex_bytes
|
||||
|
||||
|
||||
@@ -162,7 +162,7 @@ def start_pipe_worker(command, env=None, priority='normal', **process_args):
|
||||
args['close_fds'] = True
|
||||
|
||||
exe = w.executable
|
||||
cmd = [exe] if isinstance(exe, string_or_bytes) else exe
|
||||
cmd = [exe] if isinstance(exe, (str, bytes)) else exe
|
||||
p = subprocess.Popen(cmd + ['--pipe-worker', command], **args)
|
||||
return p
|
||||
|
||||
|
||||
@@ -10,7 +10,7 @@ from tempfile import SpooledTemporaryFile
|
||||
from ebook_converter import sanitize_file_name
|
||||
from ebook_converter.constants import filesystem_encoding
|
||||
from ebook_converter.ebooks.chardet import detect
|
||||
from ebook_converter.polyglot.builtins import string_or_bytes, getcwd, as_bytes
|
||||
from ebook_converter.polyglot.builtins import getcwd, as_bytes
|
||||
|
||||
try:
|
||||
import zlib # We may need its compression method
|
||||
@@ -749,7 +749,7 @@ class ZipFile:
|
||||
self.comment = b''
|
||||
|
||||
# Check if we were passed a file-like object
|
||||
if isinstance(file, string_or_bytes):
|
||||
if isinstance(file, (str, bytes)):
|
||||
self._filePassed = 0
|
||||
self.filename = file
|
||||
modeDict = {'r' : 'rb', 'w': 'wb', 'a' : 'r+b'}
|
||||
|
||||
Reference in New Issue
Block a user