diff --git a/ebook_converter/__init__.py b/ebook_converter/__init__.py index 3af6217..aeda223 100644 --- a/ebook_converter/__init__.py +++ b/ebook_converter/__init__.py @@ -9,10 +9,9 @@ import urllib.parse import urllib.request import warnings -from ebook_converter.polyglot.builtins import hasenv from functools import partial -if not hasenv('CALIBRE_SHOW_DEPRECATION_WARNINGS'): +if os.getenv('CALIBRE_SHOW_DEPRECATION_WARNINGS') is None: warnings.simplefilter('ignore', DeprecationWarning) try: os.getcwd() @@ -155,7 +154,7 @@ def prints(*args, **kwargs): ''' file = kwargs.get('file', sys.stdout) file = getattr(file, 'buffer', file) - enc = 'utf-8' if hasenv('CALIBRE_WORKER') else preferred_encoding + enc = 'utf-8' if os.getenv('CALIBRE_WORKER') else preferred_encoding sep = kwargs.get('sep', ' ') if not isinstance(sep, bytes): sep = sep.encode(enc) @@ -219,7 +218,7 @@ class CommandLineError(Exception): def setup_cli_handlers(logger, level): import logging - if hasenv('CALIBRE_WORKER') and logger.handlers: + if os.getenv('CALIBRE_WORKER') and logger.handlers: return logger.setLevel(level) if level == logging.WARNING: diff --git a/ebook_converter/constants.py b/ebook_converter/constants.py index 2abc793..b77da5a 100644 --- a/ebook_converter/constants.py +++ b/ebook_converter/constants.py @@ -5,7 +5,7 @@ import locale import os import sys -from ebook_converter.polyglot.builtins import environ_item, hasenv, as_unicode +from ebook_converter.polyglot.builtins import environ_item, as_unicode __appname__ = 'calibre' numeric_version = (4, 12, 0) @@ -30,14 +30,15 @@ ishaiku = 'haiku1' in _plat islinux = not(iswindows or isosx or isbsd or ishaiku) isfrozen = hasattr(sys, 'frozen') isunix = isosx or islinux or ishaiku -isportable = hasenv('CALIBRE_PORTABLE_BUILD') +isportable = os.getenv('CALIBRE_PORTABLE_BUILD') is not None isxp = isoldvista = False if iswindows: wver = sys.getwindowsversion() isxp = wver.major < 6 isoldvista = wver.build < 6002 is64bit = sys.maxsize > (1 << 32) -isworker = hasenv('CALIBRE_WORKER') or hasenv('CALIBRE_SIMPLE_WORKER') +isworker = any([os.getenv('CALIBRE_WORKER') or + os.getenv('CALIBRE_SIMPLE_WORKER')]) if isworker: os.environ.pop(environ_item('CALIBRE_FORCE_ANSI'), None) FAKE_PROTOCOL, FAKE_HOST = 'clbr', 'internal.invalid' @@ -92,7 +93,7 @@ else: filesystem_encoding = 'utf-8' -DEBUG = hasenv('CALIBRE_DEBUG') +DEBUG = os.getenv('CALIBRE_DEBUG') is not None def debug(): diff --git a/ebook_converter/customize/ui.py b/ebook_converter/customize/ui.py index 3ea692f..90a3de4 100644 --- a/ebook_converter/customize/ui.py +++ b/ebook_converter/customize/ui.py @@ -9,7 +9,6 @@ from ebook_converter.customize import (CatalogPlugin, FileTypePlugin, PluginNotF StoreBase as Store, EditBookToolPlugin, LibraryClosedPlugin) from ebook_converter.customize.conversion import InputFormatPlugin, OutputFormatPlugin -from ebook_converter.customize.zipplugin import loader from ebook_converter.customize.profiles import InputProfile, OutputProfile from ebook_converter.customize.builtins import plugins as builtin_plugins # from ebook_converter.devices.interface import DevicePlugin diff --git a/ebook_converter/customize/zipplugin.py b/ebook_converter/customize/zipplugin.py index 29e3c01..77ae2d0 100644 --- a/ebook_converter/customize/zipplugin.py +++ b/ebook_converter/customize/zipplugin.py @@ -294,7 +294,7 @@ class PluginLoader(object): loader = PluginLoader() -sys.meta_path.insert(0, loader) +#sys.meta_path.insert(0, loader) if __name__ == '__main__': diff --git a/ebook_converter/polyglot/builtins.py b/ebook_converter/polyglot/builtins.py index 204e464..8575ba7 100644 --- a/ebook_converter/polyglot/builtins.py +++ b/ebook_converter/polyglot/builtins.py @@ -1,9 +1,4 @@ import importlib -import os - - -def hasenv(x): - return os.getenv(x) is not None def as_bytes(x, encoding='utf-8'):