mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
Get rid of global I()
This commit is contained in:
parent
0cf25eb724
commit
45244e2a3f
@ -5,10 +5,18 @@ __license__ = 'GPL v3'
|
|||||||
__copyright__ = '2011, Kovid Goyal <kovid@kovidgoyal.net>'
|
__copyright__ = '2011, Kovid Goyal <kovid@kovidgoyal.net>'
|
||||||
__docformat__ = 'restructuredtext en'
|
__docformat__ = 'restructuredtext en'
|
||||||
|
|
||||||
import unittest, os, shutil, tempfile, atexit, gc, time
|
import atexit
|
||||||
|
import gc
|
||||||
|
import os
|
||||||
|
import shutil
|
||||||
|
import tempfile
|
||||||
|
import time
|
||||||
|
import unittest
|
||||||
from functools import partial
|
from functools import partial
|
||||||
from io import BytesIO
|
from io import BytesIO
|
||||||
|
|
||||||
|
from calibre.utils.resources import get_image_path as I
|
||||||
|
|
||||||
rmtree = partial(shutil.rmtree, ignore_errors=True)
|
rmtree = partial(shutil.rmtree, ignore_errors=True)
|
||||||
|
|
||||||
IMG = b'\xff\xd8\xff\xe0\x00\x10JFIF\x00\x01\x01\x01\x00`\x00`\x00\x00\xff\xe1\x00\x16Exif\x00\x00II*\x00\x08\x00\x00\x00\x00\x00\x00\x00\x00\x00\xff\xdb\x00C\x00\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\xff\xdb\x00C\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\xff\xc0\x00\x11\x08\x00\x01\x00\x01\x03\x01"\x00\x02\x11\x01\x03\x11\x01\xff\xc4\x00\x15\x00\x01\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\n\xff\xc4\x00\x14\x10\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\xff\xc4\x00\x14\x01\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\xff\xc4\x00\x14\x11\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\xff\xda\x00\x0c\x03\x01\x00\x02\x11\x03\x11\x00?\x00\xbf\x80\x01\xff\xd9' # noqa {{{ }}}
|
IMG = b'\xff\xd8\xff\xe0\x00\x10JFIF\x00\x01\x01\x01\x00`\x00`\x00\x00\xff\xe1\x00\x16Exif\x00\x00II*\x00\x08\x00\x00\x00\x00\x00\x00\x00\x00\x00\xff\xdb\x00C\x00\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\xff\xdb\x00C\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\xff\xc0\x00\x11\x08\x00\x01\x00\x01\x03\x01"\x00\x02\x11\x01\x03\x11\x01\xff\xc4\x00\x15\x00\x01\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\n\xff\xc4\x00\x14\x10\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\xff\xc4\x00\x14\x01\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\xff\xc4\x00\x14\x11\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\xff\xda\x00\x0c\x03\x01\x00\x02\x11\x03\x11\x00?\x00\xbf\x80\x01\xff\xd9' # noqa {{{ }}}
|
||||||
|
@ -7,6 +7,7 @@ import os
|
|||||||
|
|
||||||
from calibre import fsync
|
from calibre import fsync
|
||||||
from calibre.devices.usbms.driver import USBMS
|
from calibre.devices.usbms.driver import USBMS
|
||||||
|
from calibre.utils.resources import get_image_path as I
|
||||||
from polyglot.builtins import string_or_bytes
|
from polyglot.builtins import string_or_bytes
|
||||||
|
|
||||||
HTC_BCDS = [0x100, 0x0222, 0x0224, 0x0226, 0x227, 0x228, 0x229, 0x0231, 0x9999]
|
HTC_BCDS = [0x100, 0x0222, 0x0224, 0x0226, 0x227, 0x228, 0x229, 0x0231, 0x9999]
|
||||||
|
@ -6,11 +6,13 @@ __docformat__ = 'restructuredtext en'
|
|||||||
Device driver for Barns and Nobel's Nook
|
Device driver for Barns and Nobel's Nook
|
||||||
'''
|
'''
|
||||||
|
|
||||||
import io, os
|
import io
|
||||||
|
import os
|
||||||
|
|
||||||
from calibre import fsync, prints
|
from calibre import fsync, prints
|
||||||
from calibre.constants import DEBUG
|
from calibre.constants import DEBUG
|
||||||
from calibre.devices.usbms.driver import USBMS
|
from calibre.devices.usbms.driver import USBMS
|
||||||
|
from calibre.utils.resources import get_image_path as I
|
||||||
|
|
||||||
|
|
||||||
class NOOK(USBMS):
|
class NOOK(USBMS):
|
||||||
|
@ -4,27 +4,30 @@
|
|||||||
__license__ = 'GPL v3'
|
__license__ = 'GPL v3'
|
||||||
__copyright__ = '2014, Kovid Goyal <kovid at kovidgoyal.net>'
|
__copyright__ = '2014, Kovid Goyal <kovid at kovidgoyal.net>'
|
||||||
|
|
||||||
import re, random, unicodedata, numbers
|
import numbers
|
||||||
|
import random
|
||||||
|
import re
|
||||||
|
import unicodedata
|
||||||
from collections import namedtuple
|
from collections import namedtuple
|
||||||
from contextlib import contextmanager
|
from contextlib import contextmanager
|
||||||
from math import ceil, sqrt, cos, sin, atan2
|
|
||||||
from polyglot.builtins import iteritems, itervalues, string_or_bytes
|
|
||||||
from itertools import chain
|
from itertools import chain
|
||||||
|
from math import atan2, ceil, cos, sin, sqrt
|
||||||
from qt.core import (
|
from qt.core import (
|
||||||
QImage, Qt, QFont, QPainter, QPointF, QTextLayout, QTextOption,
|
QBrush, QColor, QFont, QFontMetrics, QImage, QLinearGradient, QPainter,
|
||||||
QFontMetrics, QTextCharFormat, QColor, QRect, QBrush, QLinearGradient,
|
QPainterPath, QPen, QPointF, QRadialGradient, QRect, QRectF, Qt, QTextCharFormat,
|
||||||
QPainterPath, QPen, QRectF, QTransform, QRadialGradient
|
QTextLayout, QTextOption, QTransform,
|
||||||
)
|
)
|
||||||
|
|
||||||
from calibre import force_unicode, fit_image
|
from calibre import fit_image, force_unicode
|
||||||
from calibre.constants import __appname__, __version__
|
from calibre.constants import __appname__, __version__
|
||||||
from calibre.ebooks.metadata import fmt_sidx
|
from calibre.ebooks.metadata import fmt_sidx
|
||||||
from calibre.ebooks.metadata.book.base import Metadata
|
from calibre.ebooks.metadata.book.base import Metadata
|
||||||
from calibre.ebooks.metadata.book.formatter import SafeFormat
|
from calibre.ebooks.metadata.book.formatter import SafeFormat
|
||||||
from calibre.gui2 import ensure_app, config, load_builtin_fonts, pixmap_to_data
|
from calibre.gui2 import config, ensure_app, load_builtin_fonts, pixmap_to_data
|
||||||
from calibre.utils.cleantext import clean_ascii_chars, clean_xml_chars
|
from calibre.utils.cleantext import clean_ascii_chars, clean_xml_chars
|
||||||
from calibre.utils.config import JSONConfig
|
from calibre.utils.config import JSONConfig
|
||||||
|
from calibre.utils.resources import get_image_path as I
|
||||||
|
from polyglot.builtins import iteritems, itervalues, string_or_bytes
|
||||||
|
|
||||||
# Default settings {{{
|
# Default settings {{{
|
||||||
cprefs = JSONConfig('cover_generation')
|
cprefs = JSONConfig('cover_generation')
|
||||||
@ -726,7 +729,8 @@ def generate_masthead(title, output_path=None, width=600, height=60, as_qimage=F
|
|||||||
|
|
||||||
|
|
||||||
def test(scale=0.25):
|
def test(scale=0.25):
|
||||||
from qt.core import QLabel, QPixmap, QMainWindow, QWidget, QScrollArea, QGridLayout
|
from qt.core import QGridLayout, QLabel, QMainWindow, QPixmap, QScrollArea, QWidget
|
||||||
|
|
||||||
from calibre.gui2 import Application
|
from calibre.gui2 import Application
|
||||||
app = Application([])
|
app = Application([])
|
||||||
mi = Metadata('Unknown', ['Kovid Goyal', 'John & Doe', 'Author'])
|
mi = Metadata('Unknown', ['Kovid Goyal', 'John & Doe', 'Author'])
|
||||||
|
@ -8,15 +8,15 @@ import os
|
|||||||
import posixpath
|
import posixpath
|
||||||
from collections import namedtuple
|
from collections import namedtuple
|
||||||
from functools import partial
|
from functools import partial
|
||||||
from polyglot.builtins import iteritems, itervalues
|
|
||||||
|
|
||||||
from lxml import etree
|
from lxml import etree
|
||||||
|
|
||||||
from calibre import fit_image
|
from calibre import fit_image
|
||||||
from calibre.ebooks.oeb.base import urlunquote, urlquote
|
|
||||||
from calibre.ebooks.docx.images import pt_to_emu
|
from calibre.ebooks.docx.images import pt_to_emu
|
||||||
|
from calibre.ebooks.oeb.base import urlquote, urlunquote
|
||||||
from calibre.utils.filenames import ascii_filename
|
from calibre.utils.filenames import ascii_filename
|
||||||
from calibre.utils.imghdr import identify
|
from calibre.utils.imghdr import identify
|
||||||
|
from calibre.utils.resources import get_image_path as I
|
||||||
|
from polyglot.builtins import iteritems, itervalues
|
||||||
|
|
||||||
Image = namedtuple('Image', 'rid fname width height fmt item')
|
Image = namedtuple('Image', 'rid fname width height fmt item')
|
||||||
|
|
||||||
|
@ -12,7 +12,7 @@ import calibre.ebooks.oeb.polish.container as pc
|
|||||||
from calibre import CurrentDir
|
from calibre import CurrentDir
|
||||||
from calibre.ptempfile import PersistentTemporaryDirectory, TemporaryDirectory
|
from calibre.ptempfile import PersistentTemporaryDirectory, TemporaryDirectory
|
||||||
from calibre.utils.logging import DevNull
|
from calibre.utils.logging import DevNull
|
||||||
from calibre.utils.resources import get_path as P
|
from calibre.utils.resources import get_image_path as I, get_path as P
|
||||||
from polyglot.builtins import iteritems
|
from polyglot.builtins import iteritems
|
||||||
|
|
||||||
|
|
||||||
|
@ -41,7 +41,7 @@ from calibre.utils.date import UNDEFINED_DATE
|
|||||||
from calibre.utils.file_type_icons import EXT_MAP
|
from calibre.utils.file_type_icons import EXT_MAP
|
||||||
from calibre.utils.img import set_image_allocation_limit
|
from calibre.utils.img import set_image_allocation_limit
|
||||||
from calibre.utils.localization import get_lang
|
from calibre.utils.localization import get_lang
|
||||||
from calibre.utils.resources import get_path as P, user_dir
|
from calibre.utils.resources import get_image_path as I, get_path as P, user_dir
|
||||||
from polyglot import queue
|
from polyglot import queue
|
||||||
from polyglot.builtins import iteritems, string_or_bytes
|
from polyglot.builtins import iteritems, string_or_bytes
|
||||||
|
|
||||||
|
@ -14,7 +14,7 @@ from functools import partial
|
|||||||
from itertools import repeat
|
from itertools import repeat
|
||||||
from qt.core import (
|
from qt.core import (
|
||||||
QDialog, QDialogButtonBox, QGridLayout, QIcon, QLabel, QLineEdit, QListWidget,
|
QDialog, QDialogButtonBox, QGridLayout, QIcon, QLabel, QLineEdit, QListWidget,
|
||||||
QListWidgetItem, QPushButton, Qt
|
QListWidgetItem, QPushButton, Qt,
|
||||||
)
|
)
|
||||||
from threading import Thread
|
from threading import Thread
|
||||||
|
|
||||||
@ -26,8 +26,9 @@ from calibre.gui2.threaded_jobs import ThreadedJob
|
|||||||
from calibre.library.save_to_disk import get_components
|
from calibre.library.save_to_disk import get_components
|
||||||
from calibre.utils.config import prefs, tweaks
|
from calibre.utils.config import prefs, tweaks
|
||||||
from calibre.utils.icu import primary_sort_key
|
from calibre.utils.icu import primary_sort_key
|
||||||
|
from calibre.utils.resources import get_image_path as I
|
||||||
from calibre.utils.smtp import (
|
from calibre.utils.smtp import (
|
||||||
compose_mail, config as email_config, extract_email_address, sendmail
|
compose_mail, config as email_config, extract_email_address, sendmail,
|
||||||
)
|
)
|
||||||
from polyglot.binary import from_hex_unicode
|
from polyglot.binary import from_hex_unicode
|
||||||
from polyglot.builtins import iteritems, itervalues
|
from polyglot.builtins import iteritems, itervalues
|
||||||
@ -439,8 +440,8 @@ class EmailMixin: # {{{
|
|||||||
_('in the %s format.') %
|
_('in the %s format.') %
|
||||||
os.path.splitext(f)[1][1:].upper())
|
os.path.splitext(f)[1][1:].upper())
|
||||||
if mi.comments and gprefs['add_comments_to_email']:
|
if mi.comments and gprefs['add_comments_to_email']:
|
||||||
from calibre.utils.html2text import html2text
|
|
||||||
from calibre.ebooks.metadata import fmt_sidx
|
from calibre.ebooks.metadata import fmt_sidx
|
||||||
|
from calibre.utils.html2text import html2text
|
||||||
if mi.series:
|
if mi.series:
|
||||||
sidx=fmt_sidx(1.0 if mi.series_index is None else mi.series_index, use_roman=config['use_roman_numerals_for_series_number'])
|
sidx=fmt_sidx(1.0 if mi.series_index is None else mi.series_index, use_roman=config['use_roman_numerals_for_series_number'])
|
||||||
texts[-1] += '\n\n' + _('{series_index} of {series}').format(series_index=sidx, series=mi.series)
|
texts[-1] += '\n\n' + _('{series_index} of {series}').format(series_index=sidx, series=mi.series)
|
||||||
|
@ -42,7 +42,7 @@ from calibre.utils.filenames import ascii_filename, atomic_rename
|
|||||||
from calibre.utils.https import HTTPError, get_https_resource_securely
|
from calibre.utils.https import HTTPError, get_https_resource_securely
|
||||||
from calibre.utils.icu import numeric_sort_key as sort_key
|
from calibre.utils.icu import numeric_sort_key as sort_key
|
||||||
from calibre.utils.img import Canvas, image_from_data, optimize_jpeg, optimize_png
|
from calibre.utils.img import Canvas, image_from_data, optimize_jpeg, optimize_png
|
||||||
from calibre.utils.resources import get_path as P
|
from calibre.utils.resources import get_image_path as I, get_path as P
|
||||||
from calibre.utils.zipfile import ZIP_STORED, ZipFile
|
from calibre.utils.zipfile import ZIP_STORED, ZipFile
|
||||||
from polyglot import http_client
|
from polyglot import http_client
|
||||||
from polyglot.builtins import as_bytes, iteritems, reraise
|
from polyglot.builtins import as_bytes, iteritems, reraise
|
||||||
|
@ -2,23 +2,22 @@
|
|||||||
# License: GPLv3 Copyright: 2015, Kovid Goyal <kovid at kovidgoyal.net>
|
# License: GPLv3 Copyright: 2015, Kovid Goyal <kovid at kovidgoyal.net>
|
||||||
|
|
||||||
|
|
||||||
|
import apsw
|
||||||
import os
|
import os
|
||||||
import re
|
import re
|
||||||
import sys
|
import sys
|
||||||
import time
|
import time
|
||||||
import traceback
|
import traceback
|
||||||
|
|
||||||
import apsw
|
|
||||||
from qt.core import QCoreApplication, QIcon, QObject, QTimer
|
from qt.core import QCoreApplication, QIcon, QObject, QTimer
|
||||||
|
|
||||||
from calibre import force_unicode, prints
|
from calibre import force_unicode, prints
|
||||||
from calibre.constants import (
|
from calibre.constants import (
|
||||||
DEBUG, MAIN_APP_UID, __appname__, filesystem_encoding, get_portable_base,
|
DEBUG, MAIN_APP_UID, __appname__, filesystem_encoding, get_portable_base, islinux,
|
||||||
islinux, ismacos, iswindows
|
ismacos, iswindows,
|
||||||
)
|
)
|
||||||
from calibre.gui2 import (
|
from calibre.gui2 import (
|
||||||
Application, choose_dir, error_dialog, gprefs, initialize_file_icon_provider,
|
Application, choose_dir, error_dialog, gprefs, initialize_file_icon_provider,
|
||||||
question_dialog, setup_gui_option_parser
|
question_dialog, setup_gui_option_parser,
|
||||||
)
|
)
|
||||||
from calibre.gui2.listener import send_message_in_process
|
from calibre.gui2.listener import send_message_in_process
|
||||||
from calibre.gui2.main_window import option_parser as _option_parser
|
from calibre.gui2.main_window import option_parser as _option_parser
|
||||||
@ -26,6 +25,7 @@ from calibre.gui2.splash_screen import SplashScreen
|
|||||||
from calibre.utils.config import dynamic, prefs
|
from calibre.utils.config import dynamic, prefs
|
||||||
from calibre.utils.lock import SingleInstance
|
from calibre.utils.lock import SingleInstance
|
||||||
from calibre.utils.monotonic import monotonic
|
from calibre.utils.monotonic import monotonic
|
||||||
|
from calibre.utils.resources import get_image_path as I
|
||||||
from polyglot.builtins import as_bytes, environ_item
|
from polyglot.builtins import as_bytes, environ_item
|
||||||
|
|
||||||
after_quit_actions = {'debug_on_restart': False, 'restart_after_quit': False, 'no_plugins_on_restart': False}
|
after_quit_actions = {'debug_on_restart': False, 'restart_after_quit': False, 'no_plugins_on_restart': False}
|
||||||
@ -197,6 +197,7 @@ def repair_library(library_path):
|
|||||||
|
|
||||||
def windows_repair(library_path=None):
|
def windows_repair(library_path=None):
|
||||||
import subprocess
|
import subprocess
|
||||||
|
|
||||||
from calibre.utils.serialize import json_dumps, json_loads
|
from calibre.utils.serialize import json_dumps, json_loads
|
||||||
from polyglot.binary import as_hex_unicode, from_hex_bytes
|
from polyglot.binary import as_hex_unicode, from_hex_bytes
|
||||||
if library_path:
|
if library_path:
|
||||||
@ -380,8 +381,10 @@ class GuiRunner(QObject):
|
|||||||
|
|
||||||
|
|
||||||
def run_in_debug_mode():
|
def run_in_debug_mode():
|
||||||
|
import subprocess
|
||||||
|
import tempfile
|
||||||
|
|
||||||
from calibre.debug import run_calibre_debug
|
from calibre.debug import run_calibre_debug
|
||||||
import tempfile, subprocess
|
|
||||||
fd, logpath = tempfile.mkstemp('.txt')
|
fd, logpath = tempfile.mkstemp('.txt')
|
||||||
os.close(fd)
|
os.close(fd)
|
||||||
run_calibre_debug(
|
run_calibre_debug(
|
||||||
|
@ -8,36 +8,38 @@ __docformat__ = 'restructuredtext en'
|
|||||||
DEBUG_DIALOG = False
|
DEBUG_DIALOG = False
|
||||||
|
|
||||||
# Imports {{{
|
# Imports {{{
|
||||||
import os, time
|
import os
|
||||||
from threading import Thread, Event
|
import time
|
||||||
from operator import attrgetter
|
|
||||||
from io import BytesIO
|
from io import BytesIO
|
||||||
|
from operator import attrgetter
|
||||||
from qt.core import (
|
from qt.core import (
|
||||||
QStyledItemDelegate, QTextDocument, QRectF, QIcon, Qt, QApplication,
|
QAbstractItemView, QAbstractListModel, QAbstractTableModel, QApplication, QCursor,
|
||||||
QDialog, QVBoxLayout, QLabel, QDialogButtonBox, QStyle, QStackedWidget,
|
QDialog, QDialogButtonBox, QGridLayout, QHBoxLayout, QIcon, QItemSelectionModel,
|
||||||
QWidget, QTableView, QGridLayout, QPalette, QTimer, pyqtSignal,
|
QLabel, QListView, QMenu, QModelIndex, QPalette, QPixmap, QPushButton, QRect,
|
||||||
QAbstractTableModel, QSize, QListView, QPixmap, QModelIndex, QSplitter,
|
QRectF, QSize, QSizePolicy, QSplitter, QStackedWidget, QStringListModel, QStyle,
|
||||||
QAbstractListModel, QRect, QTextBrowser, QStringListModel, QMenu, QItemSelectionModel,
|
QStyledItemDelegate, Qt, QTableView, QTextBrowser, QTextDocument, QTimer,
|
||||||
QCursor, QHBoxLayout, QPushButton, QSizePolicy, QAbstractItemView)
|
QVBoxLayout, QWidget, pyqtSignal,
|
||||||
|
)
|
||||||
|
from threading import Event, Thread
|
||||||
|
|
||||||
|
from calibre import force_unicode
|
||||||
from calibre.customize.ui import metadata_plugins
|
from calibre.customize.ui import metadata_plugins
|
||||||
from calibre.ebooks.metadata import authors_to_string, rating_to_stars
|
from calibre.ebooks.metadata import authors_to_string, rating_to_stars
|
||||||
from calibre.utils.logging import GUILog as Log
|
|
||||||
from calibre.ebooks.metadata.sources.identify import urls_from_identifiers
|
|
||||||
from calibre.ebooks.metadata.book.base import Metadata
|
from calibre.ebooks.metadata.book.base import Metadata
|
||||||
from calibre.ebooks.metadata.opf2 import OPF
|
from calibre.ebooks.metadata.opf2 import OPF
|
||||||
from calibre.gui2 import error_dialog, rating_font, gprefs
|
from calibre.ebooks.metadata.sources.identify import urls_from_identifiers
|
||||||
|
from calibre.gui2 import error_dialog, gprefs, rating_font
|
||||||
from calibre.gui2.progress_indicator import SpinAnimator
|
from calibre.gui2.progress_indicator import SpinAnimator
|
||||||
from calibre.gui2.widgets2 import HTMLDisplay
|
from calibre.gui2.widgets2 import HTMLDisplay
|
||||||
from calibre.utils.date import (utcnow, fromordinal, format_date,
|
|
||||||
UNDEFINED_DATE, as_utc)
|
|
||||||
from calibre.library.comments import comments_to_html
|
from calibre.library.comments import comments_to_html
|
||||||
from calibre import force_unicode
|
|
||||||
from calibre.utils.ipc.simple_worker import fork_job, WorkerError
|
|
||||||
from calibre.ptempfile import TemporaryDirectory
|
from calibre.ptempfile import TemporaryDirectory
|
||||||
|
from calibre.utils.date import UNDEFINED_DATE, as_utc, format_date, fromordinal, utcnow
|
||||||
|
from calibre.utils.ipc.simple_worker import WorkerError, fork_job
|
||||||
|
from calibre.utils.logging import GUILog as Log
|
||||||
|
from calibre.utils.resources import get_image_path as I
|
||||||
from polyglot.builtins import iteritems, itervalues
|
from polyglot.builtins import iteritems, itervalues
|
||||||
from polyglot.queue import Queue, Empty
|
from polyglot.queue import Empty, Queue
|
||||||
|
|
||||||
# }}}
|
# }}}
|
||||||
|
|
||||||
|
|
||||||
|
@ -11,6 +11,7 @@ from contextlib import suppress
|
|||||||
from functools import lru_cache
|
from functools import lru_cache
|
||||||
|
|
||||||
from calibre.constants import DEBUG, __appname__, get_osx_version, islinux, ismacos
|
from calibre.constants import DEBUG, __appname__, get_osx_version, islinux, ismacos
|
||||||
|
from calibre.utils.resources import get_image_path as I
|
||||||
|
|
||||||
|
|
||||||
class Notifier:
|
class Notifier:
|
||||||
|
@ -9,22 +9,23 @@ import uuid
|
|||||||
from contextlib import suppress
|
from contextlib import suppress
|
||||||
from functools import partial
|
from functools import partial
|
||||||
from qt.core import (
|
from qt.core import (
|
||||||
QAction, QBuffer, QByteArray, QIcon, QInputDialog, QKeySequence, QLabel,
|
QAction, QBuffer, QByteArray, QDialogButtonBox, QIcon, QInputDialog, QIODevice,
|
||||||
QListWidget, QListWidgetItem, QPixmap, QSize, QStackedLayout, Qt, QVBoxLayout,
|
QKeySequence, QLabel, QListWidget, QListWidgetItem, QPixmap, QSize, QStackedLayout,
|
||||||
QWidget, pyqtSignal, QIODevice, QDialogButtonBox
|
Qt, QVBoxLayout, QWidget, pyqtSignal,
|
||||||
)
|
)
|
||||||
from threading import Thread
|
from threading import Thread
|
||||||
|
|
||||||
from calibre import as_unicode
|
from calibre import as_unicode
|
||||||
from calibre.constants import ismacos, iswindows
|
from calibre.constants import ismacos, iswindows
|
||||||
from calibre.gui2 import (
|
from calibre.gui2 import (
|
||||||
Application, choose_files, choose_images, choose_osx_app, elided_text,
|
Application, choose_files, choose_images, choose_osx_app, elided_text, error_dialog,
|
||||||
error_dialog, sanitize_env_vars
|
sanitize_env_vars,
|
||||||
)
|
)
|
||||||
from calibre.gui2.progress_indicator import ProgressIndicator
|
from calibre.gui2.progress_indicator import ProgressIndicator
|
||||||
from calibre.gui2.widgets2 import Dialog
|
from calibre.gui2.widgets2 import Dialog
|
||||||
from calibre.utils.config import JSONConfig
|
from calibre.utils.config import JSONConfig
|
||||||
from calibre.utils.icu import numeric_sort_key as sort_key
|
from calibre.utils.icu import numeric_sort_key as sort_key
|
||||||
|
from calibre.utils.resources import get_image_path as I
|
||||||
from polyglot.builtins import iteritems, string_or_bytes
|
from polyglot.builtins import iteritems, string_or_bytes
|
||||||
|
|
||||||
ENTRY_ROLE = Qt.ItemDataRole.UserRole
|
ENTRY_ROLE = Qt.ItemDataRole.UserRole
|
||||||
@ -80,11 +81,9 @@ if iswindows:
|
|||||||
import subprocess
|
import subprocess
|
||||||
|
|
||||||
from calibre.utils.open_with.windows import (
|
from calibre.utils.open_with.windows import (
|
||||||
load_icon_for_cmdline, load_icon_resource
|
load_icon_for_cmdline, load_icon_resource,
|
||||||
)
|
|
||||||
from calibre.utils.winreg.default_programs import (
|
|
||||||
find_programs, friendly_app_name
|
|
||||||
)
|
)
|
||||||
|
from calibre.utils.winreg.default_programs import find_programs, friendly_app_name
|
||||||
from calibre_extensions import winutil
|
from calibre_extensions import winutil
|
||||||
oprefs = JSONConfig('windows_open_with')
|
oprefs = JSONConfig('windows_open_with')
|
||||||
|
|
||||||
@ -176,7 +175,7 @@ elif ismacos:
|
|||||||
# macOS {{{
|
# macOS {{{
|
||||||
oprefs = JSONConfig('osx_open_with')
|
oprefs = JSONConfig('osx_open_with')
|
||||||
from calibre.utils.open_with.osx import (
|
from calibre.utils.open_with.osx import (
|
||||||
entry_to_cmdline, find_programs, get_bundle_data, get_icon
|
entry_to_cmdline, find_programs, get_bundle_data, get_icon,
|
||||||
)
|
)
|
||||||
|
|
||||||
def entry_sort_key(entry):
|
def entry_sort_key(entry):
|
||||||
@ -226,7 +225,7 @@ else:
|
|||||||
# XDG {{{
|
# XDG {{{
|
||||||
oprefs = JSONConfig('xdg_open_with')
|
oprefs = JSONConfig('xdg_open_with')
|
||||||
from calibre.utils.open_with.linux import (
|
from calibre.utils.open_with.linux import (
|
||||||
entry_sort_key, entry_to_cmdline, find_programs
|
entry_sort_key, entry_to_cmdline, find_programs,
|
||||||
)
|
)
|
||||||
|
|
||||||
def change_name_in_entry(entry, newname):
|
def change_name_in_entry(entry, newname):
|
||||||
|
@ -4,15 +4,19 @@
|
|||||||
__license__ = 'GPL v3'
|
__license__ = 'GPL v3'
|
||||||
__copyright__ = '2013, Kovid Goyal <kovid at kovidgoyal.net>'
|
__copyright__ = '2013, Kovid Goyal <kovid at kovidgoyal.net>'
|
||||||
|
|
||||||
import glob, os, shutil
|
import glob
|
||||||
|
import os
|
||||||
|
import shutil
|
||||||
from functools import partial
|
from functools import partial
|
||||||
from qt.core import (
|
from qt.core import (
|
||||||
QDialog, QVBoxLayout, QListWidget, QListWidgetItem, Qt, QIcon,
|
QAbstractItemView, QApplication, QDialog, QDialogButtonBox, QIcon, QLabel,
|
||||||
QApplication, QSize, QDialogButtonBox, QTimer, QLabel, QAbstractItemView, QListView)
|
QListView, QListWidget, QListWidgetItem, QSize, Qt, QTimer, QVBoxLayout,
|
||||||
|
)
|
||||||
|
|
||||||
from calibre.constants import config_dir
|
from calibre.constants import config_dir
|
||||||
from calibre.gui2 import choose_files, error_dialog
|
from calibre.gui2 import choose_files, error_dialog
|
||||||
from calibre.utils.icu import sort_key
|
from calibre.utils.icu import sort_key
|
||||||
|
from calibre.utils.resources import get_image_path as I
|
||||||
|
|
||||||
|
|
||||||
def texture_dir():
|
def texture_dir():
|
||||||
|
@ -3,12 +3,13 @@
|
|||||||
|
|
||||||
|
|
||||||
from qt.core import (
|
from qt.core import (
|
||||||
QApplication, QBrush, QColor, QFont, QFontMetrics, QPen, QPixmap, QSplashScreen,
|
QApplication, QBrush, QColor, QFont, QFontMetrics, QPainter, QPen, QPixmap,
|
||||||
Qt, QPainter
|
QSplashScreen, Qt,
|
||||||
)
|
)
|
||||||
|
|
||||||
from calibre.constants import __appname__, numeric_version
|
from calibre.constants import __appname__, numeric_version
|
||||||
from calibre.utils.monotonic import monotonic
|
from calibre.utils.monotonic import monotonic
|
||||||
|
from calibre.utils.resources import get_image_path as I
|
||||||
|
|
||||||
|
|
||||||
class SplashScreen(QSplashScreen):
|
class SplashScreen(QSplashScreen):
|
||||||
|
@ -59,7 +59,7 @@ from calibre.library import current_library_name
|
|||||||
from calibre.srv.library_broker import GuiLibraryBroker, db_matches
|
from calibre.srv.library_broker import GuiLibraryBroker, db_matches
|
||||||
from calibre.utils.config import dynamic, prefs
|
from calibre.utils.config import dynamic, prefs
|
||||||
from calibre.utils.ipc.pool import Pool
|
from calibre.utils.ipc.pool import Pool
|
||||||
from calibre.utils.resources import get_path as P
|
from calibre.utils.resources import get_image_path as I, get_path as P
|
||||||
from polyglot.builtins import string_or_bytes
|
from polyglot.builtins import string_or_bytes
|
||||||
from polyglot.queue import Empty, Queue
|
from polyglot.queue import Empty, Queue
|
||||||
|
|
||||||
|
@ -1,7 +1,6 @@
|
|||||||
#!/usr/bin/env python
|
#!/usr/bin/env python
|
||||||
# License: GPLv3 Copyright: 2010, Greg Riker
|
# License: GPLv3 Copyright: 2010, Greg Riker
|
||||||
|
|
||||||
|
|
||||||
import datetime
|
import datetime
|
||||||
import os
|
import os
|
||||||
import platform
|
import platform
|
||||||
@ -38,7 +37,7 @@ 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
|
from calibre.utils.icu import capitalize, collation_order, sort_key
|
||||||
from calibre.utils.localization import get_lang, lang_as_iso639_1
|
from calibre.utils.localization import get_lang, lang_as_iso639_1
|
||||||
from calibre.utils.resources import 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
|
||||||
from polyglot.builtins import iteritems
|
from polyglot.builtins import iteritems
|
||||||
|
@ -15,7 +15,7 @@ from calibre import CurrentDir, __appname__, guess_type, prints
|
|||||||
from calibre.constants import isbsd, islinux
|
from calibre.constants import isbsd, islinux
|
||||||
from calibre.customize.ui import all_input_formats
|
from calibre.customize.ui import all_input_formats
|
||||||
from calibre.ptempfile import TemporaryDirectory
|
from calibre.ptempfile import TemporaryDirectory
|
||||||
from calibre.utils.resources import get_path as P
|
from calibre.utils.resources import get_image_path as I, get_path as P
|
||||||
from polyglot.builtins import iteritems
|
from polyglot.builtins import iteritems
|
||||||
|
|
||||||
entry_points = {
|
entry_points = {
|
||||||
|
@ -28,7 +28,7 @@ from calibre.utils.config_base import tweaks
|
|||||||
from calibre.utils.date import timestampfromdt
|
from calibre.utils.date import timestampfromdt
|
||||||
from calibre.utils.filenames import ascii_filename, atomic_rename
|
from calibre.utils.filenames import ascii_filename, atomic_rename
|
||||||
from calibre.utils.img import image_from_data, scale_image
|
from calibre.utils.img import image_from_data, scale_image
|
||||||
from calibre.utils.resources import get_path as P
|
from calibre.utils.resources import get_image_path as I, get_path as P
|
||||||
from calibre.utils.shared_file import share_open
|
from calibre.utils.shared_file import share_open
|
||||||
from polyglot.binary import as_hex_unicode
|
from polyglot.binary import as_hex_unicode
|
||||||
from polyglot.urllib import quote
|
from polyglot.urllib import quote
|
||||||
|
@ -17,7 +17,7 @@ from io import BytesIO
|
|||||||
from threading import Thread
|
from threading import Thread
|
||||||
|
|
||||||
from calibre.srv.utils import ServerLog
|
from calibre.srv.utils import ServerLog
|
||||||
from calibre.utils.resources import get_path as P
|
from calibre.utils.resources import get_image_path as I, get_path as P
|
||||||
from polyglot import http_client
|
from polyglot import http_client
|
||||||
|
|
||||||
rmtree = partial(shutil.rmtree, ignore_errors=True)
|
rmtree = partial(shutil.rmtree, ignore_errors=True)
|
||||||
|
@ -14,7 +14,7 @@ from calibre.ebooks.metadata.epub import get_metadata
|
|||||||
from calibre.ebooks.metadata.opf2 import OPF
|
from calibre.ebooks.metadata.opf2 import OPF
|
||||||
from calibre.srv.tests.base import LibraryBaseTest
|
from calibre.srv.tests.base import LibraryBaseTest
|
||||||
from calibre.utils.imghdr import identify
|
from calibre.utils.imghdr import identify
|
||||||
from calibre.utils.resources import get_path as P
|
from calibre.utils.resources import get_image_path as I, get_path as P
|
||||||
from calibre.utils.shared_file import share_open
|
from calibre.utils.shared_file import share_open
|
||||||
from polyglot import http_client
|
from polyglot import http_client
|
||||||
from polyglot.binary import from_hex_unicode
|
from polyglot.binary import from_hex_unicode
|
||||||
|
@ -18,7 +18,7 @@ import time
|
|||||||
import unittest
|
import unittest
|
||||||
|
|
||||||
from calibre.constants import islinux, ismacos, iswindows, plugins_loc
|
from calibre.constants import islinux, ismacos, iswindows, plugins_loc
|
||||||
from calibre.utils.resources import get_path as P
|
from calibre.utils.resources import get_image_path as I, get_path as P
|
||||||
from polyglot.builtins import iteritems
|
from polyglot.builtins import iteritems
|
||||||
|
|
||||||
is_ci = os.environ.get('CI', '').lower() == 'true'
|
is_ci = os.environ.get('CI', '').lower() == 'true'
|
||||||
|
@ -11,8 +11,8 @@ import tempfile
|
|||||||
from contextlib import suppress
|
from contextlib import suppress
|
||||||
from io import BytesIO
|
from io import BytesIO
|
||||||
from qt.core import (
|
from qt.core import (
|
||||||
QBuffer, QByteArray, QColor, QImage, QImageReader, QImageWriter, QIODevice,
|
QBuffer, QByteArray, QColor, QImage, QImageReader, QImageWriter, QIODevice, QPixmap,
|
||||||
QPixmap, Qt, QTransform
|
Qt, QTransform,
|
||||||
)
|
)
|
||||||
from threading import Thread
|
from threading import Thread
|
||||||
|
|
||||||
@ -22,6 +22,7 @@ from calibre.ptempfile import TemporaryDirectory
|
|||||||
from calibre.utils.config_base import tweaks
|
from calibre.utils.config_base import tweaks
|
||||||
from calibre.utils.filenames import atomic_rename
|
from calibre.utils.filenames import atomic_rename
|
||||||
from calibre.utils.imghdr import what
|
from calibre.utils.imghdr import what
|
||||||
|
from calibre.utils.resources import get_image_path as I
|
||||||
from calibre_extensions import imageops
|
from calibre_extensions import imageops
|
||||||
from polyglot.builtins import string_or_bytes
|
from polyglot.builtins import string_or_bytes
|
||||||
|
|
||||||
@ -110,7 +111,7 @@ def gif_data_to_png_data(data, discard_animation=False):
|
|||||||
def set_image_allocation_limit(size_in_mb=1024):
|
def set_image_allocation_limit(size_in_mb=1024):
|
||||||
with suppress(ImportError): # for people running form source
|
with suppress(ImportError): # for people running form source
|
||||||
from calibre_extensions.progress_indicator import (
|
from calibre_extensions.progress_indicator import (
|
||||||
set_image_allocation_limit as impl
|
set_image_allocation_limit as impl,
|
||||||
)
|
)
|
||||||
impl(size_in_mb)
|
impl(size_in_mb)
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user