mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-06-23 15:30:45 -04:00
Remove more uses of the plugins dict
This commit is contained in:
parent
c41a389437
commit
20150e3368
@ -21,8 +21,8 @@ def read_user_env_vars():
|
|||||||
|
|
||||||
def nuke_stdout():
|
def nuke_stdout():
|
||||||
# Redirect stdout, stdin and stderr to /dev/null
|
# Redirect stdout, stdin and stderr to /dev/null
|
||||||
from calibre.constants import plugins
|
from calibre_extensions.speedup import detach
|
||||||
plugins['speedup'][0].detach(os.devnull)
|
detach(os.devnull)
|
||||||
|
|
||||||
|
|
||||||
def set_helper():
|
def set_helper():
|
||||||
|
@ -68,7 +68,7 @@ if iswindows:
|
|||||||
# Windows {{{
|
# Windows {{{
|
||||||
from calibre.utils.winreg.default_programs import find_programs, friendly_app_name
|
from calibre.utils.winreg.default_programs import find_programs, friendly_app_name
|
||||||
from calibre.utils.open_with.windows import load_icon_resource, load_icon_for_cmdline
|
from calibre.utils.open_with.windows import load_icon_resource, load_icon_for_cmdline
|
||||||
from calibre.constants import plugins
|
from calibre_extensions import winutil
|
||||||
import subprocess
|
import subprocess
|
||||||
oprefs = JSONConfig('windows_open_with')
|
oprefs = JSONConfig('windows_open_with')
|
||||||
|
|
||||||
@ -145,7 +145,7 @@ if iswindows:
|
|||||||
print('Running Open With commandline%s:' % console, repr(entry['cmdline']), ' |==> ', repr(cmdline))
|
print('Running Open With commandline%s:' % console, repr(entry['cmdline']), ' |==> ', repr(cmdline))
|
||||||
try:
|
try:
|
||||||
with sanitize_env_vars():
|
with sanitize_env_vars():
|
||||||
plugins['winutil'][0].run_cmdline(cmdline, flags, 2000)
|
winutil.run_cmdline(cmdline, flags, 2000)
|
||||||
except Exception as err:
|
except Exception as err:
|
||||||
return error_dialog(
|
return error_dialog(
|
||||||
parent, _('Failed to run'), _(
|
parent, _('Failed to run'), _(
|
||||||
|
@ -7,15 +7,11 @@ from PyQt5.Qt import (
|
|||||||
QWidget
|
QWidget
|
||||||
)
|
)
|
||||||
|
|
||||||
from calibre.constants import plugins
|
from calibre_extensions.progress_indicator import (
|
||||||
|
QProgressIndicator as ProgressIndicator, draw_snake_spinner
|
||||||
|
)
|
||||||
|
|
||||||
pi, err = plugins['progress_indicator']
|
draw_snake_spinner
|
||||||
if err:
|
|
||||||
raise RuntimeError('Failed to import the progress_indicator plugin with error: {}'.format(err))
|
|
||||||
|
|
||||||
|
|
||||||
ProgressIndicator = pi.QProgressIndicator
|
|
||||||
draw_snake_spinner = pi.draw_snake_spinner
|
|
||||||
|
|
||||||
|
|
||||||
class WaitPanel(QWidget):
|
class WaitPanel(QWidget):
|
||||||
|
@ -4,11 +4,11 @@
|
|||||||
|
|
||||||
|
|
||||||
import re
|
import re
|
||||||
from polyglot.builtins import codepoint_to_chr, map, range, filter
|
|
||||||
from polyglot.html_entities import name2codepoint
|
|
||||||
from calibre.constants import plugins, preferred_encoding
|
|
||||||
|
|
||||||
_ncxc = plugins['speedup'][0].clean_xml_chars
|
from calibre.constants import preferred_encoding
|
||||||
|
from calibre_extensions.speedup import clean_xml_chars as _ncxc
|
||||||
|
from polyglot.builtins import codepoint_to_chr, filter, map, range
|
||||||
|
from polyglot.html_entities import name2codepoint
|
||||||
|
|
||||||
|
|
||||||
def native_clean_xml_chars(x):
|
def native_clean_xml_chars(x):
|
||||||
|
@ -11,7 +11,7 @@ from datetime import datetime, time as dtime, timedelta, MINYEAR, MAXYEAR
|
|||||||
from functools import partial
|
from functools import partial
|
||||||
|
|
||||||
from calibre import strftime
|
from calibre import strftime
|
||||||
from calibre.constants import iswindows, ismacos, plugins, preferred_encoding
|
from calibre.constants import iswindows, ismacos, preferred_encoding
|
||||||
from calibre.utils.iso8601 import utc_tz, local_tz, UNDEFINED_DATE
|
from calibre.utils.iso8601 import utc_tz, local_tz, UNDEFINED_DATE
|
||||||
from calibre.utils.localization import lcdata
|
from calibre.utils.localization import lcdata
|
||||||
from polyglot.builtins import unicode_type, native_string_type
|
from polyglot.builtins import unicode_type, native_string_type
|
||||||
@ -33,7 +33,8 @@ if iswindows:
|
|||||||
del ctypes, LOCALE_SSHORTDATE, buf, LOCALE_USER_DEFAULT
|
del ctypes, LOCALE_SSHORTDATE, buf, LOCALE_USER_DEFAULT
|
||||||
elif ismacos:
|
elif ismacos:
|
||||||
try:
|
try:
|
||||||
date_fmt = plugins['usbobserver'][0].date_format()
|
from calibre_extensions.usbobserver import date_format
|
||||||
|
date_fmt = date_format()
|
||||||
parse_date_day_first = date_fmt.index('d') < date_fmt.index('M')
|
parse_date_day_first = date_fmt.index('d') < date_fmt.index('M')
|
||||||
except:
|
except:
|
||||||
parse_date_day_first = False
|
parse_date_day_first = False
|
||||||
|
@ -8,9 +8,9 @@ __docformat__ = 'restructuredtext en'
|
|||||||
|
|
||||||
import threading
|
import threading
|
||||||
from functools import wraps
|
from functools import wraps
|
||||||
from polyglot.builtins import map, unicode_type
|
|
||||||
|
|
||||||
from calibre.constants import plugins
|
from calibre_extensions.freetype import FreeType as _FreeType
|
||||||
|
from polyglot.builtins import map, unicode_type
|
||||||
|
|
||||||
|
|
||||||
class ThreadingViolation(Exception):
|
class ThreadingViolation(Exception):
|
||||||
@ -30,9 +30,6 @@ def same_thread(func):
|
|||||||
return check_thread
|
return check_thread
|
||||||
|
|
||||||
|
|
||||||
FreeTypeError = getattr(plugins['freetype'][0], 'FreeTypeError', Exception)
|
|
||||||
|
|
||||||
|
|
||||||
class Face(object):
|
class Face(object):
|
||||||
|
|
||||||
def __init__(self, face):
|
def __init__(self, face):
|
||||||
@ -71,11 +68,7 @@ class FreeType(object):
|
|||||||
|
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
self.start_thread = threading.current_thread()
|
self.start_thread = threading.current_thread()
|
||||||
ft, ft_err = plugins['freetype']
|
self.ft = _FreeType()
|
||||||
if ft_err:
|
|
||||||
raise RuntimeError('Failed to load FreeType module with error: %s'
|
|
||||||
% ft_err)
|
|
||||||
self.ft = ft.FreeType()
|
|
||||||
|
|
||||||
@same_thread
|
@same_thread
|
||||||
def load_font(self, data):
|
def load_font(self, data):
|
||||||
|
@ -11,7 +11,7 @@ from collections import defaultdict
|
|||||||
from threading import Thread
|
from threading import Thread
|
||||||
|
|
||||||
from calibre import walk, prints, as_unicode
|
from calibre import walk, prints, as_unicode
|
||||||
from calibre.constants import (config_dir, iswindows, ismacos, plugins, DEBUG,
|
from calibre.constants import (config_dir, iswindows, ismacos, DEBUG,
|
||||||
isworker, filesystem_encoding)
|
isworker, filesystem_encoding)
|
||||||
from calibre.utils.fonts.metadata import FontMetadata, UnsupportedFont
|
from calibre.utils.fonts.metadata import FontMetadata, UnsupportedFont
|
||||||
from calibre.utils.icu import sort_key
|
from calibre.utils.icu import sort_key
|
||||||
@ -100,9 +100,7 @@ def fc_list():
|
|||||||
|
|
||||||
def font_dirs():
|
def font_dirs():
|
||||||
if iswindows:
|
if iswindows:
|
||||||
winutil, err = plugins['winutil']
|
from calibre_extensions import winutil
|
||||||
if err:
|
|
||||||
raise RuntimeError('Failed to load winutil: %s'%err)
|
|
||||||
paths = {os.path.normcase(r'C:\Windows\Fonts')}
|
paths = {os.path.normcase(r'C:\Windows\Fonts')}
|
||||||
for which in (winutil.CSIDL_FONTS, winutil.CSIDL_LOCAL_APPDATA, winutil.CSIDL_APPDATA):
|
for which in (winutil.CSIDL_FONTS, winutil.CSIDL_LOCAL_APPDATA, winutil.CSIDL_APPDATA):
|
||||||
try:
|
try:
|
||||||
|
@ -6,11 +6,7 @@
|
|||||||
from datetime import datetime
|
from datetime import datetime
|
||||||
|
|
||||||
from dateutil.tz import tzlocal, tzutc, tzoffset
|
from dateutil.tz import tzlocal, tzutc, tzoffset
|
||||||
|
from calibre_extensions import speedup
|
||||||
from calibre.constants import plugins
|
|
||||||
speedup, err = plugins['speedup']
|
|
||||||
if not speedup:
|
|
||||||
raise RuntimeError(err)
|
|
||||||
|
|
||||||
|
|
||||||
class SafeLocalTimeZone(tzlocal):
|
class SafeLocalTimeZone(tzlocal):
|
||||||
|
@ -7,7 +7,7 @@ import os
|
|||||||
import shutil
|
import shutil
|
||||||
import sys
|
import sys
|
||||||
|
|
||||||
from calibre.constants import plugins, preferred_encoding
|
from calibre.constants import preferred_encoding
|
||||||
from calibre.ebooks.metadata import authors_to_string
|
from calibre.ebooks.metadata import authors_to_string
|
||||||
from calibre.ptempfile import TemporaryDirectory
|
from calibre.ptempfile import TemporaryDirectory
|
||||||
from calibre.utils.ipc.simple_worker import WorkerError, fork_job
|
from calibre.utils.ipc.simple_worker import WorkerError, fork_job
|
||||||
@ -15,9 +15,7 @@ from polyglot.builtins import unicode_type
|
|||||||
|
|
||||||
|
|
||||||
def get_podofo():
|
def get_podofo():
|
||||||
podofo, podofo_err = plugins['podofo']
|
from calibre_extensions import podofo
|
||||||
if podofo is None:
|
|
||||||
raise RuntimeError('Failed to load podofo: %s'%podofo_err)
|
|
||||||
return podofo
|
return podofo
|
||||||
|
|
||||||
|
|
||||||
|
@ -9,7 +9,7 @@ __docformat__ = 'restructuredtext en'
|
|||||||
import os, shutil, time, sys
|
import os, shutil, time, sys
|
||||||
|
|
||||||
from calibre import isbytestring
|
from calibre import isbytestring
|
||||||
from calibre.constants import (iswindows, ismacos, plugins, filesystem_encoding,
|
from calibre.constants import (iswindows, ismacos, filesystem_encoding,
|
||||||
islinux)
|
islinux)
|
||||||
from polyglot.builtins import unicode_type
|
from polyglot.builtins import unicode_type
|
||||||
|
|
||||||
@ -18,6 +18,7 @@ recycle = None
|
|||||||
if iswindows:
|
if iswindows:
|
||||||
from calibre.utils.ipc import eintr_retry_call
|
from calibre.utils.ipc import eintr_retry_call
|
||||||
from threading import Lock
|
from threading import Lock
|
||||||
|
from calibre_extensions import winutil
|
||||||
recycler = None
|
recycler = None
|
||||||
rlock = Lock()
|
rlock = Lock()
|
||||||
|
|
||||||
@ -28,7 +29,7 @@ if iswindows:
|
|||||||
recycler = start_pipe_worker('from calibre.utils.recycle_bin import recycler_main; recycler_main()')
|
recycler = start_pipe_worker('from calibre.utils.recycle_bin import recycler_main; recycler_main()')
|
||||||
|
|
||||||
def recycle_path(path):
|
def recycle_path(path):
|
||||||
plugins['winutil'][0].move_to_trash(unicode_type(path))
|
winutil.move_to_trash(unicode_type(path))
|
||||||
|
|
||||||
def recycler_main():
|
def recycler_main():
|
||||||
stdin = getattr(sys.stdin, 'buffer', sys.stdin)
|
stdin = getattr(sys.stdin, 'buffer', sys.stdin)
|
||||||
@ -86,13 +87,13 @@ if iswindows:
|
|||||||
return delegate_recycle(path)
|
return delegate_recycle(path)
|
||||||
|
|
||||||
elif ismacos:
|
elif ismacos:
|
||||||
u = plugins['cocoa'][0]
|
from calibre_extensions.cocoa import send2trash
|
||||||
if hasattr(u, 'send2trash'):
|
|
||||||
def osx_recycle(path):
|
def osx_recycle(path):
|
||||||
if isbytestring(path):
|
if isbytestring(path):
|
||||||
path = path.decode(filesystem_encoding)
|
path = path.decode(filesystem_encoding)
|
||||||
u.send2trash(path)
|
send2trash(path)
|
||||||
recycle = osx_recycle
|
recycle = osx_recycle
|
||||||
elif islinux:
|
elif islinux:
|
||||||
from calibre.utils.linux_trash import send2trash
|
from calibre.utils.linux_trash import send2trash
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user