mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-07 10:14:46 -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():
|
||||
# Redirect stdout, stdin and stderr to /dev/null
|
||||
from calibre.constants import plugins
|
||||
plugins['speedup'][0].detach(os.devnull)
|
||||
from calibre_extensions.speedup import detach
|
||||
detach(os.devnull)
|
||||
|
||||
|
||||
def set_helper():
|
||||
|
@ -68,7 +68,7 @@ if iswindows:
|
||||
# Windows {{{
|
||||
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.constants import plugins
|
||||
from calibre_extensions import winutil
|
||||
import subprocess
|
||||
oprefs = JSONConfig('windows_open_with')
|
||||
|
||||
@ -145,7 +145,7 @@ if iswindows:
|
||||
print('Running Open With commandline%s:' % console, repr(entry['cmdline']), ' |==> ', repr(cmdline))
|
||||
try:
|
||||
with sanitize_env_vars():
|
||||
plugins['winutil'][0].run_cmdline(cmdline, flags, 2000)
|
||||
winutil.run_cmdline(cmdline, flags, 2000)
|
||||
except Exception as err:
|
||||
return error_dialog(
|
||||
parent, _('Failed to run'), _(
|
||||
|
@ -7,15 +7,11 @@ from PyQt5.Qt import (
|
||||
QWidget
|
||||
)
|
||||
|
||||
from calibre.constants import plugins
|
||||
from calibre_extensions.progress_indicator import (
|
||||
QProgressIndicator as ProgressIndicator, draw_snake_spinner
|
||||
)
|
||||
|
||||
pi, err = plugins['progress_indicator']
|
||||
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
|
||||
draw_snake_spinner
|
||||
|
||||
|
||||
class WaitPanel(QWidget):
|
||||
|
@ -4,11 +4,11 @@
|
||||
|
||||
|
||||
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):
|
||||
|
@ -11,7 +11,7 @@ from datetime import datetime, time as dtime, timedelta, MINYEAR, MAXYEAR
|
||||
from functools import partial
|
||||
|
||||
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.localization import lcdata
|
||||
from polyglot.builtins import unicode_type, native_string_type
|
||||
@ -33,7 +33,8 @@ if iswindows:
|
||||
del ctypes, LOCALE_SSHORTDATE, buf, LOCALE_USER_DEFAULT
|
||||
elif ismacos:
|
||||
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')
|
||||
except:
|
||||
parse_date_day_first = False
|
||||
|
@ -8,9 +8,9 @@ __docformat__ = 'restructuredtext en'
|
||||
|
||||
import threading
|
||||
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):
|
||||
@ -30,9 +30,6 @@ def same_thread(func):
|
||||
return check_thread
|
||||
|
||||
|
||||
FreeTypeError = getattr(plugins['freetype'][0], 'FreeTypeError', Exception)
|
||||
|
||||
|
||||
class Face(object):
|
||||
|
||||
def __init__(self, face):
|
||||
@ -71,11 +68,7 @@ class FreeType(object):
|
||||
|
||||
def __init__(self):
|
||||
self.start_thread = threading.current_thread()
|
||||
ft, ft_err = plugins['freetype']
|
||||
if ft_err:
|
||||
raise RuntimeError('Failed to load FreeType module with error: %s'
|
||||
% ft_err)
|
||||
self.ft = ft.FreeType()
|
||||
self.ft = _FreeType()
|
||||
|
||||
@same_thread
|
||||
def load_font(self, data):
|
||||
|
@ -11,7 +11,7 @@ from collections import defaultdict
|
||||
from threading import Thread
|
||||
|
||||
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)
|
||||
from calibre.utils.fonts.metadata import FontMetadata, UnsupportedFont
|
||||
from calibre.utils.icu import sort_key
|
||||
@ -100,9 +100,7 @@ def fc_list():
|
||||
|
||||
def font_dirs():
|
||||
if iswindows:
|
||||
winutil, err = plugins['winutil']
|
||||
if err:
|
||||
raise RuntimeError('Failed to load winutil: %s'%err)
|
||||
from calibre_extensions import winutil
|
||||
paths = {os.path.normcase(r'C:\Windows\Fonts')}
|
||||
for which in (winutil.CSIDL_FONTS, winutil.CSIDL_LOCAL_APPDATA, winutil.CSIDL_APPDATA):
|
||||
try:
|
||||
|
@ -6,11 +6,7 @@
|
||||
from datetime import datetime
|
||||
|
||||
from dateutil.tz import tzlocal, tzutc, tzoffset
|
||||
|
||||
from calibre.constants import plugins
|
||||
speedup, err = plugins['speedup']
|
||||
if not speedup:
|
||||
raise RuntimeError(err)
|
||||
from calibre_extensions import speedup
|
||||
|
||||
|
||||
class SafeLocalTimeZone(tzlocal):
|
||||
|
@ -7,7 +7,7 @@ import os
|
||||
import shutil
|
||||
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.ptempfile import TemporaryDirectory
|
||||
from calibre.utils.ipc.simple_worker import WorkerError, fork_job
|
||||
@ -15,9 +15,7 @@ from polyglot.builtins import unicode_type
|
||||
|
||||
|
||||
def get_podofo():
|
||||
podofo, podofo_err = plugins['podofo']
|
||||
if podofo is None:
|
||||
raise RuntimeError('Failed to load podofo: %s'%podofo_err)
|
||||
from calibre_extensions import podofo
|
||||
return podofo
|
||||
|
||||
|
||||
|
@ -9,7 +9,7 @@ __docformat__ = 'restructuredtext en'
|
||||
import os, shutil, time, sys
|
||||
|
||||
from calibre import isbytestring
|
||||
from calibre.constants import (iswindows, ismacos, plugins, filesystem_encoding,
|
||||
from calibre.constants import (iswindows, ismacos, filesystem_encoding,
|
||||
islinux)
|
||||
from polyglot.builtins import unicode_type
|
||||
|
||||
@ -18,6 +18,7 @@ recycle = None
|
||||
if iswindows:
|
||||
from calibre.utils.ipc import eintr_retry_call
|
||||
from threading import Lock
|
||||
from calibre_extensions import winutil
|
||||
recycler = None
|
||||
rlock = Lock()
|
||||
|
||||
@ -28,7 +29,7 @@ if iswindows:
|
||||
recycler = start_pipe_worker('from calibre.utils.recycle_bin import recycler_main; recycler_main()')
|
||||
|
||||
def recycle_path(path):
|
||||
plugins['winutil'][0].move_to_trash(unicode_type(path))
|
||||
winutil.move_to_trash(unicode_type(path))
|
||||
|
||||
def recycler_main():
|
||||
stdin = getattr(sys.stdin, 'buffer', sys.stdin)
|
||||
@ -86,12 +87,12 @@ if iswindows:
|
||||
return delegate_recycle(path)
|
||||
|
||||
elif ismacos:
|
||||
u = plugins['cocoa'][0]
|
||||
if hasattr(u, 'send2trash'):
|
||||
from calibre_extensions.cocoa import send2trash
|
||||
|
||||
def osx_recycle(path):
|
||||
if isbytestring(path):
|
||||
path = path.decode(filesystem_encoding)
|
||||
u.send2trash(path)
|
||||
send2trash(path)
|
||||
recycle = osx_recycle
|
||||
elif islinux:
|
||||
from calibre.utils.linux_trash import send2trash
|
||||
|
Loading…
x
Reference in New Issue
Block a user