mirror of
https://github.com/gryf/ebook-converter.git
synced 2026-04-04 03:33:33 +02:00
Removed unused code mainly from old constants file.
This commit is contained in:
@@ -10,7 +10,7 @@ import sys
|
|||||||
from functools import partial
|
from functools import partial
|
||||||
|
|
||||||
from ebook_converter import constants_old
|
from ebook_converter import constants_old
|
||||||
from ebook_converter.constants_old import isfrozen, \
|
from ebook_converter.constants_old import \
|
||||||
__appname__, __version__, __author__, \
|
__appname__, __version__, __author__, \
|
||||||
config_dir
|
config_dir
|
||||||
from ebook_converter.ebooks.html_entities import html5_entities
|
from ebook_converter.ebooks.html_entities import html5_entities
|
||||||
@@ -18,7 +18,7 @@ from ebook_converter.ebooks.html_entities import html5_entities
|
|||||||
|
|
||||||
if False:
|
if False:
|
||||||
# Prevent pyflakes from complaining
|
# Prevent pyflakes from complaining
|
||||||
__appname__, __version__, isfrozen, __author__, config_dir
|
__appname__, __version__, __author__, config_dir
|
||||||
|
|
||||||
|
|
||||||
def init_mimetypes():
|
def init_mimetypes():
|
||||||
|
|||||||
@@ -16,25 +16,13 @@ Various run time constants.
|
|||||||
'''
|
'''
|
||||||
|
|
||||||
|
|
||||||
isfrozen = hasattr(sys, 'frozen')
|
FAKE_PROTOCOL = 'ebco'
|
||||||
isportable = os.getenv('CALIBRE_PORTABLE_BUILD') is not None
|
|
||||||
isxp = isoldvista = False
|
|
||||||
is64bit = sys.maxsize > (1 << 32)
|
|
||||||
FAKE_PROTOCOL, FAKE_HOST = 'clbr', 'internal.invalid'
|
|
||||||
VIEWER_APP_UID = 'com.calibre-ebook.viewer'
|
|
||||||
EDITOR_APP_UID = 'com.calibre-ebook.edit-book'
|
|
||||||
MAIN_APP_UID = 'com.calibre-ebook.main-gui'
|
|
||||||
STORE_DIALOG_APP_UID = 'com.calibre-ebook.store-dialog'
|
|
||||||
TOC_DIALOG_APP_UID = 'com.calibre-ebook.toc-editor'
|
|
||||||
try:
|
try:
|
||||||
preferred_encoding = locale.getpreferredencoding()
|
preferred_encoding = locale.getpreferredencoding()
|
||||||
codecs.lookup(preferred_encoding)
|
codecs.lookup(preferred_encoding)
|
||||||
except Exception:
|
except Exception:
|
||||||
preferred_encoding = 'utf-8'
|
preferred_encoding = 'utf-8'
|
||||||
|
|
||||||
fcntl = importlib.import_module('fcntl')
|
|
||||||
dark_link_color = '#6cb4ee'
|
|
||||||
|
|
||||||
|
|
||||||
filesystem_encoding = sys.getfilesystemencoding() or 'utf-8'
|
filesystem_encoding = sys.getfilesystemencoding() or 'utf-8'
|
||||||
try:
|
try:
|
||||||
@@ -44,6 +32,7 @@ try:
|
|||||||
# ascii bytestring if sys.getfilesystemencoding() == 'ascii', which is
|
# ascii bytestring if sys.getfilesystemencoding() == 'ascii', which is
|
||||||
# just plain dumb. This is fixed by the icu.py module which, when
|
# just plain dumb. This is fixed by the icu.py module which, when
|
||||||
# imported changes ascii to utf-8
|
# imported changes ascii to utf-8
|
||||||
|
# TODO(gryf): this is not true for py3
|
||||||
except Exception:
|
except Exception:
|
||||||
filesystem_encoding = 'utf-8'
|
filesystem_encoding = 'utf-8'
|
||||||
|
|
||||||
@@ -56,50 +45,6 @@ def debug():
|
|||||||
DEBUG = True
|
DEBUG = True
|
||||||
|
|
||||||
|
|
||||||
def _get_cache_dir():
|
|
||||||
import errno
|
|
||||||
confcache = os.path.join(config_dir, 'caches')
|
|
||||||
try:
|
|
||||||
os.makedirs(confcache)
|
|
||||||
except EnvironmentError as err:
|
|
||||||
if err.errno != errno.EEXIST:
|
|
||||||
raise
|
|
||||||
if isportable:
|
|
||||||
return confcache
|
|
||||||
ccd = os.getenv('CALIBRE_CACHE_DIRECTORY')
|
|
||||||
if ccd is not None:
|
|
||||||
ans = os.path.abspath(ccd)
|
|
||||||
try:
|
|
||||||
os.makedirs(ans)
|
|
||||||
return ans
|
|
||||||
except EnvironmentError as err:
|
|
||||||
if err.errno == errno.EEXIST:
|
|
||||||
return ans
|
|
||||||
|
|
||||||
candidate = os.getenv('XDG_CACHE_HOME', '~/.cache')
|
|
||||||
candidate = os.path.join(os.path.expanduser(candidate),
|
|
||||||
__appname__)
|
|
||||||
if isinstance(candidate, bytes):
|
|
||||||
try:
|
|
||||||
candidate = candidate.decode(filesystem_encoding)
|
|
||||||
except ValueError:
|
|
||||||
candidate = confcache
|
|
||||||
try:
|
|
||||||
os.makedirs(candidate)
|
|
||||||
except EnvironmentError as err:
|
|
||||||
if err.errno != errno.EEXIST:
|
|
||||||
candidate = confcache
|
|
||||||
return candidate
|
|
||||||
|
|
||||||
|
|
||||||
def cache_dir():
|
|
||||||
ans = getattr(cache_dir, 'ans', None)
|
|
||||||
if ans is None:
|
|
||||||
ans = cache_dir.ans = os.path.realpath(_get_cache_dir())
|
|
||||||
return ans
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
# plugins {{{
|
# plugins {{{
|
||||||
|
|
||||||
|
|
||||||
@@ -136,7 +81,7 @@ class Plugins(collections.Mapping):
|
|||||||
|
|
||||||
def __getitem__(self, name):
|
def __getitem__(self, name):
|
||||||
if name not in self.plugins:
|
if name not in self.plugins:
|
||||||
raise KeyError('No plugin named %r'%name)
|
raise KeyError('No plugin named %r' % name)
|
||||||
self.load_plugin(name)
|
self.load_plugin(name)
|
||||||
return self._plugins[name]
|
return self._plugins[name]
|
||||||
|
|
||||||
@@ -189,9 +134,3 @@ def get_version():
|
|||||||
v += '*'
|
v += '*'
|
||||||
|
|
||||||
return v
|
return v
|
||||||
|
|
||||||
|
|
||||||
def get_portable_base():
|
|
||||||
'Return path to the directory that contains calibre-portable.exe or None'
|
|
||||||
if isportable:
|
|
||||||
return os.path.dirname(os.path.dirname(os.getenv('CALIBRE_PORTABLE_BUILD')))
|
|
||||||
|
|||||||
Reference in New Issue
Block a user