mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
Remove more uses of the plugins dict
This commit is contained in:
parent
4d47176100
commit
c41a389437
@ -5,23 +5,24 @@
|
||||
__license__ = 'GPL v3'
|
||||
__copyright__ = '2014, Kovid Goyal <kovid at kovidgoyal.net>'
|
||||
|
||||
import re, textwrap
|
||||
import re
|
||||
import textwrap
|
||||
from bisect import bisect
|
||||
from functools import partial
|
||||
|
||||
from PyQt5.Qt import (
|
||||
QAbstractItemModel, QModelIndex, Qt, pyqtSignal, QApplication, QHBoxLayout,
|
||||
QTreeView, QSize, QGridLayout, QAbstractListModel, QListView, QPen, QMenu,
|
||||
QStyledItemDelegate, QSplitter, QLabel, QSizePolicy, QIcon, QMimeData,
|
||||
QPushButton, QToolButton, QInputMethodEvent, QCheckBox)
|
||||
QAbstractItemModel, QAbstractListModel, QApplication, QCheckBox, QGridLayout,
|
||||
QHBoxLayout, QIcon, QInputMethodEvent, QLabel, QListView, QMenu, QMimeData,
|
||||
QModelIndex, QPen, QPushButton, QSize, QSizePolicy, QSplitter,
|
||||
QStyledItemDelegate, Qt, QToolButton, QTreeView, pyqtSignal
|
||||
)
|
||||
|
||||
from calibre.constants import plugins
|
||||
from calibre.gui2.widgets2 import HistoryLineEdit2
|
||||
from calibre.gui2.tweak_book import tprefs
|
||||
from calibre.gui2.tweak_book.widgets import Dialog, BusyCursor
|
||||
from calibre.gui2.tweak_book.widgets import BusyCursor, Dialog
|
||||
from calibre.gui2.widgets2 import HistoryLineEdit2
|
||||
from calibre.utils.icu import safe_chr as codepoint_to_chr
|
||||
from calibre.utils.unicode_names import character_name_from_code, points_for_word
|
||||
from polyglot.builtins import unicode_type, range, map
|
||||
from calibre_extensions.progress_indicator import set_no_activate_on_click
|
||||
from polyglot.builtins import map, range, unicode_type
|
||||
|
||||
ROOT = QModelIndex()
|
||||
|
||||
@ -459,9 +460,7 @@ class CategoryView(QTreeView):
|
||||
self.setAnimated(True)
|
||||
self.activated.connect(self.item_activated)
|
||||
self.clicked.connect(self.item_activated)
|
||||
pi = plugins['progress_indicator'][0]
|
||||
if hasattr(pi, 'set_no_activate_on_click'):
|
||||
pi.set_no_activate_on_click(self)
|
||||
set_no_activate_on_click(self)
|
||||
self.initialized = False
|
||||
self.setExpandsOnDoubleClick(False)
|
||||
|
||||
@ -600,9 +599,7 @@ class CharView(QListView):
|
||||
self.setContextMenuPolicy(Qt.CustomContextMenu)
|
||||
self.customContextMenuRequested.connect(self.context_menu)
|
||||
self.showing_favorites = False
|
||||
pi = plugins['progress_indicator'][0]
|
||||
if hasattr(pi, 'set_no_activate_on_click'):
|
||||
pi.set_no_activate_on_click(self)
|
||||
set_no_activate_on_click(self)
|
||||
self.activated.connect(self.item_activated)
|
||||
self.clicked.connect(self.item_activated)
|
||||
|
||||
|
@ -5,16 +5,11 @@
|
||||
__license__ = 'GPL v3'
|
||||
__copyright__ = '2014, Kovid Goyal <kovid at kovidgoyal.net>'
|
||||
|
||||
from calibre.constants import plugins
|
||||
|
||||
|
||||
def load_patience_module():
|
||||
p, err = plugins['_patiencediff_c']
|
||||
if err:
|
||||
raise ImportError('Failed to import the PatienceDiff C module with error: %r' % err)
|
||||
return p
|
||||
from calibre_extensions import _patiencediff_c
|
||||
return _patiencediff_c
|
||||
|
||||
|
||||
def get_sequence_matcher():
|
||||
return load_patience_module().PatienceSequenceMatcher_c
|
||||
|
||||
|
@ -6,21 +6,24 @@ __license__ = 'GPL v3'
|
||||
__copyright__ = '2013, Kovid Goyal <kovid at kovidgoyal.net>'
|
||||
|
||||
import re
|
||||
from functools import partial
|
||||
from collections import namedtuple
|
||||
|
||||
from functools import partial
|
||||
from PyQt5.Qt import QFont, QTextBlockUserData, QTextCharFormat
|
||||
|
||||
from calibre.ebooks.oeb.polish.spell import html_spell_tags, xml_spell_tags, patterns
|
||||
from calibre.spell.dictionary import parse_lang_code
|
||||
from calibre.spell.break_iterator import split_into_words_and_positions
|
||||
from calibre.ebooks.oeb.polish.spell import html_spell_tags, patterns, xml_spell_tags
|
||||
from calibre.gui2.tweak_book import dictionaries, tprefs, verify_link
|
||||
from calibre.gui2.tweak_book.editor import (
|
||||
syntax_text_char_format, SPELL_PROPERTY, SPELL_LOCALE_PROPERTY,
|
||||
store_locale, LINK_PROPERTY, TAG_NAME_PROPERTY, CLASS_ATTRIBUTE_PROPERTY)
|
||||
CLASS_ATTRIBUTE_PROPERTY, LINK_PROPERTY, SPELL_LOCALE_PROPERTY, SPELL_PROPERTY,
|
||||
TAG_NAME_PROPERTY, store_locale, syntax_text_char_format
|
||||
)
|
||||
from calibre.gui2.tweak_book.editor.syntax.base import SyntaxHighlighter, run_loop
|
||||
from calibre.gui2.tweak_book.editor.syntax.css import (
|
||||
create_formats as create_css_formats, state_map as css_state_map, CSSState, CSSUserData)
|
||||
CSSState, CSSUserData, create_formats as create_css_formats,
|
||||
state_map as css_state_map
|
||||
)
|
||||
from calibre.spell.break_iterator import split_into_words_and_positions
|
||||
from calibre.spell.dictionary import parse_lang_code
|
||||
from calibre_extensions import html_syntax_highlighter as _speedup
|
||||
from polyglot.builtins import iteritems
|
||||
|
||||
cdata_tags = frozenset(['title', 'textarea', 'style', 'script', 'xmp', 'iframe', 'noembed', 'noframes', 'noscript'])
|
||||
@ -62,9 +65,6 @@ def refresh_spell_check_status():
|
||||
do_spell_check = tprefs['inline_spell_check'] and hasattr(dictionaries, 'active_user_dictionaries')
|
||||
|
||||
|
||||
from calibre.constants import plugins
|
||||
|
||||
_speedup = plugins['html_syntax_highlighter'][0]
|
||||
Tag = _speedup.Tag
|
||||
bold_tags, italic_tags = _speedup.bold_tags, _speedup.italic_tags
|
||||
State = _speedup.State
|
||||
@ -522,6 +522,7 @@ class XMLHighlighter(Highlighter):
|
||||
def profile():
|
||||
import sys
|
||||
from PyQt5.Qt import QTextDocument
|
||||
|
||||
from calibre.gui2 import Application
|
||||
from calibre.gui2.tweak_book import set_book_locale
|
||||
from calibre.gui2.tweak_book.editor.themes import get_theme
|
||||
|
@ -9,7 +9,6 @@ import sys
|
||||
import textwrap
|
||||
from collections import Counter, OrderedDict, defaultdict
|
||||
from functools import partial
|
||||
|
||||
from PyQt5.Qt import (
|
||||
QApplication, QCheckBox, QDialog, QDialogButtonBox, QFont, QFormLayout,
|
||||
QGridLayout, QIcon, QInputDialog, QLabel, QLineEdit, QListWidget,
|
||||
@ -18,7 +17,7 @@ from PyQt5.Qt import (
|
||||
QVBoxLayout, QWidget, pyqtSignal
|
||||
)
|
||||
|
||||
from calibre import human_readable, plugins, sanitize_file_name
|
||||
from calibre import human_readable, sanitize_file_name
|
||||
from calibre.ebooks.oeb.base import OEB_DOCS, OEB_STYLES
|
||||
from calibre.ebooks.oeb.polish.container import OEB_FONTS, guess_type
|
||||
from calibre.ebooks.oeb.polish.cover import (
|
||||
@ -39,6 +38,7 @@ from calibre.gui2.tweak_book.editor import syntax_from_mime
|
||||
from calibre.gui2.tweak_book.templates import template_for
|
||||
from calibre.utils.fonts.utils import get_font_names
|
||||
from calibre.utils.icu import numeric_sort_key
|
||||
from calibre_extensions.progress_indicator import set_no_activate_on_click
|
||||
from polyglot.binary import as_hex_unicode
|
||||
from polyglot.builtins import filter, iteritems, itervalues, map, range, unicode_type
|
||||
|
||||
@ -191,7 +191,7 @@ class ItemDelegate(QStyledItemDelegate): # {{{
|
||||
class OpenWithHandler(object): # {{{
|
||||
|
||||
def add_open_with_actions(self, menu, file_name):
|
||||
from calibre.gui2.open_with import populate_menu, edit_programs
|
||||
from calibre.gui2.open_with import edit_programs, populate_menu
|
||||
fmt = file_name.rpartition('.')[-1].lower()
|
||||
if not fmt:
|
||||
return
|
||||
@ -242,9 +242,7 @@ class FileList(QTreeWidget, OpenWithHandler):
|
||||
make_view_use_window_background(self)
|
||||
self.categories = {}
|
||||
self.ordered_selected_indexes = False
|
||||
pi = plugins['progress_indicator'][0]
|
||||
if hasattr(pi, 'set_no_activate_on_click'):
|
||||
pi.set_no_activate_on_click(self)
|
||||
set_no_activate_on_click(self)
|
||||
self.current_edited_name = None
|
||||
self.delegate = ItemDelegate(self)
|
||||
self.delegate.rename_requested.connect(self.rename_requested)
|
||||
|
@ -5,38 +5,48 @@
|
||||
__license__ = 'GPL v3'
|
||||
__copyright__ = '2014, Kovid Goyal <kovid at kovidgoyal.net>'
|
||||
|
||||
import os, sys
|
||||
from collections import defaultdict, OrderedDict
|
||||
from itertools import chain
|
||||
from threading import Thread
|
||||
import os
|
||||
import sys
|
||||
from collections import OrderedDict, defaultdict
|
||||
from functools import partial
|
||||
|
||||
from itertools import chain
|
||||
from PyQt5.Qt import (
|
||||
QGridLayout, QApplication, QTreeWidget, QTreeWidgetItem, Qt, QFont, QSize,
|
||||
QStackedLayout, QLabel, QVBoxLayout, QWidget, QPushButton, QIcon, QMenu,
|
||||
QDialogButtonBox, QLineEdit, QDialog, QToolButton, QFormLayout, QHBoxLayout,
|
||||
pyqtSignal, QAbstractTableModel, QModelIndex, QTimer, QTableView, QCheckBox,
|
||||
QComboBox, QListWidget, QListWidgetItem, QInputDialog, QPlainTextEdit, QKeySequence,
|
||||
QT_VERSION_STR)
|
||||
QT_VERSION_STR, QAbstractTableModel, QApplication, QCheckBox, QComboBox, QDialog,
|
||||
QDialogButtonBox, QFont, QFormLayout, QGridLayout, QHBoxLayout, QIcon,
|
||||
QInputDialog, QKeySequence, QLabel, QLineEdit, QListWidget, QListWidgetItem,
|
||||
QMenu, QModelIndex, QPlainTextEdit, QPushButton, QSize, QStackedLayout, Qt,
|
||||
QTableView, QTimer, QToolButton, QTreeWidget, QTreeWidgetItem, QVBoxLayout,
|
||||
QWidget, pyqtSignal
|
||||
)
|
||||
from threading import Thread
|
||||
|
||||
from calibre.constants import __appname__, plugins
|
||||
from calibre.ebooks.oeb.polish.spell import replace_word, get_all_words, merge_locations, get_checkable_file_names, undo_replace_word
|
||||
from calibre.constants import __appname__
|
||||
from calibre.ebooks.oeb.polish.spell import (
|
||||
get_all_words, get_checkable_file_names, merge_locations, replace_word,
|
||||
undo_replace_word
|
||||
)
|
||||
from calibre.gui2 import choose_files, error_dialog
|
||||
from calibre.gui2.complete2 import LineEdit
|
||||
from calibre.gui2.languages import LanguagesEdit
|
||||
from calibre.gui2.progress_indicator import ProgressIndicator
|
||||
from calibre.gui2.tweak_book import dictionaries, current_container, set_book_locale, tprefs, editors
|
||||
from calibre.gui2.tweak_book import (
|
||||
current_container, dictionaries, editors, set_book_locale, tprefs
|
||||
)
|
||||
from calibre.gui2.tweak_book.widgets import Dialog
|
||||
from calibre.gui2.widgets2 import FlowLayout
|
||||
from calibre.spell import DictionaryLocale
|
||||
from calibre.spell.dictionary import (
|
||||
builtin_dictionaries, custom_dictionaries, best_locale_for_language,
|
||||
get_dictionary, dprefs, remove_dictionary, rename_dictionary)
|
||||
from calibre.spell.import_from import import_from_oxt
|
||||
from calibre.spell.break_iterator import split_into_words
|
||||
from calibre.utils.localization import calibre_langcode_to_name, get_language, get_lang, canonicalize_lang
|
||||
from calibre.utils.icu import sort_key, primary_sort_key, primary_contains, contains
|
||||
from polyglot.builtins import iteritems, unicode_type, range, filter
|
||||
from calibre.spell.dictionary import (
|
||||
best_locale_for_language, builtin_dictionaries, custom_dictionaries, dprefs,
|
||||
get_dictionary, remove_dictionary, rename_dictionary
|
||||
)
|
||||
from calibre.spell.import_from import import_from_oxt
|
||||
from calibre.utils.icu import contains, primary_contains, primary_sort_key, sort_key
|
||||
from calibre.utils.localization import (
|
||||
calibre_langcode_to_name, canonicalize_lang, get_lang, get_language
|
||||
)
|
||||
from calibre_extensions.progress_indicator import set_no_activate_on_click
|
||||
from polyglot.builtins import filter, iteritems, range, unicode_type
|
||||
|
||||
LANG = 0
|
||||
COUNTRY = 1
|
||||
@ -923,7 +933,6 @@ class SpellCheck(Dialog):
|
||||
|
||||
def setup_ui(self):
|
||||
self.state_name = 'spell-check-table-state-' + QT_VERSION_STR.partition('.')[0]
|
||||
set_no_activate_on_click = plugins['progress_indicator'][0].set_no_activate_on_click
|
||||
self.setWindowIcon(QIcon(I('spell-check.png')))
|
||||
self.l = l = QVBoxLayout(self)
|
||||
self.setLayout(l)
|
||||
|
@ -6,16 +6,17 @@ __license__ = 'GPL v3'
|
||||
__copyright__ = '2013, Kovid Goyal <kovid at kovidgoyal.net>'
|
||||
|
||||
from PyQt5.Qt import (
|
||||
QDialog, pyqtSignal, QIcon, QVBoxLayout, QDialogButtonBox, QStackedWidget,
|
||||
QAction, QMenu, QTreeWidget, QTreeWidgetItem, QGridLayout, QWidget, Qt,
|
||||
QSize, QStyledItemDelegate, QApplication, QTimer)
|
||||
QAction, QApplication, QDialog, QDialogButtonBox, QGridLayout, QIcon, QMenu,
|
||||
QSize, QStackedWidget, QStyledItemDelegate, Qt, QTimer, QTreeWidget,
|
||||
QTreeWidgetItem, QVBoxLayout, QWidget, pyqtSignal
|
||||
)
|
||||
|
||||
from calibre.constants import plugins
|
||||
from calibre.ebooks.oeb.polish.toc import commit_toc, get_toc
|
||||
from calibre.gui2 import error_dialog, make_view_use_window_background
|
||||
from calibre.gui2.toc.main import TOCView, ItemEdit
|
||||
from calibre.gui2.tweak_book import current_container, TOP, actions, tprefs
|
||||
from polyglot.builtins import unicode_type, range
|
||||
from calibre.gui2.toc.main import ItemEdit, TOCView
|
||||
from calibre.gui2.tweak_book import TOP, actions, current_container, tprefs
|
||||
from calibre_extensions.progress_indicator import set_no_activate_on_click
|
||||
from polyglot.builtins import range, unicode_type
|
||||
|
||||
|
||||
class TOCEditor(QDialog):
|
||||
@ -137,9 +138,7 @@ class TOCViewer(QWidget):
|
||||
self.view.customContextMenuRequested.connect(self.show_context_menu, type=Qt.QueuedConnection)
|
||||
self.view.itemActivated.connect(self.emit_navigate)
|
||||
self.view.itemPressed.connect(self.item_pressed)
|
||||
pi = plugins['progress_indicator'][0]
|
||||
if hasattr(pi, 'set_no_activate_on_click'):
|
||||
pi.set_no_activate_on_click(self.view)
|
||||
set_no_activate_on_click(self.view)
|
||||
self.view.itemDoubleClicked.connect(self.emit_navigate)
|
||||
l.addWidget(self.view)
|
||||
|
||||
|
@ -17,7 +17,7 @@ from PyQt5.Qt import (
|
||||
QPixmap, QRect, QPlainTextEdit, QMimeData)
|
||||
|
||||
from calibre import prepare_string_for_xml, human_readable
|
||||
from calibre.constants import iswindows, plugins
|
||||
from calibre.constants import iswindows
|
||||
from calibre.ebooks.oeb.polish.cover import get_raster_cover_name
|
||||
from calibre.ebooks.oeb.polish.utils import lead_text, guess_type
|
||||
from calibre.gui2 import error_dialog, choose_files, choose_save_file, info_dialog, choose_images
|
||||
@ -1230,7 +1230,7 @@ class PlainTextEdit(QPlainTextEdit): # {{{
|
||||
return True
|
||||
|
||||
def windows_ignore_altgr_shortcut(self, ev):
|
||||
winutil = plugins['winutil'][0]
|
||||
from calibre_extensions import winutil
|
||||
s = winutil.get_async_key_state(winutil.VK_RMENU) # VK_RMENU == R_ALT
|
||||
return s & 0x8000
|
||||
|
||||
|
@ -6,28 +6,27 @@ __license__ = 'GPL v3'
|
||||
__copyright__ = '2009, Kovid Goyal <kovid@kovidgoyal.net>'
|
||||
__docformat__ = 'restructuredtext en'
|
||||
|
||||
import os, traceback, re
|
||||
import os
|
||||
import re
|
||||
import traceback
|
||||
from contextlib import closing
|
||||
from PyQt5.Qt import (
|
||||
QAbstractListModel, QDir, QIcon, QItemSelection, QItemSelectionModel, Qt,
|
||||
QWizard, QWizardPage, pyqtSignal
|
||||
)
|
||||
|
||||
from PyQt5.Qt import (QWizard, QWizardPage, QIcon, Qt, QAbstractListModel,
|
||||
QItemSelectionModel, pyqtSignal, QItemSelection, QDir)
|
||||
from calibre import __appname__
|
||||
from calibre.constants import (filesystem_encoding, iswindows, plugins,
|
||||
isportable)
|
||||
from calibre.gui2.wizard.send_email import smtp_prefs
|
||||
from calibre.constants import filesystem_encoding, isportable, iswindows
|
||||
from calibre.gui2 import choose_dir, error_dialog
|
||||
from calibre.gui2.wizard.device_ui import Ui_WizardPage as DeviceUI
|
||||
from calibre.gui2.wizard.library_ui import Ui_WizardPage as LibraryUI
|
||||
from calibre.gui2.wizard.finish_ui import Ui_WizardPage as FinishUI
|
||||
from calibre.gui2.wizard.kindle_ui import Ui_WizardPage as KindleUI
|
||||
from calibre.gui2.wizard.library_ui import Ui_WizardPage as LibraryUI
|
||||
from calibre.gui2.wizard.send_email import smtp_prefs
|
||||
from calibre.gui2.wizard.stanza_ui import Ui_WizardPage as StanzaUI
|
||||
from calibre.utils.localization import localize_user_manual_link
|
||||
|
||||
from calibre.utils.config import dynamic, prefs
|
||||
from calibre.gui2 import choose_dir, error_dialog
|
||||
from polyglot.builtins import iteritems, unicode_type, map
|
||||
|
||||
if iswindows:
|
||||
winutil = plugins['winutil'][0]
|
||||
from calibre.utils.localization import localize_user_manual_link
|
||||
from polyglot.builtins import iteritems, map, unicode_type
|
||||
|
||||
# Devices {{{
|
||||
|
||||
@ -682,8 +681,9 @@ class LibraryPage(QWizardPage, LibraryUI):
|
||||
def init_languages(self):
|
||||
self.language.blockSignals(True)
|
||||
self.language.clear()
|
||||
from calibre.utils.localization import (available_translations,
|
||||
get_language, get_lang, get_lc_messages_path)
|
||||
from calibre.utils.localization import (
|
||||
available_translations, get_lang, get_language, get_lc_messages_path
|
||||
)
|
||||
lang = get_lang()
|
||||
lang = get_lc_messages_path(lang) if lang else lang
|
||||
if lang is None or lang not in available_translations():
|
||||
@ -709,9 +709,9 @@ class LibraryPage(QWizardPage, LibraryUI):
|
||||
prefs['language'] = unicode_type(self.language.itemData(self.language.currentIndex()) or '')
|
||||
from polyglot.builtins import builtins
|
||||
builtins.__dict__['_'] = lambda x: x
|
||||
from calibre.utils.localization import set_translators
|
||||
from calibre.gui2 import qt_app
|
||||
from calibre.ebooks.metadata.book.base import reset_field_metadata
|
||||
from calibre.gui2 import qt_app
|
||||
from calibre.utils.localization import set_translators
|
||||
set_translators()
|
||||
qt_app.load_translations()
|
||||
self.retranslate.emit()
|
||||
|
@ -33,8 +33,8 @@ class LinuxNetworkStatus(object):
|
||||
class WindowsNetworkStatus(object):
|
||||
|
||||
def __init__(self):
|
||||
from calibre.constants import plugins
|
||||
self.winutil = plugins['winutil'][0]
|
||||
from calibre_extensions import winutil
|
||||
self.winutil = winutil
|
||||
|
||||
def __call__(self):
|
||||
if self.winutil is None:
|
||||
|
Loading…
x
Reference in New Issue
Block a user