mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
Remove more global functions
This commit is contained in:
parent
b2311d0f05
commit
6014aec7ae
@ -16,6 +16,7 @@ from calibre.ebooks.metadata.book import (
|
|||||||
)
|
)
|
||||||
from calibre.library.field_metadata import FieldMetadata
|
from calibre.library.field_metadata import FieldMetadata
|
||||||
from calibre.utils.icu import lower as icu_lower, sort_key
|
from calibre.utils.icu import lower as icu_lower, sort_key
|
||||||
|
from calibre.utils.localization import ngettext
|
||||||
from polyglot.builtins import iteritems, string_or_bytes
|
from polyglot.builtins import iteritems, string_or_bytes
|
||||||
|
|
||||||
# Special sets used to optimize the performance of getting and setting
|
# Special sets used to optimize the performance of getting and setting
|
||||||
|
@ -6,25 +6,32 @@ __license__ = 'GPL v3'
|
|||||||
__copyright__ = '2008, Marshall T. Vandegrift <llasram@gmail.com>'
|
__copyright__ = '2008, Marshall T. Vandegrift <llasram@gmail.com>'
|
||||||
__docformat__ = 'restructuredtext en'
|
__docformat__ = 'restructuredtext en'
|
||||||
|
|
||||||
import os, re, logging, sys, numbers
|
import logging
|
||||||
|
import numbers
|
||||||
|
import os
|
||||||
|
import re
|
||||||
|
import sys
|
||||||
from collections import defaultdict
|
from collections import defaultdict
|
||||||
from itertools import count
|
from itertools import count
|
||||||
|
from lxml import etree, html
|
||||||
from operator import attrgetter
|
from operator import attrgetter
|
||||||
|
|
||||||
from lxml import etree, html
|
from calibre import as_unicode, force_unicode, get_types_map, isbytestring
|
||||||
from calibre import force_unicode
|
from calibre.constants import __version__, filesystem_encoding
|
||||||
from calibre.constants import filesystem_encoding, __version__
|
|
||||||
from calibre.translations.dynamic import translate
|
|
||||||
from calibre.utils.xml_parse import safe_xml_fromstring
|
|
||||||
from calibre.ebooks.chardet import xml_to_unicode
|
from calibre.ebooks.chardet import xml_to_unicode
|
||||||
from calibre.ebooks.conversion.preprocess import CSSPreProcessor
|
from calibre.ebooks.conversion.preprocess import CSSPreProcessor
|
||||||
from calibre import (isbytestring, as_unicode, get_types_map)
|
from calibre.ebooks.oeb.parse_utils import (
|
||||||
from calibre.ebooks.oeb.parse_utils import barename, XHTML_NS, namespace, XHTML, parse_html, NotHTML
|
XHTML, XHTML_NS, NotHTML, barename, namespace, parse_html,
|
||||||
|
)
|
||||||
|
from calibre.translations.dynamic import translate
|
||||||
from calibre.utils.cleantext import clean_xml_chars
|
from calibre.utils.cleantext import clean_xml_chars
|
||||||
|
from calibre.utils.icu import numeric_sort_key, title_case as icu_title
|
||||||
from calibre.utils.short_uuid import uuid4
|
from calibre.utils.short_uuid import uuid4
|
||||||
from polyglot.builtins import iteritems, string_or_bytes, itervalues, codepoint_to_chr
|
from calibre.utils.xml_parse import safe_xml_fromstring
|
||||||
from polyglot.urllib import unquote as urlunquote, urldefrag, urljoin, urlparse, urlunparse
|
from polyglot.builtins import codepoint_to_chr, iteritems, itervalues, string_or_bytes
|
||||||
from calibre.utils.icu import numeric_sort_key
|
from polyglot.urllib import (
|
||||||
|
unquote as urlunquote, urldefrag, urljoin, urlparse, urlunparse,
|
||||||
|
)
|
||||||
|
|
||||||
XML_NS = 'http://www.w3.org/XML/1998/namespace'
|
XML_NS = 'http://www.w3.org/XML/1998/namespace'
|
||||||
OEB_DOC_NS = 'http://openebook.org/namespaces/oeb-document/1.0/'
|
OEB_DOC_NS = 'http://openebook.org/namespaces/oeb-document/1.0/'
|
||||||
@ -249,7 +256,7 @@ def rewrite_links(root, link_repl_func, resolve_base_href=False):
|
|||||||
If the ``link_repl_func`` returns None, the attribute or
|
If the ``link_repl_func`` returns None, the attribute or
|
||||||
tag text will be removed completely.
|
tag text will be removed completely.
|
||||||
'''
|
'''
|
||||||
from css_parser import replaceUrls, log, CSSParser
|
from css_parser import CSSParser, log, replaceUrls
|
||||||
log.setLevel(logging.WARN)
|
log.setLevel(logging.WARN)
|
||||||
log.raiseExceptions = False
|
log.raiseExceptions = False
|
||||||
|
|
||||||
|
@ -17,6 +17,7 @@ from calibre.ebooks.oeb.polish.pretty import (
|
|||||||
pretty_script_or_style, pretty_xml_tree, serialize,
|
pretty_script_or_style, pretty_xml_tree, serialize,
|
||||||
)
|
)
|
||||||
from calibre.utils.icu import lower as icu_lower, numeric_sort_key
|
from calibre.utils.icu import lower as icu_lower, numeric_sort_key
|
||||||
|
from calibre.utils.localization import ngettext
|
||||||
from css_selectors import Select, SelectorError, SelectorSyntaxError, parse
|
from css_selectors import Select, SelectorError, SelectorSyntaxError, parse
|
||||||
from polyglot.builtins import iteritems, itervalues
|
from polyglot.builtins import iteritems, itervalues
|
||||||
from polyglot.functools import lru_cache
|
from polyglot.functools import lru_cache
|
||||||
|
@ -24,6 +24,7 @@ from calibre.library.comments import comments_to_html, markdown
|
|||||||
from calibre.utils.config import tweaks
|
from calibre.utils.config import tweaks
|
||||||
from calibre.utils.date import as_local_time, format_date, is_date_undefined
|
from calibre.utils.date import as_local_time, format_date, is_date_undefined
|
||||||
from calibre.utils.icu import sort_key
|
from calibre.utils.icu import sort_key
|
||||||
|
from calibre.utils.localization import ngettext
|
||||||
from calibre.utils.resources import get_path as P
|
from calibre.utils.resources import get_path as P
|
||||||
|
|
||||||
JACKET_XPATH = '//h:meta[@name="calibre-content" and @content="jacket"]'
|
JACKET_XPATH = '//h:meta[@name="calibre-content" and @content="jacket"]'
|
||||||
|
@ -9,7 +9,9 @@ from lxml import etree
|
|||||||
|
|
||||||
from calibre.ebooks.oeb.base import CSS_MIME, XHTML, XHTML_NS, namespace
|
from calibre.ebooks.oeb.base import CSS_MIME, XHTML, XHTML_NS, namespace
|
||||||
from calibre.ebooks.oeb.stylizer import Stylizer
|
from calibre.ebooks.oeb.stylizer import Stylizer
|
||||||
from calibre.utils.icu import lower as icu_lower, upper as icu_upper
|
from calibre.utils.icu import (
|
||||||
|
lower as icu_lower, title_case as icu_title, upper as icu_upper,
|
||||||
|
)
|
||||||
from polyglot.builtins import string_or_bytes
|
from polyglot.builtins import string_or_bytes
|
||||||
|
|
||||||
CASE_MANGLER_CSS = """
|
CASE_MANGLER_CSS = """
|
||||||
|
@ -15,8 +15,8 @@ from calibre.constants import iswindows
|
|||||||
from calibre.ebooks import BOOK_EXTENSIONS
|
from calibre.ebooks import BOOK_EXTENSIONS
|
||||||
from calibre.ebooks.metadata import MetaInformation, normalize_isbn
|
from calibre.ebooks.metadata import MetaInformation, normalize_isbn
|
||||||
from calibre.gui2 import (
|
from calibre.gui2 import (
|
||||||
choose_dir, choose_files, choose_files_and_remember_all_files, error_dialog,
|
choose_dir, choose_files, choose_files_and_remember_all_files, error_dialog, gprefs,
|
||||||
gprefs, info_dialog, question_dialog, warning_dialog
|
info_dialog, question_dialog, warning_dialog,
|
||||||
)
|
)
|
||||||
from calibre.gui2.actions import InterfaceAction
|
from calibre.gui2.actions import InterfaceAction
|
||||||
from calibre.gui2.dialogs.add_empty_book import AddEmptyBookDialog
|
from calibre.gui2.dialogs.add_empty_book import AddEmptyBookDialog
|
||||||
@ -26,6 +26,7 @@ from calibre.ptempfile import PersistentTemporaryFile
|
|||||||
from calibre.utils.config_base import tweaks
|
from calibre.utils.config_base import tweaks
|
||||||
from calibre.utils.filenames import ascii_filename, make_long_path_useable
|
from calibre.utils.filenames import ascii_filename, make_long_path_useable
|
||||||
from calibre.utils.icu import sort_key
|
from calibre.utils.icu import sort_key
|
||||||
|
from calibre.utils.localization import ngettext
|
||||||
from polyglot.builtins import iteritems, string_or_bytes
|
from polyglot.builtins import iteritems, string_or_bytes
|
||||||
|
|
||||||
|
|
||||||
|
@ -3,8 +3,10 @@
|
|||||||
|
|
||||||
|
|
||||||
from qt.core import QDialog
|
from qt.core import QDialog
|
||||||
|
|
||||||
from calibre.gui2 import gprefs
|
from calibre.gui2 import gprefs
|
||||||
from calibre.gui2.actions import InterfaceAction
|
from calibre.gui2.actions import InterfaceAction
|
||||||
|
from calibre.utils.localization import ngettext
|
||||||
from polyglot.builtins import iteritems
|
from polyglot.builtins import iteritems
|
||||||
|
|
||||||
|
|
||||||
@ -27,7 +29,7 @@ class AuthorMapAction(InterfaceAction):
|
|||||||
self.do_map(ids, selected)
|
self.do_map(ids, selected)
|
||||||
|
|
||||||
def do_map(self, book_ids, selected):
|
def do_map(self, book_ids, selected):
|
||||||
from calibre.ebooks.metadata.author_mapper import map_authors, compile_rules
|
from calibre.ebooks.metadata.author_mapper import compile_rules, map_authors
|
||||||
from calibre.gui2.author_mapper import RulesDialog
|
from calibre.gui2.author_mapper import RulesDialog
|
||||||
from calibre.gui2.widgets import BusyCursor
|
from calibre.gui2.widgets import BusyCursor
|
||||||
d = RulesDialog(self.gui)
|
d = RulesDialog(self.gui)
|
||||||
|
@ -9,25 +9,26 @@ import posixpath
|
|||||||
import sys
|
import sys
|
||||||
import weakref
|
import weakref
|
||||||
from contextlib import suppress
|
from contextlib import suppress
|
||||||
from functools import partial, lru_cache
|
from functools import lru_cache, partial
|
||||||
from qt.core import (
|
from qt.core import (
|
||||||
QAction, QCoreApplication, QDialog, QDialogButtonBox, QGridLayout, QIcon,
|
QAction, QCoreApplication, QDialog, QDialogButtonBox, QGridLayout, QIcon,
|
||||||
QInputDialog, QLabel, QLineEdit, QMenu, QSize, Qt, QTimer, QToolButton,
|
QInputDialog, QLabel, QLineEdit, QMenu, QSize, Qt, QTimer, QToolButton, QVBoxLayout,
|
||||||
QVBoxLayout, pyqtSignal
|
pyqtSignal,
|
||||||
)
|
)
|
||||||
|
|
||||||
from calibre import isbytestring, sanitize_file_name
|
from calibre import isbytestring, sanitize_file_name
|
||||||
from calibre.constants import (
|
from calibre.constants import (
|
||||||
config_dir, filesystem_encoding, get_portable_base, isportable, iswindows
|
config_dir, filesystem_encoding, get_portable_base, isportable, iswindows,
|
||||||
)
|
)
|
||||||
from calibre.gui2 import (
|
from calibre.gui2 import (
|
||||||
Dispatcher, choose_dir, choose_images, error_dialog, gprefs, info_dialog,
|
Dispatcher, choose_dir, choose_images, error_dialog, gprefs, info_dialog,
|
||||||
open_local_file, pixmap_to_data, question_dialog, warning_dialog
|
open_local_file, pixmap_to_data, question_dialog, warning_dialog,
|
||||||
)
|
)
|
||||||
from calibre.gui2.actions import InterfaceAction
|
from calibre.gui2.actions import InterfaceAction
|
||||||
from calibre.library import current_library_name
|
from calibre.library import current_library_name
|
||||||
from calibre.utils.config import prefs, tweaks
|
from calibre.utils.config import prefs, tweaks
|
||||||
from calibre.utils.icu import sort_key
|
from calibre.utils.icu import sort_key
|
||||||
|
from calibre.utils.localization import ngettext
|
||||||
|
|
||||||
|
|
||||||
def db_class():
|
def db_class():
|
||||||
|
@ -7,14 +7,14 @@ __docformat__ = 'restructuredtext en'
|
|||||||
|
|
||||||
import os
|
import os
|
||||||
from functools import partial
|
from functools import partial
|
||||||
|
|
||||||
from qt.core import QModelIndex, QTimer
|
from qt.core import QModelIndex, QTimer
|
||||||
|
|
||||||
from calibre.gui2 import error_dialog, Dispatcher, gprefs
|
|
||||||
from calibre.gui2.tools import convert_single_ebook, convert_bulk_ebook
|
|
||||||
from calibre.utils.config import prefs, tweaks
|
|
||||||
from calibre.gui2.actions import InterfaceAction
|
|
||||||
from calibre.customize.ui import plugin_for_input_format
|
from calibre.customize.ui import plugin_for_input_format
|
||||||
|
from calibre.gui2 import Dispatcher, error_dialog, gprefs
|
||||||
|
from calibre.gui2.actions import InterfaceAction
|
||||||
|
from calibre.gui2.tools import convert_bulk_ebook, convert_single_ebook
|
||||||
|
from calibre.utils.config import prefs, tweaks
|
||||||
|
from calibre.utils.localization import ngettext
|
||||||
|
|
||||||
|
|
||||||
class ConvertAction(InterfaceAction):
|
class ConvertAction(InterfaceAction):
|
||||||
|
@ -10,9 +10,9 @@ from collections import defaultdict
|
|||||||
from contextlib import closing
|
from contextlib import closing
|
||||||
from functools import partial
|
from functools import partial
|
||||||
from qt.core import (
|
from qt.core import (
|
||||||
QAbstractItemView, QApplication, QCheckBox, QDialog, QDialogButtonBox,
|
QAbstractItemView, QApplication, QCheckBox, QDialog, QDialogButtonBox, QFormLayout,
|
||||||
QFormLayout, QGridLayout, QHBoxLayout, QIcon, QLabel, QLineEdit, QListWidget,
|
QGridLayout, QHBoxLayout, QIcon, QLabel, QLineEdit, QListWidget, QListWidgetItem,
|
||||||
QListWidgetItem, QScrollArea, QSize, Qt, QToolButton, QVBoxLayout, QWidget
|
QScrollArea, QSize, Qt, QToolButton, QVBoxLayout, QWidget,
|
||||||
)
|
)
|
||||||
from threading import Thread
|
from threading import Thread
|
||||||
|
|
||||||
@ -20,7 +20,7 @@ from calibre import as_unicode
|
|||||||
from calibre.constants import ismacos
|
from calibre.constants import ismacos
|
||||||
from calibre.db.copy_to_library import copy_one_book
|
from calibre.db.copy_to_library import copy_one_book
|
||||||
from calibre.gui2 import (
|
from calibre.gui2 import (
|
||||||
Dispatcher, choose_dir, error_dialog, gprefs, info_dialog, warning_dialog
|
Dispatcher, choose_dir, error_dialog, gprefs, info_dialog, warning_dialog,
|
||||||
)
|
)
|
||||||
from calibre.gui2.actions import InterfaceAction
|
from calibre.gui2.actions import InterfaceAction
|
||||||
from calibre.gui2.actions.choose_library import library_qicon
|
from calibre.gui2.actions.choose_library import library_qicon
|
||||||
@ -28,6 +28,7 @@ from calibre.gui2.dialogs.progress import ProgressDialog
|
|||||||
from calibre.gui2.widgets2 import Dialog
|
from calibre.gui2.widgets2 import Dialog
|
||||||
from calibre.utils.config import prefs
|
from calibre.utils.config import prefs
|
||||||
from calibre.utils.icu import numeric_sort_key, sort_key
|
from calibre.utils.icu import numeric_sort_key, sort_key
|
||||||
|
from calibre.utils.localization import ngettext
|
||||||
from polyglot.builtins import iteritems, itervalues
|
from polyglot.builtins import iteritems, itervalues
|
||||||
|
|
||||||
|
|
||||||
|
@ -17,8 +17,9 @@ from calibre.gui2.actions import InterfaceAction
|
|||||||
from calibre.gui2.dialogs.confirm_delete import confirm
|
from calibre.gui2.dialogs.confirm_delete import confirm
|
||||||
from calibre.gui2.dialogs.confirm_delete_location import confirm_location
|
from calibre.gui2.dialogs.confirm_delete_location import confirm_location
|
||||||
from calibre.gui2.dialogs.delete_matching_from_device import (
|
from calibre.gui2.dialogs.delete_matching_from_device import (
|
||||||
DeleteMatchingFromDeviceDialog
|
DeleteMatchingFromDeviceDialog,
|
||||||
)
|
)
|
||||||
|
from calibre.utils.localization import ngettext
|
||||||
from calibre.utils.recycle_bin import can_recycle
|
from calibre.utils.recycle_bin import can_recycle
|
||||||
|
|
||||||
single_shot = partial(QTimer.singleShot, 10)
|
single_shot = partial(QTimer.singleShot, 10)
|
||||||
|
@ -8,12 +8,11 @@ __docformat__ = 'restructuredtext en'
|
|||||||
import copy
|
import copy
|
||||||
import os
|
import os
|
||||||
import shutil
|
import shutil
|
||||||
from functools import partial
|
|
||||||
from contextlib import contextmanager
|
from contextlib import contextmanager
|
||||||
|
from functools import partial
|
||||||
from io import BytesIO
|
from io import BytesIO
|
||||||
from qt.core import (
|
from qt.core import (
|
||||||
QAction, QApplication, QDialog, QIcon, QMenu, QMimeData, QModelIndex, QTimer,
|
QAction, QApplication, QDialog, QIcon, QMenu, QMimeData, QModelIndex, QTimer, QUrl,
|
||||||
QUrl
|
|
||||||
)
|
)
|
||||||
|
|
||||||
from calibre.db.errors import NoSuchFormat
|
from calibre.db.errors import NoSuchFormat
|
||||||
@ -31,6 +30,7 @@ from calibre.library.comments import merge_comments
|
|||||||
from calibre.utils.config import tweaks
|
from calibre.utils.config import tweaks
|
||||||
from calibre.utils.date import is_date_undefined
|
from calibre.utils.date import is_date_undefined
|
||||||
from calibre.utils.icu import sort_key
|
from calibre.utils.icu import sort_key
|
||||||
|
from calibre.utils.localization import ngettext
|
||||||
from polyglot.builtins import iteritems
|
from polyglot.builtins import iteritems
|
||||||
|
|
||||||
|
|
||||||
|
@ -5,12 +5,12 @@ __license__ = 'GPL v3'
|
|||||||
__copyright__ = '2014, Kovid Goyal <kovid at kovidgoyal.net>'
|
__copyright__ = '2014, Kovid Goyal <kovid at kovidgoyal.net>'
|
||||||
|
|
||||||
from functools import partial
|
from functools import partial
|
||||||
|
from qt.core import QProgressDialog, Qt, QTimer
|
||||||
from qt.core import QTimer, QProgressDialog, Qt
|
|
||||||
|
|
||||||
from calibre import force_unicode
|
from calibre import force_unicode
|
||||||
from calibre.gui2 import gprefs
|
from calibre.gui2 import gprefs
|
||||||
from calibre.gui2.actions import InterfaceAction
|
from calibre.gui2.actions import InterfaceAction
|
||||||
|
from calibre.utils.localization import ngettext
|
||||||
|
|
||||||
|
|
||||||
class EmbedAction(InterfaceAction):
|
class EmbedAction(InterfaceAction):
|
||||||
|
@ -5,22 +5,26 @@ __license__ = 'GPL v3'
|
|||||||
__copyright__ = '2013, Kovid Goyal <kovid at kovidgoyal.net>'
|
__copyright__ = '2013, Kovid Goyal <kovid at kovidgoyal.net>'
|
||||||
__docformat__ = 'restructuredtext en'
|
__docformat__ = 'restructuredtext en'
|
||||||
|
|
||||||
import os, weakref, shutil, textwrap
|
import os
|
||||||
|
import shutil
|
||||||
|
import textwrap
|
||||||
|
import weakref
|
||||||
from collections import OrderedDict
|
from collections import OrderedDict
|
||||||
from functools import partial
|
from functools import partial
|
||||||
from polyglot.builtins import iteritems, itervalues
|
from qt.core import (
|
||||||
|
QApplication, QCheckBox, QDialog, QDialogButtonBox, QFrame, QGridLayout, QIcon,
|
||||||
|
QInputDialog, QLabel, QMenu, QModelIndex, QSize, QSizePolicy, QSpacerItem, Qt,
|
||||||
|
QTextEdit, QTimer,
|
||||||
|
)
|
||||||
|
|
||||||
from qt.core import (QDialog, QGridLayout, QIcon, QCheckBox, QLabel, QFrame,
|
from calibre.gui2 import Dispatcher, error_dialog, gprefs, question_dialog
|
||||||
QApplication, QDialogButtonBox, Qt, QSize, QSpacerItem,
|
|
||||||
QSizePolicy, QTimer, QModelIndex, QTextEdit,
|
|
||||||
QInputDialog, QMenu)
|
|
||||||
|
|
||||||
from calibre.gui2 import error_dialog, Dispatcher, gprefs, question_dialog
|
|
||||||
from calibre.gui2.actions import InterfaceAction
|
from calibre.gui2.actions import InterfaceAction
|
||||||
from calibre.gui2.convert.metadata import create_opf_file
|
from calibre.gui2.convert.metadata import create_opf_file
|
||||||
from calibre.gui2.dialogs.progress import ProgressDialog
|
from calibre.gui2.dialogs.progress import ProgressDialog
|
||||||
from calibre.ptempfile import PersistentTemporaryDirectory
|
from calibre.ptempfile import PersistentTemporaryDirectory
|
||||||
from calibre.utils.config_base import tweaks
|
from calibre.utils.config_base import tweaks
|
||||||
|
from calibre.utils.localization import ngettext
|
||||||
|
from polyglot.builtins import iteritems, itervalues
|
||||||
|
|
||||||
|
|
||||||
class Polish(QDialog): # {{{
|
class Polish(QDialog): # {{{
|
||||||
|
@ -1,12 +1,12 @@
|
|||||||
#!/usr/bin/env python
|
#!/usr/bin/env python
|
||||||
# License: GPLv3 Copyright: 2015, Kovid Goyal <kovid at kovidgoyal.net>
|
# License: GPLv3 Copyright: 2015, Kovid Goyal <kovid at kovidgoyal.net>
|
||||||
|
|
||||||
|
|
||||||
from qt.core import QDialog
|
from qt.core import QDialog
|
||||||
from polyglot.builtins import iteritems
|
|
||||||
|
|
||||||
from calibre.gui2 import gprefs
|
from calibre.gui2 import gprefs
|
||||||
from calibre.gui2.actions import InterfaceAction
|
from calibre.gui2.actions import InterfaceAction
|
||||||
|
from calibre.utils.localization import ngettext
|
||||||
|
from polyglot.builtins import iteritems
|
||||||
|
|
||||||
|
|
||||||
class TagMapAction(InterfaceAction):
|
class TagMapAction(InterfaceAction):
|
||||||
|
@ -33,6 +33,7 @@ from calibre.utils.config import prefs
|
|||||||
from calibre.utils.filenames import make_long_path_useable
|
from calibre.utils.filenames import make_long_path_useable
|
||||||
from calibre.utils.icu import lower as icu_lower
|
from calibre.utils.icu import lower as icu_lower
|
||||||
from calibre.utils.ipc.pool import Failure, Pool
|
from calibre.utils.ipc.pool import Failure, Pool
|
||||||
|
from calibre.utils.localization import ngettext
|
||||||
from polyglot.builtins import iteritems, string_or_bytes
|
from polyglot.builtins import iteritems, string_or_bytes
|
||||||
from polyglot.queue import Empty
|
from polyglot.queue import Empty
|
||||||
|
|
||||||
|
@ -3,20 +3,22 @@ __copyright__ = '2009, John Schember <john@nachtimwald.com>'
|
|||||||
__docformat__ = 'restructuredtext en'
|
__docformat__ = 'restructuredtext en'
|
||||||
|
|
||||||
import shutil
|
import shutil
|
||||||
|
from qt.core import QDialog, QDialogButtonBox, QModelIndex
|
||||||
|
|
||||||
from qt.core import QModelIndex, QDialog, QDialogButtonBox
|
from calibre.ebooks.conversion.config import (
|
||||||
|
get_output_formats, sort_formats_by_preference,
|
||||||
from calibre.gui2.convert.single import Config, GroupModel, gprefs
|
)
|
||||||
from calibre.gui2.convert.look_and_feel import LookAndFeelWidget
|
from calibre.ebooks.conversion.plumber import Plumber
|
||||||
|
from calibre.gui2.convert import GuiRecommendations
|
||||||
from calibre.gui2.convert.heuristics import HeuristicsWidget
|
from calibre.gui2.convert.heuristics import HeuristicsWidget
|
||||||
from calibre.gui2.convert.search_and_replace import SearchAndReplaceWidget
|
from calibre.gui2.convert.look_and_feel import LookAndFeelWidget
|
||||||
from calibre.gui2.convert.page_setup import PageSetupWidget
|
from calibre.gui2.convert.page_setup import PageSetupWidget
|
||||||
|
from calibre.gui2.convert.search_and_replace import SearchAndReplaceWidget
|
||||||
|
from calibre.gui2.convert.single import Config, GroupModel, gprefs
|
||||||
from calibre.gui2.convert.structure_detection import StructureDetectionWidget
|
from calibre.gui2.convert.structure_detection import StructureDetectionWidget
|
||||||
from calibre.gui2.convert.toc import TOCWidget
|
from calibre.gui2.convert.toc import TOCWidget
|
||||||
from calibre.gui2.convert import GuiRecommendations
|
|
||||||
from calibre.ebooks.conversion.plumber import Plumber
|
|
||||||
from calibre.ebooks.conversion.config import sort_formats_by_preference, get_output_formats
|
|
||||||
from calibre.utils.config import prefs
|
from calibre.utils.config import prefs
|
||||||
|
from calibre.utils.localization import ngettext
|
||||||
from calibre.utils.logging import Log
|
from calibre.utils.logging import Log
|
||||||
|
|
||||||
|
|
||||||
|
@ -1,41 +1,56 @@
|
|||||||
__license__ = 'GPL v3'
|
__license__ = 'GPL v3'
|
||||||
__copyright__ = '2008, Kovid Goyal <kovid at kovidgoyal.net>'
|
__copyright__ = '2008, Kovid Goyal <kovid at kovidgoyal.net>'
|
||||||
|
|
||||||
|
import io
|
||||||
|
|
||||||
# Imports {{{
|
# Imports {{{
|
||||||
import os, traceback, time, io, re, sys, weakref
|
import os
|
||||||
from threading import Thread, Event
|
import re
|
||||||
|
import sys
|
||||||
|
import time
|
||||||
|
import traceback
|
||||||
|
import weakref
|
||||||
from qt.core import (
|
from qt.core import (
|
||||||
QMenu, QAction, QActionGroup, QIcon, pyqtSignal, QDialog,
|
QAction, QActionGroup, QCoreApplication, QDialog, QDialogButtonBox, QEventLoop,
|
||||||
QObject, QVBoxLayout, QDialogButtonBox, QCoreApplication,
|
QIcon, QMenu, QObject, QTimer, QVBoxLayout, pyqtSignal,
|
||||||
QEventLoop, QTimer)
|
)
|
||||||
|
from threading import Event, Thread
|
||||||
|
|
||||||
from calibre.customize.ui import (available_input_formats, available_output_formats,
|
from calibre import (
|
||||||
device_plugins, disabled_device_plugins)
|
as_unicode, force_unicode, preferred_encoding, prints, sanitize_file_name,
|
||||||
from calibre.devices.interface import DevicePlugin, currently_connected_device
|
)
|
||||||
from calibre.devices.errors import (UserFeedback, OpenFeedback, OpenFailed, OpenActionNeeded,
|
|
||||||
InitialConnectionError)
|
|
||||||
from calibre.ebooks.covers import cprefs, override_prefs, scale_cover, generate_cover
|
|
||||||
from calibre.gui2.dialogs.choose_format_device import ChooseFormatDeviceDialog
|
|
||||||
from calibre.utils.ipc.job import BaseJob
|
|
||||||
from calibre.devices.scanner import DeviceScanner
|
|
||||||
from calibre.gui2 import (config, error_dialog, Dispatcher, dynamic,
|
|
||||||
warning_dialog, info_dialog, choose_dir, FunctionDispatcher,
|
|
||||||
show_restart_warning, gprefs, question_dialog)
|
|
||||||
from calibre.gui2.widgets import BusyCursor
|
|
||||||
from calibre.ebooks.metadata import authors_to_string
|
|
||||||
from calibre import preferred_encoding, prints, force_unicode, as_unicode, sanitize_file_name
|
|
||||||
from calibre.utils.filenames import ascii_filename
|
|
||||||
from calibre.devices.errors import (FreeSpaceError, WrongDestinationError,
|
|
||||||
BlacklistedDevice)
|
|
||||||
from calibre.devices.folder_device.driver import FOLDER_DEVICE
|
|
||||||
from calibre.constants import DEBUG
|
from calibre.constants import DEBUG
|
||||||
from calibre.utils.config import tweaks, device_prefs
|
from calibre.customize.ui import (
|
||||||
from calibre.utils.img import scale_image
|
available_input_formats, available_output_formats, device_plugins,
|
||||||
|
disabled_device_plugins,
|
||||||
|
)
|
||||||
|
from calibre.devices.errors import (
|
||||||
|
BlacklistedDevice, FreeSpaceError, InitialConnectionError, OpenActionNeeded,
|
||||||
|
OpenFailed, OpenFeedback, UserFeedback, WrongDestinationError,
|
||||||
|
)
|
||||||
|
from calibre.devices.folder_device.driver import FOLDER_DEVICE
|
||||||
|
from calibre.devices.interface import DevicePlugin, currently_connected_device
|
||||||
|
from calibre.devices.scanner import DeviceScanner
|
||||||
|
from calibre.ebooks.covers import cprefs, generate_cover, override_prefs, scale_cover
|
||||||
|
from calibre.ebooks.metadata import authors_to_string
|
||||||
|
from calibre.gui2 import (
|
||||||
|
Dispatcher, FunctionDispatcher, choose_dir, config, dynamic, error_dialog, gprefs,
|
||||||
|
info_dialog, question_dialog, show_restart_warning, warning_dialog,
|
||||||
|
)
|
||||||
|
from calibre.gui2.dialogs.choose_format_device import ChooseFormatDeviceDialog
|
||||||
|
from calibre.gui2.widgets import BusyCursor
|
||||||
from calibre.library.save_to_disk import find_plugboard
|
from calibre.library.save_to_disk import find_plugboard
|
||||||
from calibre.ptempfile import PersistentTemporaryFile, force_unicode as filename_to_unicode
|
from calibre.ptempfile import (
|
||||||
from polyglot.builtins import string_or_unicode
|
PersistentTemporaryFile, force_unicode as filename_to_unicode,
|
||||||
|
)
|
||||||
|
from calibre.utils.config import device_prefs, tweaks
|
||||||
|
from calibre.utils.filenames import ascii_filename
|
||||||
|
from calibre.utils.img import scale_image
|
||||||
|
from calibre.utils.ipc.job import BaseJob
|
||||||
|
from calibre.utils.localization import ngettext
|
||||||
from polyglot import queue
|
from polyglot import queue
|
||||||
|
from polyglot.builtins import string_or_unicode
|
||||||
|
|
||||||
# }}}
|
# }}}
|
||||||
|
|
||||||
|
|
||||||
|
@ -6,14 +6,15 @@ __copyright__ = '2013, Kovid Goyal <kovid at kovidgoyal.net>'
|
|||||||
__docformat__ = 'restructuredtext en'
|
__docformat__ = 'restructuredtext en'
|
||||||
|
|
||||||
import os.path
|
import os.path
|
||||||
|
|
||||||
from qt.core import (
|
from qt.core import (
|
||||||
QDialog, QGridLayout, QIcon, QLabel, QTreeWidget, QTreeWidgetItem, Qt,
|
QApplication, QDialog, QDialogButtonBox, QFont, QGridLayout, QIcon, QLabel, Qt,
|
||||||
QFont, QDialogButtonBox, QApplication)
|
QTreeWidget, QTreeWidgetItem,
|
||||||
|
)
|
||||||
|
|
||||||
from calibre.gui2 import gprefs
|
|
||||||
from calibre.ebooks.metadata import authors_to_string
|
from calibre.ebooks.metadata import authors_to_string
|
||||||
|
from calibre.gui2 import gprefs
|
||||||
from calibre.utils.icu import primary_sort_key
|
from calibre.utils.icu import primary_sort_key
|
||||||
|
from calibre.utils.localization import ngettext
|
||||||
|
|
||||||
|
|
||||||
class DuplicatesQuestion(QDialog):
|
class DuplicatesQuestion(QDialog):
|
||||||
|
@ -6,12 +6,14 @@ __copyright__ = '2013, Kovid Goyal kovid@kovidgoyal.net'
|
|||||||
__docformat__ = 'restructuredtext en'
|
__docformat__ = 'restructuredtext en'
|
||||||
|
|
||||||
|
|
||||||
from qt.core import (Qt, QDialog, QAbstractItemView, QTableWidgetItem,
|
from qt.core import (
|
||||||
QApplication, QCursor, QTimer)
|
QAbstractItemView, QApplication, QCursor, QDialog, Qt, QTableWidgetItem, QTimer,
|
||||||
|
)
|
||||||
|
|
||||||
from calibre.gui2 import gprefs, error_dialog
|
from calibre.gui2 import error_dialog, gprefs
|
||||||
from calibre.gui2.dialogs.match_books_ui import Ui_MatchBooks
|
from calibre.gui2.dialogs.match_books_ui import Ui_MatchBooks
|
||||||
from calibre.utils.icu import sort_key
|
from calibre.utils.icu import sort_key
|
||||||
|
from calibre.utils.localization import ngettext
|
||||||
|
|
||||||
|
|
||||||
class TableItem(QTableWidgetItem):
|
class TableItem(QTableWidgetItem):
|
||||||
|
@ -9,11 +9,12 @@ import sys
|
|||||||
from qt.core import (
|
from qt.core import (
|
||||||
QAction, QApplication, QCheckBox, QDialog, QDialogButtonBox, QGridLayout, QIcon,
|
QAction, QApplication, QCheckBox, QDialog, QDialogButtonBox, QGridLayout, QIcon,
|
||||||
QKeySequence, QLabel, QPainter, QPlainTextEdit, QSize, QSizePolicy, Qt,
|
QKeySequence, QLabel, QPainter, QPlainTextEdit, QSize, QSizePolicy, Qt,
|
||||||
QTextBrowser, QTextDocument, QVBoxLayout, QWidget, pyqtSignal
|
QTextBrowser, QTextDocument, QVBoxLayout, QWidget, pyqtSignal,
|
||||||
)
|
)
|
||||||
|
|
||||||
from calibre.constants import __version__, isfrozen
|
from calibre.constants import __version__, isfrozen
|
||||||
from calibre.gui2 import gprefs
|
from calibre.gui2 import gprefs
|
||||||
|
from calibre.utils.localization import ngettext
|
||||||
|
|
||||||
|
|
||||||
class Icon(QWidget):
|
class Icon(QWidget):
|
||||||
@ -491,8 +492,8 @@ class JobError(QDialog): # {{{
|
|||||||
|
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
from calibre.gui2 import Application, question_dialog
|
|
||||||
from calibre import prepare_string_for_xml
|
from calibre import prepare_string_for_xml
|
||||||
|
from calibre.gui2 import Application, question_dialog
|
||||||
app = Application([])
|
app = Application([])
|
||||||
merged = {'Kovid Goyal': ['Waterloo', 'Doomed'], 'Someone Else': ['Some other book ' * 1000]}
|
merged = {'Kovid Goyal': ['Waterloo', 'Doomed'], 'Someone Else': ['Some other book ' * 1000]}
|
||||||
lines = []
|
lines = []
|
||||||
|
@ -33,6 +33,7 @@ from calibre.utils.date import internal_iso_format_string, qt_to_dt
|
|||||||
from calibre.utils.icu import (
|
from calibre.utils.icu import (
|
||||||
capitalize, lower as icu_lower, sort_key, upper as icu_upper,
|
capitalize, lower as icu_lower, sort_key, upper as icu_upper,
|
||||||
)
|
)
|
||||||
|
from calibre.utils.localization import ngettext
|
||||||
from calibre.utils.titlecase import titlecase
|
from calibre.utils.titlecase import titlecase
|
||||||
from polyglot.builtins import error_message, iteritems, itervalues, native_string_type
|
from polyglot.builtins import error_message, iteritems, itervalues, native_string_type
|
||||||
|
|
||||||
|
@ -15,7 +15,7 @@ from qt.core import (
|
|||||||
QAbstractItemView, QApplication, QColor, QComboBox, QCursor, QDialog,
|
QAbstractItemView, QApplication, QColor, QComboBox, QCursor, QDialog,
|
||||||
QDialogButtonBox, QFont, QFontDatabase, QFontInfo, QFontMetrics, QIcon, QLineEdit,
|
QDialogButtonBox, QFont, QFontDatabase, QFontInfo, QFontMetrics, QIcon, QLineEdit,
|
||||||
QPalette, QSize, QSyntaxHighlighter, Qt, QTableWidget, QTableWidgetItem,
|
QPalette, QSize, QSyntaxHighlighter, Qt, QTableWidget, QTableWidgetItem,
|
||||||
QTextCharFormat, QTextOption, QVBoxLayout, pyqtSignal
|
QTextCharFormat, QTextOption, QVBoxLayout, pyqtSignal,
|
||||||
)
|
)
|
||||||
|
|
||||||
from calibre import sanitize_file_name
|
from calibre import sanitize_file_name
|
||||||
@ -33,7 +33,7 @@ from calibre.utils.date import DEFAULT_DATE
|
|||||||
from calibre.utils.formatter import PythonTemplateContext, StopException
|
from calibre.utils.formatter import PythonTemplateContext, StopException
|
||||||
from calibre.utils.formatter_functions import StoredObjectType, formatter_functions
|
from calibre.utils.formatter_functions import StoredObjectType, formatter_functions
|
||||||
from calibre.utils.icu import lower as icu_lower, sort_key
|
from calibre.utils.icu import lower as icu_lower, sort_key
|
||||||
from calibre.utils.localization import localize_user_manual_link
|
from calibre.utils.localization import localize_user_manual_link, ngettext
|
||||||
from calibre.utils.resources import get_path as P
|
from calibre.utils.resources import get_path as P
|
||||||
|
|
||||||
|
|
||||||
|
@ -11,10 +11,9 @@ from contextlib import suppress
|
|||||||
from functools import partial
|
from functools import partial
|
||||||
from itertools import count
|
from itertools import count
|
||||||
from qt.core import (
|
from qt.core import (
|
||||||
QAbstractItemModel, QAbstractItemView, QCheckBox, QDialog, QDialogButtonBox,
|
QAbstractItemModel, QAbstractItemView, QCheckBox, QDialog, QDialogButtonBox, QFont,
|
||||||
QFont, QHBoxLayout, QIcon, QLabel, QMenu, QModelIndex, QPixmap, QPushButton,
|
QHBoxLayout, QIcon, QLabel, QMenu, QModelIndex, QPixmap, QPushButton, QRect, QSize,
|
||||||
QRect, QSize, QSplitter, QStackedWidget, Qt, QTreeView, QVBoxLayout, QWidget,
|
QSplitter, QStackedWidget, Qt, QTreeView, QVBoxLayout, QWidget, pyqtSignal,
|
||||||
pyqtSignal
|
|
||||||
)
|
)
|
||||||
from threading import Event, Thread
|
from threading import Event, Thread
|
||||||
|
|
||||||
@ -22,7 +21,7 @@ from calibre import fit_image, prepare_string_for_xml
|
|||||||
from calibre.db import FTSQueryError
|
from calibre.db import FTSQueryError
|
||||||
from calibre.ebooks.metadata import authors_to_string, fmt_sidx
|
from calibre.ebooks.metadata import authors_to_string, fmt_sidx
|
||||||
from calibre.gui2 import (
|
from calibre.gui2 import (
|
||||||
config, error_dialog, gprefs, info_dialog, question_dialog, safe_open_url
|
config, error_dialog, gprefs, info_dialog, question_dialog, safe_open_url,
|
||||||
)
|
)
|
||||||
from calibre.gui2.fts.utils import get_db
|
from calibre.gui2.fts.utils import get_db
|
||||||
from calibre.gui2.library.models import render_pin
|
from calibre.gui2.library.models import render_pin
|
||||||
@ -31,6 +30,7 @@ from calibre.gui2.ui import get_gui
|
|||||||
from calibre.gui2.viewer.widgets import ResultsDelegate, SearchBox
|
from calibre.gui2.viewer.widgets import ResultsDelegate, SearchBox
|
||||||
from calibre.gui2.widgets import BusyCursor
|
from calibre.gui2.widgets import BusyCursor
|
||||||
from calibre.gui2.widgets2 import HTMLDisplay
|
from calibre.gui2.widgets2 import HTMLDisplay
|
||||||
|
from calibre.utils.localization import ngettext
|
||||||
|
|
||||||
ROOT = QModelIndex()
|
ROOT = QModelIndex()
|
||||||
sanitize_text_pat = re.compile(r'\s+')
|
sanitize_text_pat = re.compile(r'\s+')
|
||||||
|
@ -7,15 +7,15 @@ __docformat__ = 'restructuredtext en'
|
|||||||
|
|
||||||
import functools
|
import functools
|
||||||
from qt.core import (
|
from qt.core import (
|
||||||
QAction, QApplication, QDialog, QEvent, QIcon, QLabel, QMenu, QPixmap, QUrl,
|
QAction, QApplication, QDialog, QEvent, QIcon, QLabel, QMenu, QPixmap, QSizePolicy,
|
||||||
QSizePolicy, QStackedWidget, QStatusBar, QStyle, QStyleOption, QSplitter,
|
QSplitter, QStackedWidget, QStatusBar, QStyle, QStyleOption, QStylePainter, Qt,
|
||||||
QStylePainter, Qt, QTabBar, QTimer, QToolButton, QVBoxLayout, QWidget
|
QTabBar, QTimer, QToolButton, QUrl, QVBoxLayout, QWidget,
|
||||||
)
|
)
|
||||||
|
|
||||||
from calibre.constants import get_appname_for_display, get_version, ismacos
|
from calibre.constants import get_appname_for_display, get_version, ismacos
|
||||||
from calibre.customize.ui import find_plugin
|
from calibre.customize.ui import find_plugin
|
||||||
from calibre.gui2 import (
|
from calibre.gui2 import (
|
||||||
config, error_dialog, gprefs, is_widescreen, open_local_file, open_url
|
config, error_dialog, gprefs, is_widescreen, open_local_file, open_url,
|
||||||
)
|
)
|
||||||
from calibre.gui2.book_details import BookDetails
|
from calibre.gui2.book_details import BookDetails
|
||||||
from calibre.gui2.layout_menu import LayoutMenu
|
from calibre.gui2.layout_menu import LayoutMenu
|
||||||
@ -26,7 +26,7 @@ from calibre.gui2.tag_browser.ui import TagBrowserWidget
|
|||||||
from calibre.gui2.widgets import LayoutButton, Splitter
|
from calibre.gui2.widgets import LayoutButton, Splitter
|
||||||
from calibre.utils.config import prefs
|
from calibre.utils.config import prefs
|
||||||
from calibre.utils.icu import sort_key
|
from calibre.utils.icu import sort_key
|
||||||
from calibre.utils.localization import localize_website_link
|
from calibre.utils.localization import localize_website_link, ngettext
|
||||||
|
|
||||||
_keep_refs = []
|
_keep_refs = []
|
||||||
|
|
||||||
|
@ -10,28 +10,28 @@ Job management.
|
|||||||
'''
|
'''
|
||||||
|
|
||||||
import time
|
import time
|
||||||
|
from qt.core import (
|
||||||
|
QAbstractItemDelegate, QAbstractTableModel, QAction, QApplication, QByteArray,
|
||||||
|
QCoreApplication, QDialog, QDialogButtonBox, QEvent, QHBoxLayout, QIcon,
|
||||||
|
QItemSelectionModel, QLabel, QModelIndex, QPlainTextEdit, QSize, QSizePolicy,
|
||||||
|
QSortFilterProxyModel, QStyle, QStyleOption, QStyleOptionProgressBar, QStylePainter,
|
||||||
|
Qt, QTextBrowser, QTimer, QToolTip, QVBoxLayout, QWidget, pyqtSignal,
|
||||||
|
)
|
||||||
|
|
||||||
from qt.core import (QAbstractTableModel, QModelIndex, Qt, QStylePainter,
|
from calibre import __appname__, as_unicode, strftime
|
||||||
QTimer, pyqtSignal, QIcon, QDialog, QAbstractItemDelegate, QApplication, QEvent,
|
from calibre.constants import isbsd, islinux
|
||||||
QSize, QStyleOptionProgressBar, QStyle, QToolTip, QWidget, QStyleOption,
|
from calibre.db.utils import human_readable_interval
|
||||||
QHBoxLayout, QVBoxLayout, QSizePolicy, QLabel, QCoreApplication, QAction, QItemSelectionModel,
|
from calibre.gui2 import Dispatcher, config, error_dialog, gprefs, question_dialog
|
||||||
QByteArray, QSortFilterProxyModel, QTextBrowser, QPlainTextEdit, QDialogButtonBox)
|
|
||||||
|
|
||||||
from calibre import strftime
|
|
||||||
from calibre.constants import islinux, isbsd
|
|
||||||
from calibre.utils.ipc.server import Server
|
|
||||||
from calibre.utils.ipc.job import ParallelJob
|
|
||||||
from calibre.gui2 import (Dispatcher, error_dialog, question_dialog,
|
|
||||||
config, gprefs)
|
|
||||||
from calibre.gui2.device import DeviceJob
|
from calibre.gui2.device import DeviceJob
|
||||||
from calibre.gui2.dialogs.jobs_ui import Ui_JobsDialog
|
from calibre.gui2.dialogs.jobs_ui import Ui_JobsDialog
|
||||||
from calibre import __appname__, as_unicode
|
|
||||||
from calibre.gui2.progress_indicator import ProgressIndicator
|
from calibre.gui2.progress_indicator import ProgressIndicator
|
||||||
from calibre.gui2.threaded_jobs import ThreadedJobServer, ThreadedJob
|
from calibre.gui2.threaded_jobs import ThreadedJob, ThreadedJobServer
|
||||||
from calibre.gui2.widgets2 import Dialog
|
from calibre.gui2.widgets2 import Dialog
|
||||||
from calibre.utils.search_query_parser import SearchQueryParser, ParseException
|
|
||||||
from calibre.db.utils import human_readable_interval
|
|
||||||
from calibre.utils.icu import lower
|
from calibre.utils.icu import lower
|
||||||
|
from calibre.utils.ipc.job import ParallelJob
|
||||||
|
from calibre.utils.ipc.server import Server
|
||||||
|
from calibre.utils.localization import ngettext
|
||||||
|
from calibre.utils.search_query_parser import ParseException, SearchQueryParser
|
||||||
from polyglot.queue import Empty, Queue
|
from polyglot.queue import Empty, Queue
|
||||||
|
|
||||||
|
|
||||||
|
@ -7,28 +7,29 @@ import os
|
|||||||
import re
|
import re
|
||||||
from functools import lru_cache, partial
|
from functools import lru_cache, partial
|
||||||
from qt.core import (
|
from qt.core import (
|
||||||
QAbstractItemView, QApplication, QCheckBox, QComboBox, QDateTime,
|
QAbstractItemView, QApplication, QCheckBox, QComboBox, QDateTime, QDialog,
|
||||||
QDialog, QDialogButtonBox, QFont, QFormLayout, QFrame, QHBoxLayout, QIcon,
|
QDialogButtonBox, QFont, QFormLayout, QFrame, QHBoxLayout, QIcon, QKeySequence,
|
||||||
QKeySequence, QLabel, QLocale, QMenu, QPalette, QPlainTextEdit, QSize, QSplitter,
|
QLabel, QLocale, QMenu, QPalette, QPlainTextEdit, QSize, QSplitter, Qt,
|
||||||
Qt, QTextBrowser, QTimer, QToolButton, QTreeWidget, QTreeWidgetItem, QVBoxLayout,
|
QTextBrowser, QTimer, QToolButton, QTreeWidget, QTreeWidgetItem, QVBoxLayout,
|
||||||
QWidget, pyqtSignal
|
QWidget, pyqtSignal,
|
||||||
)
|
)
|
||||||
from urllib.parse import quote
|
from urllib.parse import quote
|
||||||
|
|
||||||
from calibre import prepare_string_for_xml
|
from calibre import prepare_string_for_xml
|
||||||
from calibre.constants import (
|
from calibre.constants import (
|
||||||
builtin_colors_dark, builtin_colors_light, builtin_decorations
|
builtin_colors_dark, builtin_colors_light, builtin_decorations,
|
||||||
)
|
)
|
||||||
from calibre.db.backend import FTSQueryError
|
from calibre.db.backend import FTSQueryError
|
||||||
from calibre.ebooks.metadata import authors_to_string, fmt_sidx
|
from calibre.ebooks.metadata import authors_to_string, fmt_sidx
|
||||||
from calibre.gui2 import (
|
from calibre.gui2 import (
|
||||||
Application, choose_save_file, config, error_dialog, gprefs, is_dark_theme,
|
Application, choose_save_file, config, error_dialog, gprefs, is_dark_theme,
|
||||||
safe_open_url
|
safe_open_url,
|
||||||
)
|
)
|
||||||
from calibre.gui2.dialogs.confirm_delete import confirm
|
from calibre.gui2.dialogs.confirm_delete import confirm
|
||||||
from calibre.gui2.viewer.widgets import ResultsDelegate, SearchBox
|
from calibre.gui2.viewer.widgets import ResultsDelegate, SearchBox
|
||||||
from calibre.gui2.widgets import BusyCursor
|
from calibre.gui2.widgets import BusyCursor
|
||||||
from calibre.gui2.widgets2 import Dialog, RightClickButton
|
from calibre.gui2.widgets2 import Dialog, RightClickButton
|
||||||
|
from calibre.utils.localization import ngettext
|
||||||
|
|
||||||
|
|
||||||
def render_timestamp(ts):
|
def render_timestamp(ts):
|
||||||
|
@ -38,7 +38,7 @@ from calibre.utils.date import (
|
|||||||
UNDEFINED_DATE, as_local_time, dt_factory, is_date_undefined, qt_to_dt,
|
UNDEFINED_DATE, as_local_time, dt_factory, is_date_undefined, qt_to_dt,
|
||||||
)
|
)
|
||||||
from calibre.utils.icu import sort_key
|
from calibre.utils.icu import sort_key
|
||||||
from calibre.utils.localization import calibre_langcode_to_name
|
from calibre.utils.localization import calibre_langcode_to_name, ngettext
|
||||||
from calibre.utils.resources import get_path as P
|
from calibre.utils.resources import get_path as P
|
||||||
from calibre.utils.search_query_parser import ParseException, SearchQueryParser
|
from calibre.utils.search_query_parser import ParseException, SearchQueryParser
|
||||||
from polyglot.builtins import iteritems, itervalues, string_or_bytes
|
from polyglot.builtins import iteritems, itervalues, string_or_bytes
|
||||||
|
@ -12,10 +12,11 @@ import textwrap
|
|||||||
import weakref
|
import weakref
|
||||||
from datetime import date, datetime
|
from datetime import date, datetime
|
||||||
from qt.core import (
|
from qt.core import (
|
||||||
QAction, QApplication, QDateTime, QDialog, QDialogButtonBox, QDoubleSpinBox, QAbstractItemView,
|
QAbstractItemView, QAction, QApplication, QComboBox, QDateTime, QDialog,
|
||||||
QGridLayout, QIcon, QKeySequence, QLabel, QLineEdit, QListWidgetItem, QMenu,
|
QDialogButtonBox, QDoubleSpinBox, QGridLayout, QIcon, QKeySequence, QLabel,
|
||||||
QMessageBox, QPixmap, QPlainTextEdit, QSize, QSizePolicy, Qt, QToolButton, QComboBox,
|
QLineEdit, QListWidgetItem, QMenu, QMessageBox, QPixmap, QPlainTextEdit, QSize,
|
||||||
QUndoCommand, QUndoStack, QUrl, QVBoxLayout, QWidget, pyqtSignal
|
QSizePolicy, Qt, QToolButton, QUndoCommand, QUndoStack, QUrl, QVBoxLayout, QWidget,
|
||||||
|
pyqtSignal,
|
||||||
)
|
)
|
||||||
|
|
||||||
from calibre import strftime
|
from calibre import strftime
|
||||||
@ -24,12 +25,13 @@ from calibre.customize.ui import run_plugins_on_import
|
|||||||
from calibre.db import SPOOL_SIZE
|
from calibre.db import SPOOL_SIZE
|
||||||
from calibre.ebooks import BOOK_EXTENSIONS
|
from calibre.ebooks import BOOK_EXTENSIONS
|
||||||
from calibre.ebooks.metadata import (
|
from calibre.ebooks.metadata import (
|
||||||
authors_to_sort_string, check_isbn, string_to_authors, title_sort
|
authors_to_sort_string, check_isbn, string_to_authors, title_sort,
|
||||||
)
|
)
|
||||||
from calibre.ebooks.metadata.meta import get_metadata
|
from calibre.ebooks.metadata.meta import get_metadata
|
||||||
from calibre.ebooks.oeb.polish.main import SUPPORTED as EDIT_SUPPORTED
|
from calibre.ebooks.oeb.polish.main import SUPPORTED as EDIT_SUPPORTED
|
||||||
from calibre.gui2 import (
|
from calibre.gui2 import (
|
||||||
choose_files_and_remember_all_files, choose_images, error_dialog, file_icon_provider, gprefs
|
choose_files_and_remember_all_files, choose_images, error_dialog,
|
||||||
|
file_icon_provider, gprefs,
|
||||||
)
|
)
|
||||||
from calibre.gui2.comments_editor import Editor
|
from calibre.gui2.comments_editor import Editor
|
||||||
from calibre.gui2.complete2 import EditWithComplete
|
from calibre.gui2.complete2 import EditWithComplete
|
||||||
@ -38,17 +40,18 @@ from calibre.gui2.languages import LanguagesEdit as LE
|
|||||||
from calibre.gui2.widgets import EnLineEdit, FormatList as _FormatList, ImageView
|
from calibre.gui2.widgets import EnLineEdit, FormatList as _FormatList, ImageView
|
||||||
from calibre.gui2.widgets2 import (
|
from calibre.gui2.widgets2 import (
|
||||||
DateTimeEdit, Dialog, RatingEditor, RightClickButton, access_key,
|
DateTimeEdit, Dialog, RatingEditor, RightClickButton, access_key,
|
||||||
populate_standard_spinbox_context_menu
|
populate_standard_spinbox_context_menu,
|
||||||
)
|
)
|
||||||
from calibre.library.comments import comments_to_html
|
from calibre.library.comments import comments_to_html
|
||||||
from calibre.ptempfile import PersistentTemporaryFile, SpooledTemporaryFile
|
from calibre.ptempfile import PersistentTemporaryFile, SpooledTemporaryFile
|
||||||
from calibre.utils.config import prefs, tweaks
|
from calibre.utils.config import prefs, tweaks
|
||||||
from calibre.utils.date import (
|
from calibre.utils.date import (
|
||||||
UNDEFINED_DATE, as_local_time, internal_iso_format_string, is_date_undefined,
|
UNDEFINED_DATE, as_local_time, internal_iso_format_string, is_date_undefined,
|
||||||
local_tz, parse_only_date, qt_to_dt, utcfromtimestamp
|
local_tz, parse_only_date, qt_to_dt, utcfromtimestamp,
|
||||||
)
|
)
|
||||||
from calibre.utils.filenames import make_long_path_useable
|
from calibre.utils.filenames import make_long_path_useable
|
||||||
from calibre.utils.icu import sort_key, strcmp
|
from calibre.utils.icu import sort_key, strcmp
|
||||||
|
from calibre.utils.localization import ngettext
|
||||||
from polyglot.builtins import iteritems
|
from polyglot.builtins import iteritems
|
||||||
|
|
||||||
|
|
||||||
@ -1221,7 +1224,7 @@ class Cover(ImageView): # {{{
|
|||||||
if not cdata:
|
if not cdata:
|
||||||
return
|
return
|
||||||
from calibre.utils.img import (
|
from calibre.utils.img import (
|
||||||
image_from_data, image_to_data, remove_borders_from_image
|
image_from_data, image_to_data, remove_borders_from_image,
|
||||||
)
|
)
|
||||||
img = image_from_data(cdata)
|
img = image_from_data(cdata)
|
||||||
nimg = remove_borders_from_image(img)
|
nimg = remove_borders_from_image(img)
|
||||||
|
@ -5,17 +5,17 @@ __license__ = 'GPL v3'
|
|||||||
__copyright__ = '2011, Kovid Goyal <kovid@kovidgoyal.net>'
|
__copyright__ = '2011, Kovid Goyal <kovid@kovidgoyal.net>'
|
||||||
__docformat__ = 'restructuredtext en'
|
__docformat__ = 'restructuredtext en'
|
||||||
|
|
||||||
import os, time, shutil
|
import os
|
||||||
|
import shutil
|
||||||
|
import time
|
||||||
|
from qt.core import QDialog, QDialogButtonBox, QGridLayout, QIcon, QLabel, Qt
|
||||||
from threading import Thread
|
from threading import Thread
|
||||||
|
|
||||||
from qt.core import (QIcon, QDialog,
|
|
||||||
QDialogButtonBox, QLabel, QGridLayout, Qt)
|
|
||||||
|
|
||||||
from calibre.gui2.threaded_jobs import ThreadedJob
|
|
||||||
from calibre.ebooks.metadata.opf2 import metadata_to_opf
|
from calibre.ebooks.metadata.opf2 import metadata_to_opf
|
||||||
from calibre.utils.ipc.simple_worker import fork_job, WorkerError
|
from calibre.gui2.threaded_jobs import ThreadedJob
|
||||||
from calibre.ptempfile import (PersistentTemporaryDirectory,
|
from calibre.ptempfile import PersistentTemporaryDirectory, PersistentTemporaryFile
|
||||||
PersistentTemporaryFile)
|
from calibre.utils.ipc.simple_worker import WorkerError, fork_job
|
||||||
|
from calibre.utils.localization import ngettext
|
||||||
from polyglot.builtins import iteritems
|
from polyglot.builtins import iteritems
|
||||||
|
|
||||||
# Start download {{{
|
# Start download {{{
|
||||||
|
@ -27,6 +27,7 @@ from calibre.gui2.widgets2 import RightClickButton
|
|||||||
from calibre.ptempfile import PersistentTemporaryFile
|
from calibre.ptempfile import PersistentTemporaryFile
|
||||||
from calibre.utils.date import UNDEFINED_DATE
|
from calibre.utils.date import UNDEFINED_DATE
|
||||||
from calibre.utils.icu import lower as icu_lower
|
from calibre.utils.icu import lower as icu_lower
|
||||||
|
from calibre.utils.localization import ngettext
|
||||||
from polyglot.builtins import iteritems, itervalues
|
from polyglot.builtins import iteritems, itervalues
|
||||||
|
|
||||||
Widgets = namedtuple('Widgets', 'new old label button')
|
Widgets = namedtuple('Widgets', 'new old label button')
|
||||||
|
@ -32,7 +32,7 @@ from calibre.gui2.metadata.single_download import FullFetch
|
|||||||
from calibre.gui2.widgets2 import CenteredToolButton
|
from calibre.gui2.widgets2 import CenteredToolButton
|
||||||
from calibre.library.comments import merge_comments as merge_two_comments
|
from calibre.library.comments import merge_comments as merge_two_comments
|
||||||
from calibre.utils.date import local_tz
|
from calibre.utils.date import local_tz
|
||||||
from calibre.utils.localization import canonicalize_lang
|
from calibre.utils.localization import canonicalize_lang, ngettext
|
||||||
from polyglot.builtins import iteritems
|
from polyglot.builtins import iteritems
|
||||||
|
|
||||||
BASE_TITLE = _('Edit metadata')
|
BASE_TITLE = _('Edit metadata')
|
||||||
|
@ -10,30 +10,29 @@ import os
|
|||||||
import textwrap
|
import textwrap
|
||||||
from functools import partial
|
from functools import partial
|
||||||
from qt.core import (
|
from qt.core import (
|
||||||
QAbstractItemView, QAbstractListModel, QApplication, QCheckBox, QComboBox,
|
QAbstractItemView, QAbstractListModel, QApplication, QCheckBox, QComboBox, QDialog,
|
||||||
QDialog, QDialogButtonBox, QDoubleValidator, QFrame, QGridLayout, QIcon,
|
QDialogButtonBox, QDoubleValidator, QFrame, QGridLayout, QIcon, QIntValidator,
|
||||||
QIntValidator, QItemSelectionModel, QLabel, QLineEdit, QListView,
|
QItemSelection, QItemSelectionModel, QLabel, QLineEdit, QListView, QListWidget,
|
||||||
QPalette, QPushButton, QScrollArea, QSize, QSizePolicy, QSpacerItem,
|
QListWidgetItem, QPalette, QPushButton, QScrollArea, QSize, QSizePolicy,
|
||||||
QStandardItem, QStandardItemModel, Qt, QToolButton, QVBoxLayout, QWidget,
|
QSpacerItem, QStandardItem, QStandardItemModel, Qt, QToolButton, QVBoxLayout,
|
||||||
QItemSelection, QListWidget, QListWidgetItem, pyqtSignal
|
QWidget, pyqtSignal,
|
||||||
)
|
)
|
||||||
|
|
||||||
from calibre import as_unicode, prepare_string_for_xml, sanitize_file_name
|
from calibre import as_unicode, prepare_string_for_xml, sanitize_file_name
|
||||||
from calibre.constants import config_dir
|
from calibre.constants import config_dir
|
||||||
from calibre.gui2 import (
|
from calibre.gui2 import (
|
||||||
choose_files, choose_save_file, error_dialog, gprefs, open_local_file,
|
choose_files, choose_save_file, error_dialog, gprefs, open_local_file,
|
||||||
pixmap_to_data, question_dialog
|
pixmap_to_data, question_dialog,
|
||||||
)
|
)
|
||||||
from calibre.gui2.dialogs.template_dialog import TemplateDialog
|
from calibre.gui2.dialogs.template_dialog import TemplateDialog
|
||||||
from calibre.gui2.metadata.single_download import RichTextDelegate
|
from calibre.gui2.metadata.single_download import RichTextDelegate
|
||||||
from calibre.gui2.preferences import ListViewWithMoveByKeyPress
|
from calibre.gui2.preferences import ListViewWithMoveByKeyPress
|
||||||
from calibre.gui2.widgets2 import ColorButton, FlowLayout, Separator
|
from calibre.gui2.widgets2 import ColorButton, FlowLayout, Separator
|
||||||
from calibre.library.coloring import (
|
from calibre.library.coloring import (
|
||||||
Rule, color_row_key, conditionable_columns, displayable_columns,
|
Rule, color_row_key, conditionable_columns, displayable_columns, rule_from_template,
|
||||||
rule_from_template
|
|
||||||
)
|
)
|
||||||
from calibre.utils.icu import lower, sort_key
|
from calibre.utils.icu import lower, sort_key
|
||||||
from calibre.utils.localization import lang_map
|
from calibre.utils.localization import lang_map, ngettext
|
||||||
from polyglot.builtins import iteritems
|
from polyglot.builtins import iteritems
|
||||||
|
|
||||||
all_columns_string = _('All columns')
|
all_columns_string = _('All columns')
|
||||||
|
@ -6,19 +6,20 @@ __copyright__ = '2010, Kovid Goyal <kovid at kovidgoyal.net>'
|
|||||||
|
|
||||||
'''Dialog to create a new custom column'''
|
'''Dialog to create a new custom column'''
|
||||||
|
|
||||||
import copy, re
|
import copy
|
||||||
|
import re
|
||||||
from enum import Enum
|
from enum import Enum
|
||||||
from functools import partial
|
from functools import partial
|
||||||
|
|
||||||
from qt.core import (
|
from qt.core import (
|
||||||
QDialog, Qt, QColor, QIcon, QVBoxLayout, QLabel, QGridLayout,
|
QCheckBox, QColor, QComboBox, QDialog, QDialogButtonBox, QGridLayout, QGroupBox,
|
||||||
QDialogButtonBox, QWidget, QLineEdit, QHBoxLayout, QComboBox,
|
QHBoxLayout, QIcon, QLabel, QLineEdit, QRadioButton, QSpinBox, Qt, QVBoxLayout,
|
||||||
QCheckBox, QSpinBox, QRadioButton, QGroupBox
|
QWidget,
|
||||||
)
|
)
|
||||||
|
|
||||||
from calibre.gui2 import error_dialog
|
from calibre.gui2 import error_dialog
|
||||||
from calibre.gui2.dialogs.template_line_editor import TemplateLineEditor
|
from calibre.gui2.dialogs.template_line_editor import TemplateLineEditor
|
||||||
from calibre.utils.date import parse_date, UNDEFINED_DATE
|
from calibre.utils.date import UNDEFINED_DATE, parse_date
|
||||||
|
from calibre.utils.localization import ngettext
|
||||||
from polyglot.builtins import iteritems
|
from polyglot.builtins import iteritems
|
||||||
|
|
||||||
|
|
||||||
|
@ -7,18 +7,19 @@ __docformat__ = 'restructuredtext en'
|
|||||||
|
|
||||||
from operator import attrgetter
|
from operator import attrgetter
|
||||||
from qt.core import (
|
from qt.core import (
|
||||||
QAbstractListModel, QAbstractTableModel, QDialogButtonBox, QFrame, QIcon, QLabel,
|
QAbstractListModel, QAbstractTableModel, QCursor, QDialog, QDialogButtonBox, QFrame,
|
||||||
QScrollArea, Qt, QVBoxLayout, QWidget, pyqtSignal, QDialog, QMenu, QCursor
|
QIcon, QLabel, QMenu, QScrollArea, Qt, QVBoxLayout, QWidget, pyqtSignal,
|
||||||
)
|
)
|
||||||
|
|
||||||
from calibre.customize.ui import (
|
from calibre.customize.ui import (
|
||||||
all_metadata_plugins, default_disabled_plugins, disable_plugin, enable_plugin,
|
all_metadata_plugins, default_disabled_plugins, disable_plugin, enable_plugin,
|
||||||
is_disabled
|
is_disabled,
|
||||||
)
|
)
|
||||||
from calibre.ebooks.metadata.sources.prefs import msprefs
|
from calibre.ebooks.metadata.sources.prefs import msprefs
|
||||||
from calibre.gui2 import error_dialog, question_dialog
|
from calibre.gui2 import error_dialog, question_dialog
|
||||||
from calibre.gui2.preferences import ConfigWidgetBase, test_widget
|
from calibre.gui2.preferences import ConfigWidgetBase, test_widget
|
||||||
from calibre.gui2.preferences.metadata_sources_ui import Ui_Form
|
from calibre.gui2.preferences.metadata_sources_ui import Ui_Form
|
||||||
|
from calibre.utils.localization import ngettext
|
||||||
from polyglot.builtins import iteritems
|
from polyglot.builtins import iteritems
|
||||||
|
|
||||||
|
|
||||||
|
@ -12,14 +12,14 @@ from qt.core import (
|
|||||||
QApplication, QCheckBox, QComboBox, QDialog, QDialogButtonBox, QDoubleSpinBox,
|
QApplication, QCheckBox, QComboBox, QDialog, QDialogButtonBox, QDoubleSpinBox,
|
||||||
QFormLayout, QFrame, QHBoxLayout, QIcon, QLabel, QLayout, QLineEdit, QListWidget,
|
QFormLayout, QFrame, QHBoxLayout, QIcon, QLabel, QLayout, QLineEdit, QListWidget,
|
||||||
QPlainTextEdit, QPushButton, QScrollArea, QSize, QSizePolicy, QSpinBox, Qt,
|
QPlainTextEdit, QPushButton, QScrollArea, QSize, QSizePolicy, QSpinBox, Qt,
|
||||||
QTabWidget, QTimer, QToolButton, QUrl, QVBoxLayout, QWidget, pyqtSignal, sip
|
QTabWidget, QTimer, QToolButton, QUrl, QVBoxLayout, QWidget, pyqtSignal, sip,
|
||||||
)
|
)
|
||||||
|
|
||||||
from calibre import as_unicode
|
from calibre import as_unicode
|
||||||
from calibre.constants import isportable, iswindows
|
from calibre.constants import isportable, iswindows
|
||||||
from calibre.gui2 import (
|
from calibre.gui2 import (
|
||||||
choose_files, choose_save_file, config, error_dialog, gprefs, info_dialog,
|
choose_files, choose_save_file, config, error_dialog, gprefs, info_dialog, open_url,
|
||||||
open_url, warning_dialog
|
warning_dialog,
|
||||||
)
|
)
|
||||||
from calibre.gui2.preferences import AbortCommit, ConfigWidgetBase, test_widget
|
from calibre.gui2.preferences import AbortCommit, ConfigWidgetBase, test_widget
|
||||||
from calibre.gui2.widgets import HistoryLineEdit
|
from calibre.gui2.widgets import HistoryLineEdit
|
||||||
@ -29,9 +29,10 @@ from calibre.srv.library_broker import load_gui_libraries
|
|||||||
from calibre.srv.loop import parse_trusted_ips
|
from calibre.srv.loop import parse_trusted_ips
|
||||||
from calibre.srv.opts import change_settings, options, server_config
|
from calibre.srv.opts import change_settings, options, server_config
|
||||||
from calibre.srv.users import (
|
from calibre.srv.users import (
|
||||||
UserManager, create_user_data, validate_password, validate_username
|
UserManager, create_user_data, validate_password, validate_username,
|
||||||
)
|
)
|
||||||
from calibre.utils.icu import primary_sort_key
|
from calibre.utils.icu import primary_sort_key
|
||||||
|
from calibre.utils.localization import ngettext
|
||||||
from calibre.utils.shared_file import share_open
|
from calibre.utils.shared_file import share_open
|
||||||
from polyglot.builtins import as_bytes
|
from polyglot.builtins import as_bytes
|
||||||
|
|
||||||
|
@ -8,14 +8,14 @@ from functools import partial
|
|||||||
from qt.core import (
|
from qt.core import (
|
||||||
QAbstractItemView, QAction, QComboBox, QDialog, QDialogButtonBox, QFrame,
|
QAbstractItemView, QAction, QComboBox, QDialog, QDialogButtonBox, QFrame,
|
||||||
QGridLayout, QIcon, QLabel, QLineEdit, QListView, QMenu, QRadioButton, QSize,
|
QGridLayout, QIcon, QLabel, QLineEdit, QListView, QMenu, QRadioButton, QSize,
|
||||||
QStringListModel, Qt, QTextBrowser, QVBoxLayout, QSortFilterProxyModel
|
QSortFilterProxyModel, QStringListModel, Qt, QTextBrowser, QVBoxLayout,
|
||||||
)
|
)
|
||||||
|
|
||||||
from calibre.gui2 import error_dialog, gprefs, question_dialog
|
from calibre.gui2 import error_dialog, gprefs, question_dialog
|
||||||
from calibre.gui2.dialogs.confirm_delete import confirm
|
from calibre.gui2.dialogs.confirm_delete import confirm
|
||||||
from calibre.gui2.widgets import ComboBoxWithHelp
|
from calibre.gui2.widgets import ComboBoxWithHelp
|
||||||
from calibre.utils.icu import sort_key
|
from calibre.utils.icu import sort_key
|
||||||
from calibre.utils.localization import localize_user_manual_link, pgettext
|
from calibre.utils.localization import localize_user_manual_link, ngettext, pgettext
|
||||||
from calibre.utils.search_query_parser import ParseException
|
from calibre.utils.search_query_parser import ParseException
|
||||||
|
|
||||||
|
|
||||||
|
@ -5,22 +5,25 @@ __license__ = 'GPL v3'
|
|||||||
__copyright__ = '2011, Kovid Goyal <kovid@kovidgoyal.net>'
|
__copyright__ = '2011, Kovid Goyal <kovid@kovidgoyal.net>'
|
||||||
__docformat__ = 'restructuredtext en'
|
__docformat__ = 'restructuredtext en'
|
||||||
|
|
||||||
import copy, textwrap
|
import copy
|
||||||
|
import textwrap
|
||||||
from functools import partial
|
from functools import partial
|
||||||
|
|
||||||
from qt.core import (
|
from qt.core import (
|
||||||
Qt, QIcon, QWidget, QHBoxLayout, QVBoxLayout, QToolButton, QLabel, QFrame, QDialog, QComboBox, QLineEdit,
|
QAction, QActionGroup, QComboBox, QDialog, QFrame, QHBoxLayout, QIcon, QLabel,
|
||||||
QTimer, QMenu, QActionGroup, QAction, QSizePolicy, pyqtSignal)
|
QLineEdit, QMenu, QSizePolicy, Qt, QTimer, QToolButton, QVBoxLayout, QWidget,
|
||||||
|
pyqtSignal,
|
||||||
|
)
|
||||||
|
|
||||||
from calibre.gui2 import error_dialog, question_dialog, gprefs, config
|
from calibre.ebooks.metadata import title_sort
|
||||||
|
from calibre.gui2 import config, error_dialog, gprefs, question_dialog
|
||||||
|
from calibre.gui2.dialogs.edit_authors_dialog import EditAuthorsDialog
|
||||||
|
from calibre.gui2.dialogs.tag_categories import TagCategories
|
||||||
|
from calibre.gui2.dialogs.tag_list_editor import TagListEditor
|
||||||
|
from calibre.gui2.tag_browser.view import TagsView
|
||||||
from calibre.gui2.widgets import HistoryLineEdit
|
from calibre.gui2.widgets import HistoryLineEdit
|
||||||
from calibre.library.field_metadata import category_icon_map
|
from calibre.library.field_metadata import category_icon_map
|
||||||
from calibre.utils.icu import sort_key
|
from calibre.utils.icu import sort_key
|
||||||
from calibre.gui2.tag_browser.view import TagsView
|
from calibre.utils.localization import ngettext
|
||||||
from calibre.ebooks.metadata import title_sort
|
|
||||||
from calibre.gui2.dialogs.tag_categories import TagCategories
|
|
||||||
from calibre.gui2.dialogs.tag_list_editor import TagListEditor
|
|
||||||
from calibre.gui2.dialogs.edit_authors_dialog import EditAuthorsDialog
|
|
||||||
from polyglot.builtins import iteritems
|
from polyglot.builtins import iteritems
|
||||||
|
|
||||||
|
|
||||||
|
@ -1,7 +1,6 @@
|
|||||||
#!/usr/bin/env python
|
#!/usr/bin/env python
|
||||||
# License: GPLv3 Copyright: 2013, Kovid Goyal <kovid at kovidgoyal.net>
|
# License: GPLv3 Copyright: 2013, Kovid Goyal <kovid at kovidgoyal.net>
|
||||||
|
|
||||||
|
|
||||||
import errno
|
import errno
|
||||||
import os
|
import os
|
||||||
import shutil
|
import shutil
|
||||||
@ -11,39 +10,37 @@ from functools import partial, wraps
|
|||||||
from qt.core import (
|
from qt.core import (
|
||||||
QApplication, QCheckBox, QDialog, QDialogButtonBox, QGridLayout, QIcon,
|
QApplication, QCheckBox, QDialog, QDialogButtonBox, QGridLayout, QIcon,
|
||||||
QInputDialog, QLabel, QMimeData, QObject, QSize, Qt, QTimer, QUrl, QVBoxLayout,
|
QInputDialog, QLabel, QMimeData, QObject, QSize, Qt, QTimer, QUrl, QVBoxLayout,
|
||||||
pyqtSignal
|
pyqtSignal,
|
||||||
)
|
)
|
||||||
|
|
||||||
from calibre import isbytestring, prints
|
from calibre import isbytestring, prints
|
||||||
from calibre.constants import cache_dir, iswindows
|
from calibre.constants import cache_dir, iswindows
|
||||||
from calibre.ebooks.oeb.base import urlnormalize
|
from calibre.ebooks.oeb.base import urlnormalize
|
||||||
from calibre.ebooks.oeb.polish.container import (
|
from calibre.ebooks.oeb.polish.container import (
|
||||||
OEB_DOCS, OEB_STYLES, clone_container, get_container as _gc, guess_type
|
OEB_DOCS, OEB_STYLES, clone_container, get_container as _gc, guess_type,
|
||||||
)
|
|
||||||
from calibre.ebooks.oeb.polish.cover import (
|
|
||||||
mark_as_cover, mark_as_titlepage, set_cover
|
|
||||||
)
|
)
|
||||||
|
from calibre.ebooks.oeb.polish.cover import mark_as_cover, mark_as_titlepage, set_cover
|
||||||
from calibre.ebooks.oeb.polish.css import filter_css, rename_class
|
from calibre.ebooks.oeb.polish.css import filter_css, rename_class
|
||||||
from calibre.ebooks.oeb.polish.main import SUPPORTED, tweak_polish
|
from calibre.ebooks.oeb.polish.main import SUPPORTED, tweak_polish
|
||||||
from calibre.ebooks.oeb.polish.pretty import fix_all_html, pretty_all
|
from calibre.ebooks.oeb.polish.pretty import fix_all_html, pretty_all
|
||||||
from calibre.ebooks.oeb.polish.replace import (
|
from calibre.ebooks.oeb.polish.replace import (
|
||||||
get_recommended_folders, rationalize_folders, rename_files, replace_file
|
get_recommended_folders, rationalize_folders, rename_files, replace_file,
|
||||||
)
|
)
|
||||||
from calibre.ebooks.oeb.polish.split import AbortError, merge, multisplit, split
|
from calibre.ebooks.oeb.polish.split import AbortError, merge, multisplit, split
|
||||||
from calibre.ebooks.oeb.polish.toc import (
|
from calibre.ebooks.oeb.polish.toc import (
|
||||||
create_inline_toc, mark_as_nav, remove_names_from_toc
|
create_inline_toc, mark_as_nav, remove_names_from_toc,
|
||||||
)
|
)
|
||||||
from calibre.ebooks.oeb.polish.utils import (
|
from calibre.ebooks.oeb.polish.utils import (
|
||||||
link_stylesheets, setup_css_parser_serialization as scs
|
link_stylesheets, setup_css_parser_serialization as scs,
|
||||||
)
|
)
|
||||||
from calibre.gui2 import (
|
from calibre.gui2 import (
|
||||||
add_to_recent_docs, choose_dir, choose_files, choose_save_file, error_dialog, warning_dialog,
|
add_to_recent_docs, choose_dir, choose_files, choose_save_file, error_dialog,
|
||||||
info_dialog, open_url, question_dialog
|
info_dialog, open_url, question_dialog, warning_dialog,
|
||||||
)
|
)
|
||||||
from calibre.gui2.dialogs.confirm_delete import confirm
|
from calibre.gui2.dialogs.confirm_delete import confirm
|
||||||
from calibre.gui2.tweak_book import (
|
from calibre.gui2.tweak_book import (
|
||||||
actions, current_container, dictionaries, editor_name, editors, set_book_locale,
|
actions, current_container, dictionaries, editor_name, editors, set_book_locale,
|
||||||
set_current_container, tprefs
|
set_current_container, tprefs,
|
||||||
)
|
)
|
||||||
from calibre.gui2.tweak_book.completion.worker import completion_worker
|
from calibre.gui2.tweak_book.completion.worker import completion_worker
|
||||||
from calibre.gui2.tweak_book.editor import editor_from_syntax, syntax_from_mime
|
from calibre.gui2.tweak_book.editor import editor_from_syntax, syntax_from_mime
|
||||||
@ -52,23 +49,22 @@ from calibre.gui2.tweak_book.file_list import FILE_COPY_MIME, NewFileDialog
|
|||||||
from calibre.gui2.tweak_book.preferences import Preferences
|
from calibre.gui2.tweak_book.preferences import Preferences
|
||||||
from calibre.gui2.tweak_book.preview import parse_worker
|
from calibre.gui2.tweak_book.preview import parse_worker
|
||||||
from calibre.gui2.tweak_book.save import (
|
from calibre.gui2.tweak_book.save import (
|
||||||
SaveManager, find_first_existing_ancestor, save_container
|
SaveManager, find_first_existing_ancestor, save_container,
|
||||||
)
|
)
|
||||||
from calibre.gui2.tweak_book.search import run_search, validate_search_request
|
from calibre.gui2.tweak_book.search import run_search, validate_search_request
|
||||||
from calibre.gui2.tweak_book.spell import (
|
from calibre.gui2.tweak_book.spell import find_next as find_next_word, find_next_error
|
||||||
find_next as find_next_word, find_next_error
|
|
||||||
)
|
|
||||||
from calibre.gui2.tweak_book.toc import TOCEditor
|
from calibre.gui2.tweak_book.toc import TOCEditor
|
||||||
from calibre.gui2.tweak_book.undo import GlobalUndoHistory
|
from calibre.gui2.tweak_book.undo import GlobalUndoHistory
|
||||||
from calibre.gui2.tweak_book.widgets import (
|
from calibre.gui2.tweak_book.widgets import (
|
||||||
AddCover, FilterCSS, ImportForeign, InsertLink, InsertSemantics, InsertTag,
|
AddCover, FilterCSS, ImportForeign, InsertLink, InsertSemantics, InsertTag,
|
||||||
MultiSplit, QuickOpen, RationalizeFolders
|
MultiSplit, QuickOpen, RationalizeFolders,
|
||||||
)
|
)
|
||||||
from calibre.gui2.widgets import BusyCursor
|
from calibre.gui2.widgets import BusyCursor
|
||||||
from calibre.ptempfile import PersistentTemporaryDirectory, TemporaryDirectory
|
from calibre.ptempfile import PersistentTemporaryDirectory, TemporaryDirectory
|
||||||
from calibre.utils.config import JSONConfig
|
from calibre.utils.config import JSONConfig
|
||||||
from calibre.utils.icu import numeric_sort_key
|
from calibre.utils.icu import numeric_sort_key
|
||||||
from calibre.utils.imghdr import identify
|
from calibre.utils.imghdr import identify
|
||||||
|
from calibre.utils.localization import ngettext
|
||||||
from calibre.utils.tdir_in_cache import tdir_in_cache
|
from calibre.utils.tdir_in_cache import tdir_in_cache
|
||||||
from polyglot.builtins import as_bytes, iteritems, itervalues, string_or_bytes
|
from polyglot.builtins import as_bytes, iteritems, itervalues, string_or_bytes
|
||||||
from polyglot.urllib import urlparse
|
from polyglot.urllib import urlparse
|
||||||
@ -216,7 +212,7 @@ class Boss(QObject):
|
|||||||
ed.apply_settings(dictionaries_changed=p.dictionaries_changed)
|
ed.apply_settings(dictionaries_changed=p.dictionaries_changed)
|
||||||
if orig_spell != tprefs['inline_spell_check']:
|
if orig_spell != tprefs['inline_spell_check']:
|
||||||
from calibre.gui2.tweak_book.editor.syntax.html import (
|
from calibre.gui2.tweak_book.editor.syntax.html import (
|
||||||
refresh_spell_check_status
|
refresh_spell_check_status,
|
||||||
)
|
)
|
||||||
refresh_spell_check_status()
|
refresh_spell_check_status()
|
||||||
for ed in itervalues(editors):
|
for ed in itervalues(editors):
|
||||||
@ -502,7 +498,7 @@ class Boss(QObject):
|
|||||||
added_name = self.do_add_file(d.file_name, d.file_data, using_template=d.using_template, edit_file=True)
|
added_name = self.do_add_file(d.file_name, d.file_data, using_template=d.using_template, edit_file=True)
|
||||||
if d.file_name.rpartition('.')[2].lower() in ('ttf', 'otf', 'woff'):
|
if d.file_name.rpartition('.')[2].lower() in ('ttf', 'otf', 'woff'):
|
||||||
from calibre.gui2.tweak_book.manage_fonts import (
|
from calibre.gui2.tweak_book.manage_fonts import (
|
||||||
show_font_face_rule_for_font_file
|
show_font_face_rule_for_font_file,
|
||||||
)
|
)
|
||||||
show_font_face_rule_for_font_file(d.file_data, added_name, self.gui)
|
show_font_face_rule_for_font_file(d.file_data, added_name, self.gui)
|
||||||
|
|
||||||
@ -567,7 +563,7 @@ class Boss(QObject):
|
|||||||
completion_worker().clear_caches('names')
|
completion_worker().clear_caches('names')
|
||||||
if added_fonts:
|
if added_fonts:
|
||||||
from calibre.gui2.tweak_book.manage_fonts import (
|
from calibre.gui2.tweak_book.manage_fonts import (
|
||||||
show_font_face_rule_for_font_files
|
show_font_face_rule_for_font_files,
|
||||||
)
|
)
|
||||||
show_font_face_rule_for_font_files(c, added_fonts, self.gui)
|
show_font_face_rule_for_font_files(c, added_fonts, self.gui)
|
||||||
|
|
||||||
@ -1219,7 +1215,7 @@ class Boss(QObject):
|
|||||||
|
|
||||||
def editor_class_clicked(self, class_data):
|
def editor_class_clicked(self, class_data):
|
||||||
from calibre.gui2.tweak_book.jump_to_class import (
|
from calibre.gui2.tweak_book.jump_to_class import (
|
||||||
NoMatchingRuleFound, NoMatchingTagFound, find_first_matching_rule
|
NoMatchingRuleFound, NoMatchingTagFound, find_first_matching_rule,
|
||||||
)
|
)
|
||||||
ed = self.gui.central.current_editor
|
ed = self.gui.central.current_editor
|
||||||
name = editor_name(ed)
|
name = editor_name(ed)
|
||||||
@ -1617,7 +1613,7 @@ class Boss(QObject):
|
|||||||
if not self.ensure_book(_('You must first open a book in order to compress images.')):
|
if not self.ensure_book(_('You must first open a book in order to compress images.')):
|
||||||
return
|
return
|
||||||
from calibre.gui2.tweak_book.polish import (
|
from calibre.gui2.tweak_book.polish import (
|
||||||
CompressImages, CompressImagesProgress, show_report
|
CompressImages, CompressImagesProgress, show_report,
|
||||||
)
|
)
|
||||||
d = CompressImages(self.gui)
|
d = CompressImages(self.gui)
|
||||||
if d.exec() == QDialog.DialogCode.Accepted:
|
if d.exec() == QDialog.DialogCode.Accepted:
|
||||||
|
@ -1,19 +1,20 @@
|
|||||||
#!/usr/bin/env python
|
#!/usr/bin/env python
|
||||||
# License: GPLv3 Copyright: 2015, Kovid Goyal <kovid at kovidgoyal.net>
|
# License: GPLv3 Copyright: 2015, Kovid Goyal <kovid at kovidgoyal.net>
|
||||||
|
|
||||||
|
|
||||||
from collections import defaultdict
|
from collections import defaultdict
|
||||||
|
from qt.core import (
|
||||||
|
QCheckBox, QDialogButtonBox, QHBoxLayout, QIcon, QInputDialog, QLabel, QProgressBar,
|
||||||
|
QSizePolicy, QStackedWidget, Qt, QTextBrowser, QVBoxLayout, QWidget, pyqtSignal,
|
||||||
|
)
|
||||||
from threading import Thread
|
from threading import Thread
|
||||||
|
|
||||||
from qt.core import (
|
|
||||||
QCheckBox, QHBoxLayout, QIcon, QInputDialog, QLabel, QProgressBar, QSizePolicy,
|
|
||||||
QStackedWidget, Qt, QTextBrowser, QVBoxLayout, QWidget, pyqtSignal, QDialogButtonBox
|
|
||||||
)
|
|
||||||
|
|
||||||
from calibre.gui2 import error_dialog
|
from calibre.gui2 import error_dialog
|
||||||
from calibre.gui2.tweak_book import current_container, editors, set_current_container, tprefs
|
from calibre.gui2.tweak_book import (
|
||||||
|
current_container, editors, set_current_container, tprefs,
|
||||||
|
)
|
||||||
from calibre.gui2.tweak_book.boss import get_boss
|
from calibre.gui2.tweak_book.boss import get_boss
|
||||||
from calibre.gui2.tweak_book.widgets import Dialog
|
from calibre.gui2.tweak_book.widgets import Dialog
|
||||||
|
from calibre.utils.localization import ngettext
|
||||||
from polyglot.builtins import iteritems
|
from polyglot.builtins import iteritems
|
||||||
|
|
||||||
|
|
||||||
@ -168,6 +169,7 @@ class CheckExternalLinks(Dialog):
|
|||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
import sys
|
import sys
|
||||||
|
|
||||||
from calibre.gui2 import Application
|
from calibre.gui2 import Application
|
||||||
from calibre.gui2.tweak_book.boss import get_container
|
from calibre.gui2.tweak_book.boss import get_container
|
||||||
app = Application([])
|
app = Application([])
|
||||||
|
@ -2,17 +2,20 @@
|
|||||||
# License: GPLv3 Copyright: 2016, Kovid Goyal <kovid at kovidgoyal.net>
|
# License: GPLv3 Copyright: 2016, Kovid Goyal <kovid at kovidgoyal.net>
|
||||||
|
|
||||||
|
|
||||||
|
from qt.core import (
|
||||||
|
QDialogButtonBox, QGridLayout, QIcon, QLabel, QListWidget, QListWidgetItem,
|
||||||
|
QProgressBar, QScrollArea, QSize, Qt, QVBoxLayout, QWidget, pyqtSignal,
|
||||||
|
)
|
||||||
from threading import Thread
|
from threading import Thread
|
||||||
|
|
||||||
from qt.core import (
|
from calibre.ebooks.oeb.polish.download import (
|
||||||
pyqtSignal, QWidget, QListWidget, QListWidgetItem, QLabel, Qt,
|
download_external_resources, get_external_resources, replace_resources,
|
||||||
QVBoxLayout, QScrollArea, QProgressBar, QGridLayout, QSize, QIcon, QDialogButtonBox)
|
)
|
||||||
|
|
||||||
from calibre.gui2 import error_dialog, info_dialog, warning_dialog
|
from calibre.gui2 import error_dialog, info_dialog, warning_dialog
|
||||||
|
from calibre.gui2.progress_indicator import WaitStack
|
||||||
from calibre.gui2.tweak_book import current_container
|
from calibre.gui2.tweak_book import current_container
|
||||||
from calibre.gui2.tweak_book.widgets import Dialog
|
from calibre.gui2.tweak_book.widgets import Dialog
|
||||||
from calibre.gui2.progress_indicator import WaitStack
|
from calibre.utils.localization import ngettext
|
||||||
from calibre.ebooks.oeb.polish.download import get_external_resources, download_external_resources, replace_resources
|
|
||||||
from polyglot.builtins import iteritems
|
from polyglot.builtins import iteritems
|
||||||
|
|
||||||
|
|
||||||
@ -258,8 +261,9 @@ class DownloadResources(Dialog):
|
|||||||
|
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
from calibre.gui2 import Application
|
|
||||||
import sys
|
import sys
|
||||||
|
|
||||||
|
from calibre.gui2 import Application
|
||||||
app = Application([])
|
app = Application([])
|
||||||
from calibre.gui2.tweak_book import set_current_container
|
from calibre.gui2.tweak_book import set_current_container
|
||||||
from calibre.gui2.tweak_book.boss import get_container
|
from calibre.gui2.tweak_book.boss import get_container
|
||||||
|
@ -13,31 +13,31 @@ from qt.core import (
|
|||||||
QFormLayout, QGridLayout, QIcon, QInputDialog, QItemSelectionModel, QLabel,
|
QFormLayout, QGridLayout, QIcon, QInputDialog, QItemSelectionModel, QLabel,
|
||||||
QLineEdit, QListWidget, QListWidgetItem, QMenu, QPainter, QPixmap, QRadioButton,
|
QLineEdit, QListWidget, QListWidgetItem, QMenu, QPainter, QPixmap, QRadioButton,
|
||||||
QScrollArea, QSize, QSpinBox, QStyle, QStyledItemDelegate, Qt, QTimer, QTreeView,
|
QScrollArea, QSize, QSpinBox, QStyle, QStyledItemDelegate, Qt, QTimer, QTreeView,
|
||||||
QTreeWidget, QTreeWidgetItem, QVBoxLayout, QWidget, pyqtSignal, sip
|
QTreeWidget, QTreeWidgetItem, QVBoxLayout, QWidget, pyqtSignal, sip,
|
||||||
)
|
)
|
||||||
|
|
||||||
from calibre import human_readable, 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.base import OEB_DOCS, OEB_STYLES
|
||||||
from calibre.ebooks.oeb.polish.cover import (
|
from calibre.ebooks.oeb.polish.cover import (
|
||||||
get_cover_page_name, get_raster_cover_name, is_raster_image
|
get_cover_page_name, get_raster_cover_name, is_raster_image,
|
||||||
)
|
)
|
||||||
from calibre.ebooks.oeb.polish.css import add_stylesheet_links
|
from calibre.ebooks.oeb.polish.css import add_stylesheet_links
|
||||||
from calibre.ebooks.oeb.polish.replace import (
|
from calibre.ebooks.oeb.polish.replace import (
|
||||||
get_recommended_folders, get_spine_order_for_all_files
|
get_recommended_folders, get_spine_order_for_all_files,
|
||||||
)
|
)
|
||||||
from calibre.ebooks.oeb.polish.utils import OEB_FONTS, guess_type
|
from calibre.ebooks.oeb.polish.utils import OEB_FONTS, guess_type
|
||||||
from calibre.gui2 import (
|
from calibre.gui2 import (
|
||||||
choose_dir, choose_files, choose_save_file, elided_text, error_dialog,
|
choose_dir, choose_files, choose_save_file, elided_text, error_dialog,
|
||||||
make_view_use_window_background, question_dialog
|
make_view_use_window_background, question_dialog,
|
||||||
)
|
)
|
||||||
from calibre.gui2.tweak_book import (
|
from calibre.gui2.tweak_book import (
|
||||||
CONTAINER_DND_MIMETYPE, current_container, editors, tprefs
|
CONTAINER_DND_MIMETYPE, current_container, editors, tprefs,
|
||||||
)
|
)
|
||||||
from calibre.gui2.tweak_book.editor import syntax_from_mime
|
from calibre.gui2.tweak_book.editor import syntax_from_mime
|
||||||
from calibre.gui2.tweak_book.templates import template_for
|
from calibre.gui2.tweak_book.templates import template_for
|
||||||
from calibre.utils.fonts.utils import get_font_names
|
from calibre.utils.fonts.utils import get_font_names
|
||||||
from calibre.utils.localization import pgettext
|
|
||||||
from calibre.utils.icu import numeric_sort_key
|
from calibre.utils.icu import numeric_sort_key
|
||||||
|
from calibre.utils.localization import ngettext, pgettext
|
||||||
from calibre_extensions.progress_indicator import set_no_activate_on_click
|
from calibre_extensions.progress_indicator import set_no_activate_on_click
|
||||||
from polyglot.binary import as_hex_unicode
|
from polyglot.binary import as_hex_unicode
|
||||||
from polyglot.builtins import iteritems
|
from polyglot.builtins import iteritems
|
||||||
|
@ -22,6 +22,7 @@ from calibre.gui2.widgets import BusyCursor
|
|||||||
from calibre.utils.fonts.metadata import FontMetadata, UnsupportedFont
|
from calibre.utils.fonts.metadata import FontMetadata, UnsupportedFont
|
||||||
from calibre.utils.fonts.scanner import NoFonts, font_scanner
|
from calibre.utils.fonts.scanner import NoFonts, font_scanner
|
||||||
from calibre.utils.icu import lower as icu_lower, primary_sort_key as sort_key
|
from calibre.utils.icu import lower as icu_lower, primary_sort_key as sort_key
|
||||||
|
from calibre.utils.localization import ngettext
|
||||||
from polyglot.builtins import iteritems
|
from polyglot.builtins import iteritems
|
||||||
|
|
||||||
|
|
||||||
|
@ -5,30 +5,34 @@ __license__ = 'GPL v3'
|
|||||||
__copyright__ = '2013, Kovid Goyal <kovid at kovidgoyal.net>'
|
__copyright__ = '2013, Kovid Goyal <kovid at kovidgoyal.net>'
|
||||||
|
|
||||||
import numbers
|
import numbers
|
||||||
from operator import attrgetter, methodcaller
|
|
||||||
from functools import partial
|
|
||||||
from collections import namedtuple
|
from collections import namedtuple
|
||||||
from polyglot.builtins import iteritems, itervalues
|
|
||||||
from itertools import product
|
|
||||||
from copy import copy, deepcopy
|
from copy import copy, deepcopy
|
||||||
|
from functools import partial
|
||||||
|
from itertools import product
|
||||||
|
from operator import attrgetter, methodcaller
|
||||||
from qt.core import (
|
from qt.core import (
|
||||||
QDialog, QGridLayout, QStackedWidget, QDialogButtonBox, QListWidget,
|
QAbstractItemView, QCheckBox, QComboBox, QDialog, QDialogButtonBox, QDoubleSpinBox,
|
||||||
QListWidgetItem, QIcon, QWidget, QSize, QFormLayout, Qt, QSpinBox, QListView,
|
QFont, QFontComboBox, QFormLayout, QGridLayout, QGroupBox, QHBoxLayout, QIcon,
|
||||||
QCheckBox, pyqtSignal, QDoubleSpinBox, QComboBox, QLabel, QFont,
|
QLabel, QListView, QListWidget, QListWidgetItem, QPushButton, QRadioButton, QSize,
|
||||||
QFontComboBox, QPushButton, QSizePolicy, QHBoxLayout, QGroupBox, QAbstractItemView,
|
QSizePolicy, QSpacerItem, QSpinBox, QStackedWidget, Qt, QTimer, QToolButton,
|
||||||
QToolButton, QVBoxLayout, QSpacerItem, QTimer, QRadioButton)
|
QVBoxLayout, QWidget, pyqtSignal,
|
||||||
|
)
|
||||||
|
|
||||||
from calibre import prepare_string_for_xml
|
from calibre import prepare_string_for_xml
|
||||||
from calibre.utils.localization import get_lang
|
|
||||||
from calibre.gui2 import info_dialog
|
from calibre.gui2 import info_dialog
|
||||||
from calibre.gui2.keyboard import ShortcutConfig
|
|
||||||
from calibre.gui2.tweak_book import tprefs, toolbar_actions, editor_toolbar_actions, actions
|
|
||||||
from calibre.gui2.tweak_book.editor.themes import default_theme, all_theme_names, ThemeEditor
|
|
||||||
from calibre.gui2.tweak_book.spell import ManageDictionaries
|
|
||||||
from calibre.gui2.font_family_chooser import FontFamilyChooser
|
from calibre.gui2.font_family_chooser import FontFamilyChooser
|
||||||
|
from calibre.gui2.keyboard import ShortcutConfig
|
||||||
|
from calibre.gui2.tweak_book import (
|
||||||
|
actions, editor_toolbar_actions, toolbar_actions, tprefs,
|
||||||
|
)
|
||||||
|
from calibre.gui2.tweak_book.editor.themes import (
|
||||||
|
ThemeEditor, all_theme_names, default_theme,
|
||||||
|
)
|
||||||
|
from calibre.gui2.tweak_book.spell import ManageDictionaries
|
||||||
from calibre.gui2.tweak_book.widgets import Dialog
|
from calibre.gui2.tweak_book.widgets import Dialog
|
||||||
from calibre.gui2.widgets2 import ColorButton
|
from calibre.gui2.widgets2 import ColorButton
|
||||||
|
from calibre.utils.localization import get_lang, ngettext
|
||||||
|
from polyglot.builtins import iteritems, itervalues
|
||||||
|
|
||||||
|
|
||||||
class BasicSettings(QWidget): # {{{
|
class BasicSettings(QWidget): # {{{
|
||||||
@ -348,7 +352,7 @@ class PreviewSettings(BasicSettings): # {{{
|
|||||||
|
|
||||||
def default_font(which):
|
def default_font(which):
|
||||||
if not self.default_font_settings:
|
if not self.default_font_settings:
|
||||||
from qt.webengine import QWebEngineSettings, QWebEnginePage
|
from qt.webengine import QWebEnginePage, QWebEngineSettings
|
||||||
page = QWebEnginePage()
|
page = QWebEnginePage()
|
||||||
s = page.settings()
|
s = page.settings()
|
||||||
self.default_font_settings = {
|
self.default_font_settings = {
|
||||||
@ -672,8 +676,9 @@ class TemplatesDialog(Dialog): # {{{
|
|||||||
Dialog.__init__(self, _('Customize templates'), 'customize-templates', parent=parent)
|
Dialog.__init__(self, _('Customize templates'), 'customize-templates', parent=parent)
|
||||||
|
|
||||||
def setup_ui(self):
|
def setup_ui(self):
|
||||||
from calibre.gui2.tweak_book.templates import DEFAULT_TEMPLATES
|
|
||||||
from calibre.gui2.tweak_book.editor.text import TextEdit
|
from calibre.gui2.tweak_book.editor.text import TextEdit
|
||||||
|
from calibre.gui2.tweak_book.templates import DEFAULT_TEMPLATES
|
||||||
|
|
||||||
# Cannot use QFormLayout as it does not play nice with TextEdit on windows
|
# Cannot use QFormLayout as it does not play nice with TextEdit on windows
|
||||||
self.l = l = QVBoxLayout(self)
|
self.l = l = QVBoxLayout(self)
|
||||||
|
|
||||||
|
@ -4,20 +4,20 @@ __copyright__ = '2008, Kovid Goyal <kovid at kovidgoyal.net>'
|
|||||||
import re
|
import re
|
||||||
import ssl
|
import ssl
|
||||||
from qt.core import (
|
from qt.core import (
|
||||||
QCheckBox, QDialog, QDialogButtonBox, QGridLayout, QIcon, QLabel, QObject, Qt,
|
QCheckBox, QDialog, QDialogButtonBox, QGridLayout, QIcon, QLabel, QObject, Qt, QUrl,
|
||||||
QUrl, pyqtSignal
|
pyqtSignal,
|
||||||
)
|
)
|
||||||
from threading import Event, Thread
|
from threading import Event, Thread
|
||||||
|
|
||||||
from calibre import as_unicode, prints
|
from calibre import as_unicode, prints
|
||||||
from calibre.constants import (
|
from calibre.constants import (
|
||||||
__appname__, __version__, ismacos, isportable, iswindows, numeric_version
|
__appname__, __version__, ismacos, isportable, iswindows, numeric_version,
|
||||||
)
|
)
|
||||||
from calibre.gui2 import config, dynamic, icon_resource_manager, open_url
|
from calibre.gui2 import config, dynamic, icon_resource_manager, open_url
|
||||||
from calibre.gui2.dialogs.plugin_updater import get_plugin_updates_available
|
from calibre.gui2.dialogs.plugin_updater import get_plugin_updates_available
|
||||||
from calibre.utils.config import prefs
|
from calibre.utils.config import prefs
|
||||||
from calibre.utils.https import get_https_resource_securely
|
from calibre.utils.https import get_https_resource_securely
|
||||||
from calibre.utils.localization import localize_website_link
|
from calibre.utils.localization import localize_website_link, ngettext
|
||||||
from calibre.utils.serialize import msgpack_dumps, msgpack_loads
|
from calibre.utils.serialize import msgpack_dumps, msgpack_loads
|
||||||
from polyglot.binary import as_hex_unicode, from_hex_bytes
|
from polyglot.binary import as_hex_unicode, from_hex_bytes
|
||||||
|
|
||||||
@ -168,7 +168,7 @@ class UpdateNotification(QDialog):
|
|||||||
|
|
||||||
def get_plugins(self):
|
def get_plugins(self):
|
||||||
from calibre.gui2.dialogs.plugin_updater import (
|
from calibre.gui2.dialogs.plugin_updater import (
|
||||||
FILTER_UPDATE_AVAILABLE, PluginUpdaterDialog
|
FILTER_UPDATE_AVAILABLE, PluginUpdaterDialog,
|
||||||
)
|
)
|
||||||
d = PluginUpdaterDialog(self.parent(),
|
d = PluginUpdaterDialog(self.parent(),
|
||||||
initial_filter=FILTER_UPDATE_AVAILABLE)
|
initial_filter=FILTER_UPDATE_AVAILABLE)
|
||||||
@ -238,7 +238,7 @@ class UpdateMixin:
|
|||||||
elif has_plugin_updates:
|
elif has_plugin_updates:
|
||||||
if force:
|
if force:
|
||||||
from calibre.gui2.dialogs.plugin_updater import (
|
from calibre.gui2.dialogs.plugin_updater import (
|
||||||
FILTER_UPDATE_AVAILABLE, PluginUpdaterDialog
|
FILTER_UPDATE_AVAILABLE, PluginUpdaterDialog,
|
||||||
)
|
)
|
||||||
d = PluginUpdaterDialog(self,
|
d = PluginUpdaterDialog(self,
|
||||||
initial_filter=FILTER_UPDATE_AVAILABLE)
|
initial_filter=FILTER_UPDATE_AVAILABLE)
|
||||||
|
@ -8,26 +8,27 @@ from functools import lru_cache
|
|||||||
from itertools import chain
|
from itertools import chain
|
||||||
from qt.core import (
|
from qt.core import (
|
||||||
QAbstractItemView, QColor, QDialog, QFont, QHBoxLayout, QIcon, QImage,
|
QAbstractItemView, QColor, QDialog, QFont, QHBoxLayout, QIcon, QImage,
|
||||||
QItemSelectionModel, QKeySequence, QLabel, QMenu, QPainter, QPainterPath,
|
QItemSelectionModel, QKeySequence, QLabel, QMenu, QPainter, QPainterPath, QPalette,
|
||||||
QPalette, QPixmap, QPushButton, QRect, QSizePolicy, QStyle, Qt, QTextCursor,
|
QPixmap, QPushButton, QRect, QSizePolicy, QStyle, Qt, QTextCursor, QTextEdit,
|
||||||
QTextEdit, QTreeWidget, QTreeWidgetItem, QVBoxLayout, QWidget, pyqtSignal
|
QTreeWidget, QTreeWidgetItem, QVBoxLayout, QWidget, pyqtSignal,
|
||||||
)
|
)
|
||||||
|
|
||||||
from calibre.constants import (
|
from calibre.constants import (
|
||||||
builtin_colors_dark, builtin_colors_light, builtin_decorations
|
builtin_colors_dark, builtin_colors_light, builtin_decorations,
|
||||||
)
|
)
|
||||||
from calibre.ebooks.epub.cfi.parse import cfi_sort_key
|
from calibre.ebooks.epub.cfi.parse import cfi_sort_key
|
||||||
from calibre.gui2 import error_dialog, is_dark_theme, safe_open_url
|
from calibre.gui2 import error_dialog, is_dark_theme, safe_open_url
|
||||||
from calibre.gui2.dialogs.confirm_delete import confirm
|
from calibre.gui2.dialogs.confirm_delete import confirm
|
||||||
from calibre.gui2.gestures import GestureManager
|
from calibre.gui2.gestures import GestureManager
|
||||||
from calibre.gui2.library.annotations import (
|
from calibre.gui2.library.annotations import (
|
||||||
Details, Export as ExportBase, render_highlight_as_text, render_notes
|
Details, Export as ExportBase, render_highlight_as_text, render_notes,
|
||||||
)
|
)
|
||||||
from calibre.gui2.viewer import link_prefix_for_location_links
|
from calibre.gui2.viewer import link_prefix_for_location_links
|
||||||
from calibre.gui2.viewer.config import vprefs
|
from calibre.gui2.viewer.config import vprefs
|
||||||
from calibre.gui2.viewer.search import SearchInput
|
from calibre.gui2.viewer.search import SearchInput
|
||||||
from calibre.gui2.viewer.shortcuts import get_shortcut_for, index_to_key_sequence
|
from calibre.gui2.viewer.shortcuts import get_shortcut_for, index_to_key_sequence
|
||||||
from calibre.gui2.widgets2 import Dialog
|
from calibre.gui2.widgets2 import Dialog
|
||||||
|
from calibre.utils.localization import ngettext
|
||||||
from calibre_extensions.progress_indicator import set_no_activate_on_click
|
from calibre_extensions.progress_indicator import set_no_activate_on_click
|
||||||
|
|
||||||
decoration_cache = {}
|
decoration_cache = {}
|
||||||
|
@ -7,7 +7,7 @@ from collections import Counter, OrderedDict
|
|||||||
from html import escape
|
from html import escape
|
||||||
from qt.core import (
|
from qt.core import (
|
||||||
QAbstractItemView, QCheckBox, QComboBox, QFont, QHBoxLayout, QIcon, QLabel, Qt,
|
QAbstractItemView, QCheckBox, QComboBox, QFont, QHBoxLayout, QIcon, QLabel, Qt,
|
||||||
QToolButton, QTreeWidget, QTreeWidgetItem, QVBoxLayout, QWidget, pyqtSignal
|
QToolButton, QTreeWidget, QTreeWidgetItem, QVBoxLayout, QWidget, pyqtSignal,
|
||||||
)
|
)
|
||||||
from threading import Thread
|
from threading import Thread
|
||||||
|
|
||||||
@ -19,6 +19,7 @@ from calibre.gui2.viewer.config import vprefs
|
|||||||
from calibre.gui2.viewer.web_view import get_data, get_manifest
|
from calibre.gui2.viewer.web_view import get_data, get_manifest
|
||||||
from calibre.gui2.viewer.widgets import ResultsDelegate, SearchBox
|
from calibre.gui2.viewer.widgets import ResultsDelegate, SearchBox
|
||||||
from calibre.utils.icu import primary_collator_without_punctuation
|
from calibre.utils.icu import primary_collator_without_punctuation
|
||||||
|
from calibre.utils.localization import ngettext
|
||||||
from polyglot.builtins import iteritems
|
from polyglot.builtins import iteritems
|
||||||
from polyglot.functools import lru_cache
|
from polyglot.functools import lru_cache
|
||||||
from polyglot.queue import Queue
|
from polyglot.queue import Queue
|
||||||
@ -363,6 +364,7 @@ def search_in_name(name, search_query, ctx_size=75):
|
|||||||
|
|
||||||
else:
|
else:
|
||||||
spans = []
|
spans = []
|
||||||
|
|
||||||
def miter():
|
def miter():
|
||||||
return spans
|
return spans
|
||||||
if raw:
|
if raw:
|
||||||
|
@ -35,8 +35,10 @@ from calibre.utils.date import (
|
|||||||
)
|
)
|
||||||
from calibre.utils.filenames import ascii_text, shorten_components_to
|
from calibre.utils.filenames import ascii_text, shorten_components_to
|
||||||
from calibre.utils.formatter import TemplateFormatter
|
from calibre.utils.formatter import TemplateFormatter
|
||||||
from calibre.utils.icu import capitalize, collation_order, sort_key, upper as icu_upper
|
from calibre.utils.icu import (
|
||||||
from calibre.utils.localization import get_lang, lang_as_iso639_1
|
capitalize, collation_order, sort_key, title_case as icu_title, upper as icu_upper,
|
||||||
|
)
|
||||||
|
from calibre.utils.localization import get_lang, lang_as_iso639_1, ngettext
|
||||||
from calibre.utils.resources import get_image_path as I, get_path as P
|
from calibre.utils.resources import get_image_path as I, get_path as P
|
||||||
from calibre.utils.xml_parse import safe_xml_fromstring
|
from calibre.utils.xml_parse import safe_xml_fromstring
|
||||||
from calibre.utils.zipfile import ZipFile
|
from calibre.utils.zipfile import ZipFile
|
||||||
|
@ -9,6 +9,7 @@ from collections import OrderedDict
|
|||||||
|
|
||||||
from calibre.utils.config_base import tweaks
|
from calibre.utils.config_base import tweaks
|
||||||
from calibre.utils.icu import lower as icu_lower
|
from calibre.utils.icu import lower as icu_lower
|
||||||
|
from calibre.utils.localization import ngettext
|
||||||
from polyglot.builtins import iteritems, itervalues
|
from polyglot.builtins import iteritems, itervalues
|
||||||
|
|
||||||
category_icon_map = {
|
category_icon_map = {
|
||||||
|
@ -5,8 +5,9 @@ import sys
|
|||||||
from functools import partial
|
from functools import partial
|
||||||
|
|
||||||
from calibre import prints
|
from calibre import prints
|
||||||
from calibre.constants import preferred_encoding, iswindows
|
from calibre.constants import iswindows, preferred_encoding
|
||||||
from calibre.utils.config import OptionParser
|
from calibre.utils.config import OptionParser
|
||||||
|
from calibre.utils.localization import ngettext
|
||||||
from polyglot.builtins import iteritems
|
from polyglot.builtins import iteritems
|
||||||
|
|
||||||
|
|
||||||
|
@ -24,6 +24,7 @@ from calibre.srv.utils import Offsets, get_library_data, http_date
|
|||||||
from calibre.utils.config import prefs
|
from calibre.utils.config import prefs
|
||||||
from calibre.utils.date import as_utc, is_date_undefined, timestampfromdt
|
from calibre.utils.date import as_utc, is_date_undefined, timestampfromdt
|
||||||
from calibre.utils.icu import sort_key
|
from calibre.utils.icu import sort_key
|
||||||
|
from calibre.utils.localization import ngettext
|
||||||
from calibre.utils.search_query_parser import ParseException
|
from calibre.utils.search_query_parser import ParseException
|
||||||
from calibre.utils.xml_parse import safe_xml_fromstring
|
from calibre.utils.xml_parse import safe_xml_fromstring
|
||||||
from polyglot.binary import as_hex_unicode, from_hex_unicode
|
from polyglot.binary import as_hex_unicode, from_hex_unicode
|
||||||
|
Loading…
x
Reference in New Issue
Block a user