mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
Delay load playform nad utils.config
This commit is contained in:
parent
0b88f9a399
commit
698362b7a1
@ -1762,7 +1762,7 @@ if __name__ == '__main__':
|
||||
for x in ('lxml', 'calibre.ebooks.BeautifulSoup', 'uuid',
|
||||
'calibre.utils.terminal', 'calibre.utils.magick', 'PIL', 'Image',
|
||||
'sqlite3', 'mechanize', 'httplib', 'xml', 'inspect', 'urllib',
|
||||
'calibre.utils.date'):
|
||||
'calibre.utils.date', 'calibre.utils.config', 'platform'):
|
||||
if x in sys.modules:
|
||||
ret = 1
|
||||
print (x, 'has been loaded by a plugin')
|
||||
|
@ -5,7 +5,7 @@ __copyright__ = '2010, Gregory Riker'
|
||||
__docformat__ = 'restructuredtext en'
|
||||
|
||||
|
||||
import cStringIO, ctypes, datetime, os, platform, re, shutil, sys, tempfile, time
|
||||
import cStringIO, ctypes, datetime, os, re, shutil, sys, tempfile, time
|
||||
|
||||
from calibre import fit_image, confirm_config_name, strftime as _strftime
|
||||
from calibre.constants import (
|
||||
@ -17,7 +17,7 @@ from calibre.devices.interface import DevicePlugin
|
||||
from calibre.ebooks.metadata import (author_to_author_sort, authors_to_string,
|
||||
MetaInformation, title_sort)
|
||||
from calibre.ebooks.metadata.book.base import Metadata
|
||||
from calibre.utils.config import config_dir, dynamic, prefs
|
||||
from calibre.utils.config_base import config_dir, prefs
|
||||
from calibre.utils.zipfile import ZipFile
|
||||
|
||||
DEBUG = CALIBRE_DEBUG
|
||||
@ -96,6 +96,7 @@ class AppleOpenFeedback(OpenFeedback):
|
||||
|
||||
def do_it(self, return_code):
|
||||
from calibre.utils.logging import default_log
|
||||
from calibre.utils.config import dynamic
|
||||
if return_code == self.Accepted:
|
||||
default_log.info(" Apple driver ENABLED")
|
||||
dynamic[confirm_config_name(self.cd.plugin.DISPLAY_DISABLE_DIALOG)] = False
|
||||
@ -882,6 +883,7 @@ class ITUNES(DriverBase):
|
||||
if False:
|
||||
# Display a dialog recommending using 'Connect to iTunes' if user hasn't
|
||||
# previously disabled the dialog
|
||||
from calibre.utils.config import dynamic
|
||||
if dynamic.get(confirm_config_name(self.DISPLAY_DISABLE_DIALOG), True):
|
||||
raise AppleOpenFeedback(self)
|
||||
else:
|
||||
@ -2480,6 +2482,7 @@ class ITUNES(DriverBase):
|
||||
'''
|
||||
|
||||
if DEBUG:
|
||||
import platform
|
||||
logger().info(" %s %s" % (__appname__, __version__))
|
||||
logger().info(" [OSX %s, %s %s (%s), %s driver version %d.%d.%d]" %
|
||||
(platform.mac_ver()[0],
|
||||
|
@ -10,7 +10,7 @@ from calibre.utils.icu import sort_key
|
||||
|
||||
from calibre.devices.usbms.books import Book as Book_
|
||||
from calibre.devices.usbms.books import CollectionsBookList
|
||||
from calibre.utils.config import prefs
|
||||
from calibre.utils.config_base import prefs
|
||||
from calibre.devices.usbms.driver import debug_print
|
||||
from calibre.ebooks.metadata import author_to_author_sort
|
||||
|
||||
|
@ -26,7 +26,7 @@ from calibre.devices.usbms.driver import USBMS, debug_print
|
||||
from calibre import prints
|
||||
from calibre.ptempfile import PersistentTemporaryFile
|
||||
from calibre.constants import DEBUG
|
||||
from calibre.utils.config import prefs
|
||||
from calibre.utils.config_base import prefs
|
||||
|
||||
|
||||
class KOBO(USBMS):
|
||||
|
@ -17,7 +17,6 @@ from calibre.devices.errors import PathError
|
||||
from calibre.devices.mtp.base import debug
|
||||
from calibre.devices.mtp.defaults import DeviceDefaults
|
||||
from calibre.ptempfile import SpooledTemporaryFile, PersistentTemporaryDirectory
|
||||
from calibre.utils.config import from_json, to_json, JSONConfig
|
||||
from calibre.utils.filenames import shorten_components_to
|
||||
|
||||
BASE = importlib.import_module('calibre.devices.mtp.%s.driver'%(
|
||||
@ -56,6 +55,7 @@ class MTP_DEVICE(BASE):
|
||||
|
||||
@property
|
||||
def prefs(self):
|
||||
from calibre.utils.config import JSONConfig
|
||||
if self._prefs is None:
|
||||
self._prefs = p = JSONConfig('mtp_devices')
|
||||
p.defaults['format_map'] = self.FORMATS
|
||||
@ -129,6 +129,7 @@ class MTP_DEVICE(BASE):
|
||||
# Device information {{{
|
||||
def _update_drive_info(self, storage, location_code, name=None):
|
||||
from calibre.utils.date import isoformat, now
|
||||
from calibre.utils.config import from_json, to_json
|
||||
import uuid
|
||||
f = storage.find_path((self.DRIVEINFO,))
|
||||
dinfo = {}
|
||||
|
@ -34,7 +34,7 @@ from calibre.library import current_library_name
|
||||
from calibre.library.server import server_config as content_server_config
|
||||
from calibre.ptempfile import PersistentTemporaryFile
|
||||
from calibre.utils.ipc import eintr_retry_call
|
||||
from calibre.utils.config import from_json, tweaks
|
||||
from calibre.utils.config_base import tweaks
|
||||
from calibre.utils.filenames import ascii_filename as sanitize, shorten_components_to
|
||||
from calibre.utils.mdns import (publish as publish_zeroconf, unpublish as
|
||||
unpublish_zeroconf, get_all_ips)
|
||||
@ -594,6 +594,7 @@ class SMART_DEVICE_APP(DeviceConfig, DevicePlugin):
|
||||
raise ControlError(desc='Device responded with incorrect information')
|
||||
|
||||
def _receive_from_client(self, print_debug_info=True):
|
||||
from calibre.utils.config import from_json
|
||||
extra_debug = self.settings().extra_customization[self.OPT_EXTRA_DEBUG]
|
||||
try:
|
||||
v = self._read_string_from_net()
|
||||
|
@ -12,7 +12,7 @@ from calibre.devices.mime import mime_type_ext
|
||||
from calibre.devices.interface import BookList as _BookList
|
||||
from calibre.constants import preferred_encoding
|
||||
from calibre import isbytestring, force_unicode
|
||||
from calibre.utils.config import device_prefs, tweaks
|
||||
from calibre.utils.config_base import tweaks
|
||||
from calibre.utils.icu import sort_key
|
||||
|
||||
class Book(Metadata):
|
||||
@ -124,6 +124,7 @@ class CollectionsBookList(BookList):
|
||||
|
||||
def get_collections(self, collection_attributes):
|
||||
from calibre.devices.usbms.driver import debug_print
|
||||
from calibre.utils.config import device_prefs
|
||||
debug_print('Starting get_collections:', device_prefs['manage_device_metadata'])
|
||||
debug_print('Renaming rules:', tweaks['sony_collection_renaming_rules'])
|
||||
debug_print('Formatting template:', tweaks['sony_collection_name_template'])
|
||||
|
@ -4,7 +4,7 @@ __license__ = 'GPL 3'
|
||||
__copyright__ = '2009, John Schember <john@nachtimwald.com>'
|
||||
__docformat__ = 'restructuredtext en'
|
||||
|
||||
from calibre.utils.config import Config, ConfigProxy
|
||||
from calibre.utils.config_base import Config, ConfigProxy
|
||||
|
||||
|
||||
class DeviceConfig(object):
|
||||
|
@ -20,7 +20,6 @@ from calibre.devices.usbms.cli import CLI
|
||||
from calibre.devices.usbms.device import Device
|
||||
from calibre.devices.usbms.books import BookList, Book
|
||||
from calibre.ebooks.metadata.book.json_codec import JsonCodec
|
||||
from calibre.utils.config import from_json, to_json
|
||||
|
||||
BASE_TIME = None
|
||||
def debug_print(*args):
|
||||
@ -75,6 +74,7 @@ class USBMS(CLI, Device):
|
||||
return dinfo
|
||||
|
||||
def _update_driveinfo_file(self, prefix, location_code, name=None):
|
||||
from calibre.utils.config import from_json, to_json
|
||||
if os.path.exists(os.path.join(prefix, self.DRIVEINFO)):
|
||||
with open(os.path.join(prefix, self.DRIVEINFO), 'rb') as f:
|
||||
try:
|
||||
|
@ -11,7 +11,7 @@ from urlparse import urlparse
|
||||
|
||||
from calibre import relpath, guess_type, remove_bracketed_text, prints
|
||||
|
||||
from calibre.utils.config import tweaks
|
||||
from calibre.utils.config_base import tweaks
|
||||
|
||||
try:
|
||||
_author_pat = re.compile(tweaks['authors_split_regex'])
|
||||
|
@ -12,26 +12,9 @@ from future_builtins import map
|
||||
|
||||
from calibre import browser, random_user_agent
|
||||
from calibre.customize import Plugin
|
||||
from calibre.utils.config import JSONConfig
|
||||
from calibre.utils.icu import capitalize, lower, upper
|
||||
from calibre.ebooks.metadata import check_isbn
|
||||
|
||||
msprefs = JSONConfig('metadata_sources/global.json')
|
||||
msprefs.defaults['txt_comments'] = False
|
||||
msprefs.defaults['ignore_fields'] = []
|
||||
msprefs.defaults['user_default_ignore_fields'] = []
|
||||
msprefs.defaults['max_tags'] = 20
|
||||
msprefs.defaults['wait_after_first_identify_result'] = 30 # seconds
|
||||
msprefs.defaults['wait_after_first_cover_result'] = 60 # seconds
|
||||
msprefs.defaults['swap_author_names'] = False
|
||||
msprefs.defaults['fewer_tags'] = True
|
||||
msprefs.defaults['find_first_edition_date'] = False
|
||||
|
||||
# Google covers are often poor quality (scans/errors) but they have high
|
||||
# resolution, so they trump covers from better sources. So make sure they
|
||||
# are only used if no other covers are found.
|
||||
msprefs.defaults['cover_priorities'] = {'Google':2, 'Google Images':2, 'Big Book Search':2}
|
||||
|
||||
def create_log(ostream=None):
|
||||
from calibre.utils.logging import ThreadSafeLog, FileStream
|
||||
log = ThreadSafeLog(level=ThreadSafeLog.DEBUG)
|
||||
@ -263,6 +246,7 @@ class Source(Plugin):
|
||||
@property
|
||||
def prefs(self):
|
||||
if self._config_obj is None:
|
||||
from calibre.utils.config import JSONConfig
|
||||
self._config_obj = JSONConfig('metadata_sources/%s.json'%self.name)
|
||||
return self._config_obj
|
||||
# }}}
|
||||
|
@ -13,7 +13,8 @@ from threading import Thread, Event
|
||||
from io import BytesIO
|
||||
|
||||
from calibre.customize.ui import metadata_plugins
|
||||
from calibre.ebooks.metadata.sources.base import msprefs, create_log
|
||||
from calibre.ebooks.metadata.sources.base import create_log
|
||||
from calibre.ebooks.metadata.sources.prefs import msprefs
|
||||
from calibre.utils.magick.draw import Image, save_cover_data_to
|
||||
|
||||
class Worker(Thread):
|
||||
|
@ -16,7 +16,8 @@ from operator import attrgetter
|
||||
from urlparse import urlparse
|
||||
|
||||
from calibre.customize.ui import metadata_plugins, all_metadata_plugins
|
||||
from calibre.ebooks.metadata.sources.base import create_log, msprefs
|
||||
from calibre.ebooks.metadata.sources.base import create_log
|
||||
from calibre.ebooks.metadata.sources.prefs import msprefs
|
||||
from calibre.ebooks.metadata.xisbn import xisbn
|
||||
from calibre.ebooks.metadata.book.base import Metadata
|
||||
from calibre.utils.date import utc_tz, as_utc
|
||||
|
28
src/calibre/ebooks/metadata/sources/prefs.py
Normal file
28
src/calibre/ebooks/metadata/sources/prefs.py
Normal file
@ -0,0 +1,28 @@
|
||||
#!/usr/bin/env python
|
||||
# vim:fileencoding=utf-8
|
||||
from __future__ import (unicode_literals, division, absolute_import,
|
||||
print_function)
|
||||
|
||||
__license__ = 'GPL v3'
|
||||
__copyright__ = '2013, Kovid Goyal <kovid at kovidgoyal.net>'
|
||||
|
||||
from calibre.utils.config import JSONConfig
|
||||
|
||||
msprefs = JSONConfig('metadata_sources/global.json')
|
||||
msprefs.defaults['txt_comments'] = False
|
||||
msprefs.defaults['ignore_fields'] = []
|
||||
msprefs.defaults['user_default_ignore_fields'] = []
|
||||
msprefs.defaults['max_tags'] = 20
|
||||
msprefs.defaults['wait_after_first_identify_result'] = 30 # seconds
|
||||
msprefs.defaults['wait_after_first_cover_result'] = 60 # seconds
|
||||
msprefs.defaults['swap_author_names'] = False
|
||||
msprefs.defaults['fewer_tags'] = True
|
||||
msprefs.defaults['find_first_edition_date'] = False
|
||||
|
||||
# Google covers are often poor quality (scans/errors) but they have high
|
||||
# resolution, so they trump covers from better sources. So make sure they
|
||||
# are only used if no other covers are found.
|
||||
msprefs.defaults['cover_priorities'] = {'Google':2, 'Google Images':2, 'Big Book Search':2}
|
||||
|
||||
|
||||
|
@ -14,8 +14,8 @@ from threading import Event
|
||||
from calibre.customize.ui import all_metadata_plugins
|
||||
from calibre import prints, sanitize_file_name2
|
||||
from calibre.ebooks.metadata import check_isbn
|
||||
from calibre.ebooks.metadata.sources.base import (create_log,
|
||||
get_cached_cover_urls, msprefs)
|
||||
from calibre.ebooks.metadata.sources.base import create_log, get_cached_cover_urls
|
||||
from calibre.ebooks.metadata.sources.prefs import msprefs
|
||||
|
||||
def isbn_test(isbn):
|
||||
isbn_ = check_isbn(isbn)
|
||||
|
@ -421,7 +421,7 @@ class MetadataSingleDialogBase(ResizableDialog):
|
||||
ret = d.start(title=self.title.current_val, authors=self.authors.current_val,
|
||||
identifiers=self.identifiers.current_val)
|
||||
if ret == d.Accepted:
|
||||
from calibre.ebooks.metadata.sources.base import msprefs
|
||||
from calibre.ebooks.metadata.sources.prefs import msprefs
|
||||
mi = d.book
|
||||
dummy = Metadata(_('Unknown'))
|
||||
for f in msprefs['ignore_fields']:
|
||||
|
@ -14,7 +14,7 @@ from PyQt4.Qt import (QAbstractTableModel, Qt, QAbstractListModel, QWidget,
|
||||
|
||||
from calibre.gui2.preferences import ConfigWidgetBase, test_widget
|
||||
from calibre.gui2.preferences.metadata_sources_ui import Ui_Form
|
||||
from calibre.ebooks.metadata.sources.base import msprefs
|
||||
from calibre.ebooks.metadata.sources.prefs import msprefs
|
||||
from calibre.customize.ui import (all_metadata_plugins, is_disabled,
|
||||
enable_plugin, disable_plugin, default_disabled_plugins)
|
||||
from calibre.gui2 import NONE, error_dialog, question_dialog
|
||||
|
@ -17,7 +17,6 @@ from calibre.ebooks import calibre_cover
|
||||
from calibre.library import current_library_name
|
||||
from calibre.library.catalogs import AuthorSortMismatchException, EmptyCatalogException
|
||||
from calibre.ptempfile import PersistentTemporaryFile
|
||||
from calibre.utils.config import JSONConfig
|
||||
from calibre.utils.localization import calibre_langcode_to_name, canonicalize_lang, get_lang
|
||||
|
||||
Option = namedtuple('Option', 'option, default, dest, action, help')
|
||||
@ -191,6 +190,7 @@ class EPUB_MOBI(CatalogPlugin):
|
||||
def run(self, path_to_output, opts, db, notification=DummyReporter()):
|
||||
from calibre.library.catalogs.epub_mobi_builder import CatalogBuilder
|
||||
from calibre.utils.logging import default_log as log
|
||||
from calibre.utils.config import JSONConfig
|
||||
|
||||
# If preset specified from the cli, insert stored options from JSON file
|
||||
if hasattr(opts, 'preset') and opts.preset:
|
||||
|
@ -6,7 +6,7 @@ Created on 25 May 2010
|
||||
import copy, traceback
|
||||
from collections import OrderedDict
|
||||
|
||||
from calibre.utils.config import tweaks
|
||||
from calibre.utils.config_base import tweaks
|
||||
|
||||
class TagsIcons(dict):
|
||||
'''
|
||||
|
@ -7,7 +7,7 @@ __docformat__ = 'restructuredtext en'
|
||||
|
||||
import os
|
||||
|
||||
from calibre.utils.config import Config, StringConfig, config_dir, tweaks
|
||||
from calibre.utils.config_base import Config, StringConfig, config_dir, tweaks
|
||||
|
||||
|
||||
listen_on = tweaks['server_listen_on']
|
||||
|
Loading…
x
Reference in New Issue
Block a user