mirror of
https://github.com/gryf/ebook-converter.git
synced 2026-03-06 17:35:48 +01:00
Removed another unicode/string nonsense
This commit is contained in:
@@ -14,12 +14,6 @@ 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 native_string_type
|
||||
|
||||
|
||||
__license__ = 'GPL v3'
|
||||
__copyright__ = '2008, Kovid Goyal kovid@kovidgoyal.net'
|
||||
__docformat__ = 'restructuredtext en'
|
||||
|
||||
|
||||
# optparse uses gettext.gettext instead of _ from builtins, so we
|
||||
@@ -164,11 +158,11 @@ class OptionParser(optparse.OptionParser):
|
||||
|
||||
def options_iter(self):
|
||||
for opt in self.option_list:
|
||||
if native_string_type(opt).strip():
|
||||
if str(opt).strip():
|
||||
yield opt
|
||||
for gr in self.option_groups:
|
||||
for opt in gr.option_list:
|
||||
if native_string_type(opt).strip():
|
||||
if str(opt).strip():
|
||||
yield opt
|
||||
|
||||
def option_by_dest(self, dest):
|
||||
@@ -193,7 +187,6 @@ class OptionParser(optparse.OptionParser):
|
||||
def add_option_group(self, *args, **kwargs):
|
||||
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)
|
||||
|
||||
|
||||
|
||||
@@ -6,13 +6,8 @@ from ebook_converter import strftime
|
||||
from ebook_converter.constants import iswindows, isosx, plugins, preferred_encoding
|
||||
from ebook_converter.utils.iso8601 import utc_tz, local_tz, UNDEFINED_DATE
|
||||
from ebook_converter.utils.localization import lcdata
|
||||
from ebook_converter.polyglot.builtins import native_string_type
|
||||
|
||||
|
||||
__license__ = 'GPL v3'
|
||||
__copyright__ = '2010, Kovid Goyal <kovid@kovidgoyal.net>'
|
||||
__docformat__ = 'restructuredtext en'
|
||||
|
||||
_utc_tz = utc_tz
|
||||
_local_tz = local_tz
|
||||
|
||||
@@ -39,7 +34,7 @@ else:
|
||||
def first_index(raw, queries):
|
||||
for q in queries:
|
||||
try:
|
||||
return raw.index(native_string_type(q))
|
||||
return raw.index(q)
|
||||
except ValueError:
|
||||
pass
|
||||
return -1
|
||||
@@ -191,8 +186,7 @@ def isoformat(date_time, assume_utc=False, as_utc=True, sep='T'):
|
||||
date_time = date_time.replace(tzinfo=_utc_tz if assume_utc else
|
||||
_local_tz)
|
||||
date_time = date_time.astimezone(_utc_tz if as_utc else _local_tz)
|
||||
# native_string_type(sep) because isoformat barfs with unicode sep on python 2.x
|
||||
return str(date_time.isoformat(native_string_type(sep)))
|
||||
return str(date_time.isoformat(sep))
|
||||
|
||||
|
||||
def internal_iso_format_string():
|
||||
|
||||
@@ -5,7 +5,7 @@ from ebook_converter.constants import isosx, isfrozen, filesystem_encoding
|
||||
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 environ_item, native_string_type
|
||||
from ebook_converter.polyglot.builtins import environ_item
|
||||
from ebook_converter.polyglot.binary import as_hex_unicode
|
||||
try:
|
||||
import win32process
|
||||
@@ -14,11 +14,6 @@ except ImportError:
|
||||
iswindows = False
|
||||
|
||||
|
||||
__license__ = 'GPL v3'
|
||||
__copyright__ = '2009, Kovid Goyal <kovid@kovidgoyal.net>'
|
||||
__docformat__ = 'restructuredtext en'
|
||||
|
||||
|
||||
if iswindows:
|
||||
try:
|
||||
windows_null_file = open(os.devnull, 'wb')
|
||||
@@ -89,9 +84,9 @@ class Worker(object):
|
||||
@property
|
||||
def env(self):
|
||||
env = os.environ.copy()
|
||||
env[native_string_type('CALIBRE_WORKER')] = environ_item('1')
|
||||
env['CALIBRE_WORKER'] = environ_item('1')
|
||||
td = as_hex_unicode(msgpack_dumps(base_dir()))
|
||||
env[native_string_type('CALIBRE_WORKER_TEMP_DIR')] = environ_item(td)
|
||||
env['CALIBRE_WORKER_TEMP_DIR'] = environ_item(td)
|
||||
env.update(self._env)
|
||||
return env
|
||||
|
||||
@@ -154,7 +149,7 @@ class Worker(object):
|
||||
except EnvironmentError:
|
||||
# cwd no longer exists
|
||||
origwd = cwd or os.path.expanduser('~')
|
||||
env[native_string_type('ORIGWD')] = environ_item(as_hex_unicode(msgpack_dumps(origwd)))
|
||||
env['ORIGWD'] = environ_item(as_hex_unicode(msgpack_dumps(origwd)))
|
||||
_cwd = cwd
|
||||
if priority is None:
|
||||
priority = prefs['worker_process_priority']
|
||||
|
||||
@@ -6,13 +6,6 @@ try:
|
||||
except ValueError:
|
||||
iswindows = False
|
||||
|
||||
from ebook_converter.polyglot.builtins import native_string_type
|
||||
|
||||
|
||||
__license__ = 'GPL v3'
|
||||
__copyright__ = '2012, Kovid Goyal <kovid at kovidgoyal.net>'
|
||||
__docformat__ = 'restructuredtext en'
|
||||
|
||||
|
||||
def fmt(code):
|
||||
return '\033[%dm' % code
|
||||
@@ -128,7 +121,7 @@ class Detect(object):
|
||||
# Stream is a console
|
||||
self.set_console = windll.kernel32.SetConsoleTextAttribute
|
||||
self.default_console_text_attributes = WCOLORS['white']
|
||||
kernel32 = WinDLL(native_string_type('kernel32'), use_last_error=True)
|
||||
kernel32 = WinDLL('kernel32', use_last_error=True)
|
||||
self.write_console = kernel32.WriteConsoleW
|
||||
self.write_console.argtypes = [wintypes.HANDLE, wintypes.c_wchar_p, wintypes.DWORD, POINTER(wintypes.DWORD), wintypes.LPVOID]
|
||||
self.write_console.restype = wintypes.BOOL
|
||||
|
||||
Reference in New Issue
Block a user