mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
sort imports in all python files
This commit is contained in:
parent
6fb49c9a22
commit
53b74283a4
@ -8,10 +8,8 @@ import re
|
||||
import subprocess
|
||||
import sys
|
||||
|
||||
from bypy.constants import (
|
||||
LIBDIR, PREFIX, PYTHON, SRC as CALIBRE_DIR, build_dir, islinux, ismacos,
|
||||
worker_env
|
||||
)
|
||||
from bypy.constants import LIBDIR, PREFIX, PYTHON, build_dir, islinux, ismacos, worker_env
|
||||
from bypy.constants import SRC as CALIBRE_DIR
|
||||
from bypy.utils import run_shell
|
||||
|
||||
dlls = [
|
||||
|
@ -12,16 +12,10 @@ import tarfile
|
||||
import time
|
||||
from functools import partial
|
||||
|
||||
from bypy.constants import (
|
||||
LIBDIR, OUTPUT_DIR, PREFIX, SRC as CALIBRE_DIR, python_major_minor_version,
|
||||
)
|
||||
from bypy.freeze import (
|
||||
extract_extension_modules, fix_pycryptodome, freeze_python, is_package_dir,
|
||||
path_to_freeze_dir,
|
||||
)
|
||||
from bypy.utils import (
|
||||
create_job, get_dll_path, mkdtemp, parallel_build, py_compile, run, walk,
|
||||
)
|
||||
from bypy.constants import LIBDIR, OUTPUT_DIR, PREFIX, python_major_minor_version
|
||||
from bypy.constants import SRC as CALIBRE_DIR
|
||||
from bypy.freeze import extract_extension_modules, fix_pycryptodome, freeze_python, is_package_dir, path_to_freeze_dir
|
||||
from bypy.utils import create_job, get_dll_path, mkdtemp, parallel_build, py_compile, run, walk
|
||||
|
||||
j = os.path.join
|
||||
self_dir = os.path.dirname(os.path.abspath(__file__))
|
||||
|
@ -19,16 +19,10 @@ import zipfile
|
||||
from functools import partial, reduce
|
||||
from itertools import repeat
|
||||
|
||||
from bypy.constants import (
|
||||
OUTPUT_DIR, PREFIX, PYTHON, SRC as CALIBRE_DIR, python_major_minor_version,
|
||||
)
|
||||
from bypy.freeze import (
|
||||
extract_extension_modules, fix_pycryptodome, freeze_python, is_package_dir,
|
||||
path_to_freeze_dir,
|
||||
)
|
||||
from bypy.utils import (
|
||||
current_dir, get_arches_in_binary, mkdtemp, py_compile, timeit, walk,
|
||||
)
|
||||
from bypy.constants import OUTPUT_DIR, PREFIX, PYTHON, python_major_minor_version
|
||||
from bypy.constants import SRC as CALIBRE_DIR
|
||||
from bypy.freeze import extract_extension_modules, fix_pycryptodome, freeze_python, is_package_dir, path_to_freeze_dir
|
||||
from bypy.utils import current_dir, get_arches_in_binary, mkdtemp, py_compile, timeit, walk
|
||||
|
||||
abspath, join, basename, dirname = os.path.abspath, os.path.join, os.path.basename, os.path.dirname
|
||||
iv = globals()['init_env']
|
||||
|
@ -6,10 +6,7 @@ import os
|
||||
import plistlib
|
||||
from glob import glob
|
||||
|
||||
from bypy.macos_sign import (
|
||||
codesign, create_entitlements_file, make_certificate_useable, notarize_app,
|
||||
verify_signature
|
||||
)
|
||||
from bypy.macos_sign import codesign, create_entitlements_file, make_certificate_useable, notarize_app, verify_signature
|
||||
from bypy.utils import current_dir
|
||||
|
||||
entitlements = {
|
||||
|
@ -1,6 +1,7 @@
|
||||
import builtins
|
||||
import os
|
||||
import sys
|
||||
|
||||
import _sitebuiltins
|
||||
|
||||
USER_SITE = None
|
||||
|
@ -15,14 +15,9 @@ import subprocess
|
||||
import sys
|
||||
import zipfile
|
||||
|
||||
from bypy.constants import (
|
||||
CL, LINK, MT, PREFIX, RC, SIGNTOOL, SRC as CALIBRE_DIR, SW, build_dir,
|
||||
python_major_minor_version, worker_env
|
||||
)
|
||||
from bypy.freeze import (
|
||||
cleanup_site_packages, extract_extension_modules, freeze_python,
|
||||
path_to_freeze_dir
|
||||
)
|
||||
from bypy.constants import CL, LINK, MT, PREFIX, RC, SIGNTOOL, SW, build_dir, python_major_minor_version, worker_env
|
||||
from bypy.constants import SRC as CALIBRE_DIR
|
||||
from bypy.freeze import cleanup_site_packages, extract_extension_modules, freeze_python, path_to_freeze_dir
|
||||
from bypy.utils import mkdtemp, py_compile, run, walk
|
||||
|
||||
iv = globals()['init_env']
|
||||
|
@ -6,8 +6,8 @@ import builtins
|
||||
import os
|
||||
import sys
|
||||
from importlib import import_module
|
||||
from importlib.util import spec_from_file_location
|
||||
from importlib.machinery import EXTENSION_SUFFIXES
|
||||
from importlib.util import spec_from_file_location
|
||||
|
||||
import _sitebuiltins
|
||||
|
||||
@ -96,6 +96,7 @@ if __name__ == '__main__':
|
||||
except Exception:
|
||||
if sys.gui_app and sys.excepthook == sys.__excepthook__:
|
||||
import traceback
|
||||
|
||||
import calibre_os_module
|
||||
calibre_os_module.gui_error_message(
|
||||
f"Unhandled exception running {sys.calibre_basename}",
|
||||
|
@ -2,9 +2,9 @@
|
||||
# vim:fileencoding=utf-8
|
||||
# License: GPLv3 Copyright: 2016, Kovid Goyal <kovid at kovidgoyal.net>
|
||||
|
||||
from itertools import count
|
||||
import os
|
||||
import shutil
|
||||
from itertools import count
|
||||
|
||||
from bypy.constants import is64bit
|
||||
from bypy.utils import run
|
||||
|
@ -5,7 +5,10 @@
|
||||
__license__ = 'GPL v3'
|
||||
__copyright__ = '2014, Kovid Goyal <kovid at kovidgoyal.net>'
|
||||
|
||||
import os, shutil, subprocess, sys
|
||||
import os
|
||||
import shutil
|
||||
import subprocess
|
||||
import sys
|
||||
|
||||
d, j, a = (getattr(os.path, x) for x in ('dirname', 'join', 'abspath'))
|
||||
base = d(a(__file__))
|
||||
|
@ -5,7 +5,10 @@
|
||||
__license__ = 'GPL v3'
|
||||
__copyright__ = '2014, Kovid Goyal <kovid at kovidgoyal.net>'
|
||||
|
||||
import os, shutil, subprocess, sys
|
||||
import os
|
||||
import shutil
|
||||
import subprocess
|
||||
import sys
|
||||
|
||||
d, j, a = (getattr(os.path, x) for x in ('dirname', 'join', 'abspath'))
|
||||
base = d(a(__file__))
|
||||
|
@ -2,7 +2,12 @@
|
||||
# vim:fileencoding=utf-8
|
||||
# License: GPLv3 Copyright: 2016, Kovid Goyal <kovid at kovidgoyal.net>
|
||||
|
||||
import os, glob, subprocess, argparse, json, hashlib
|
||||
import argparse
|
||||
import glob
|
||||
import hashlib
|
||||
import json
|
||||
import os
|
||||
import subprocess
|
||||
|
||||
duplicates = {
|
||||
'character-set': ['languages'],
|
||||
|
@ -3,7 +3,10 @@
|
||||
# License: GPLv3 Copyright: 2016, Kovid Goyal <kovid at kovidgoyal.net>
|
||||
|
||||
|
||||
import os, subprocess, sys, shutil
|
||||
import os
|
||||
import shutil
|
||||
import subprocess
|
||||
import sys
|
||||
|
||||
j = os.path.join
|
||||
base = os.path.dirname(os.path.abspath(__file__))
|
||||
|
@ -3,7 +3,9 @@
|
||||
# License: GPLv3 Copyright: 2016, Kovid Goyal <kovid at kovidgoyal.net>
|
||||
|
||||
|
||||
import os, re, sys
|
||||
import os
|
||||
import re
|
||||
import sys
|
||||
|
||||
from lxml import etree
|
||||
|
||||
|
@ -5,7 +5,10 @@
|
||||
__license__ = 'GPL v3'
|
||||
__copyright__ = '2014, Kovid Goyal <kovid at kovidgoyal.net>'
|
||||
|
||||
import sys, os, subprocess, shutil
|
||||
import os
|
||||
import shutil
|
||||
import subprocess
|
||||
import sys
|
||||
import tempfile
|
||||
from functools import partial
|
||||
|
||||
@ -14,8 +17,10 @@ BASE = d(a(__file__))
|
||||
SPHINX_BUILD = ['sphinx-build']
|
||||
|
||||
sys.path.insert(0, d(BASE))
|
||||
from setup import __appname__, __version__
|
||||
from calibre.ebooks.oeb.polish.container import epub_to_azw3
|
||||
|
||||
from setup import __appname__, __version__
|
||||
|
||||
sys.path.remove(d(BASE))
|
||||
|
||||
|
||||
|
@ -11,17 +11,21 @@
|
||||
# All configuration values have a default value; values that are commented out
|
||||
# serve to show the default value.
|
||||
|
||||
import sys, os, errno
|
||||
import errno
|
||||
import os
|
||||
import sys
|
||||
from datetime import date
|
||||
|
||||
# If your extensions are in another directory, add it here.
|
||||
base = os.path.dirname(os.path.abspath(__file__))
|
||||
sys.path.append(base)
|
||||
sys.path.insert(0, os.path.dirname(base))
|
||||
from setup import __appname__, __version__
|
||||
from calibre.utils.localization import localize_website_link
|
||||
import calibre.utils.img as cimg
|
||||
import custom
|
||||
from calibre.utils.localization import localize_website_link
|
||||
|
||||
from setup import __appname__, __version__
|
||||
|
||||
del sys.path[0]
|
||||
custom, cimg
|
||||
# General configuration
|
||||
@ -158,6 +162,7 @@ html_last_updated_fmt = '%b %d, %Y'
|
||||
html_short_title = _('Start')
|
||||
|
||||
from calibre.utils.localization import get_language
|
||||
|
||||
html_context = {}
|
||||
html_context['other_languages'] = [
|
||||
(lc, get_language(lc)) for lc in os.environ.get('ALL_USER_MANUAL_LANGUAGES', '').split() if lc != language]
|
||||
|
@ -6,11 +6,10 @@ import os
|
||||
import re
|
||||
from functools import partial
|
||||
|
||||
from sphinx.util.console import bold
|
||||
from sphinx.util.logging import getLogger
|
||||
|
||||
from calibre.linux import cli_index_strings, entry_points
|
||||
from epub import EPUBHelpBuilder
|
||||
from sphinx.util.console import bold
|
||||
from sphinx.util.logging import getLogger
|
||||
|
||||
|
||||
def info(*a):
|
||||
@ -86,7 +85,7 @@ def titlecase(language, x):
|
||||
|
||||
|
||||
def generate_calibredb_help(preamble, language):
|
||||
from calibre.db.cli.main import COMMANDS, option_parser_for, get_parser
|
||||
from calibre.db.cli.main import COMMANDS, get_parser, option_parser_for
|
||||
preamble = preamble[:preamble.find('\n\n\n', preamble.find('code-block'))]
|
||||
preamble += '\n\n'
|
||||
preamble += _('''\
|
||||
@ -156,8 +155,8 @@ details and examples.
|
||||
|
||||
|
||||
def generate_ebook_convert_help(preamble, app):
|
||||
from calibre.ebooks.conversion.cli import create_option_parser, manual_index_strings
|
||||
from calibre.customize.ui import input_format_plugins, output_format_plugins
|
||||
from calibre.ebooks.conversion.cli import create_option_parser, manual_index_strings
|
||||
from calibre.utils.logging import default_log
|
||||
preamble = re.sub(r'http.*\.html', ':ref:`conversion`', preamble)
|
||||
|
||||
|
@ -8,13 +8,13 @@ __docformat__ = 'restructuredtext en'
|
||||
|
||||
import os
|
||||
|
||||
from sphinx.builders.epub3 import Epub3Builder as EpubBuilder
|
||||
|
||||
from calibre.ebooks.oeb.base import OPF
|
||||
from calibre.ebooks.oeb.polish.container import get_container, OEB_DOCS
|
||||
from calibre.ebooks.oeb.polish.check.links import check_links, UnreferencedResource
|
||||
from calibre.ebooks.oeb.polish.check.links import UnreferencedResource, check_links
|
||||
from calibre.ebooks.oeb.polish.container import OEB_DOCS, get_container
|
||||
from calibre.ebooks.oeb.polish.pretty import pretty_html_tree, pretty_opf
|
||||
from calibre.utils.imghdr import identify
|
||||
from sphinx.builders.epub3 import Epub3Builder as EpubBuilder
|
||||
|
||||
from polyglot.builtins import iteritems
|
||||
|
||||
|
||||
|
@ -6,15 +6,15 @@ __license__ = 'GPL v3'
|
||||
__copyright__ = '2014, Kovid Goyal <kovid at kovidgoyal.net>'
|
||||
|
||||
import re
|
||||
from qt.core import QAction, QInputDialog
|
||||
from css_parser.css import CSSRule
|
||||
|
||||
from calibre import force_unicode
|
||||
from calibre.ebooks.oeb.polish.container import OEB_DOCS, OEB_STYLES, serialize
|
||||
from calibre.gui2 import error_dialog
|
||||
|
||||
# The base class that all tools must inherit from
|
||||
from calibre.gui2.tweak_book.plugin import Tool
|
||||
|
||||
from calibre import force_unicode
|
||||
from calibre.gui2 import error_dialog
|
||||
from calibre.ebooks.oeb.polish.container import OEB_DOCS, OEB_STYLES, serialize
|
||||
from css_parser.css import CSSRule
|
||||
from qt.core import QAction, QInputDialog
|
||||
|
||||
|
||||
class DemoTool(Tool):
|
||||
|
@ -7,8 +7,10 @@ __copyright__ = '2011, Kovid Goyal <kovid@kovidgoyal.net>'
|
||||
__docformat__ = 'restructuredtext en'
|
||||
|
||||
import os
|
||||
|
||||
from calibre.customize import FileTypePlugin
|
||||
|
||||
|
||||
class HelloWorld(FileTypePlugin):
|
||||
|
||||
name = 'Hello World Plugin' # Name of the plugin
|
||||
|
@ -9,6 +9,7 @@ __docformat__ = 'restructuredtext en'
|
||||
# The class that all Interface Action plugin wrappers must inherit from
|
||||
from calibre.customize import InterfaceActionBase
|
||||
|
||||
|
||||
class InterfacePluginDemo(InterfaceActionBase):
|
||||
'''
|
||||
This class is a simple wrapper that provides information about the actual
|
||||
|
@ -6,9 +6,8 @@ __license__ = 'GPL v3'
|
||||
__copyright__ = '2011, Kovid Goyal <kovid@kovidgoyal.net>'
|
||||
__docformat__ = 'restructuredtext en'
|
||||
|
||||
from qt.core import QWidget, QHBoxLayout, QLabel, QLineEdit
|
||||
|
||||
from calibre.utils.config import JSONConfig
|
||||
from qt.core import QHBoxLayout, QLabel, QLineEdit, QWidget
|
||||
|
||||
# This is where all preferences for this plugin will be stored
|
||||
# Remember that this name (i.e. plugins/interface_demo) is also
|
||||
|
@ -12,9 +12,8 @@ if False:
|
||||
# You do not need this code in your plugins
|
||||
get_icons = get_resources = None
|
||||
|
||||
from qt.core import QDialog, QVBoxLayout, QPushButton, QMessageBox, QLabel
|
||||
|
||||
from calibre_plugins.interface_demo.config import prefs
|
||||
from qt.core import QDialog, QLabel, QMessageBox, QPushButton, QVBoxLayout
|
||||
|
||||
|
||||
class DemoDialog(QDialog):
|
||||
|
@ -1,8 +1,9 @@
|
||||
#!/usr/bin/env python
|
||||
# vim:fileencoding=UTF-8:ts=4:sw=4:sta:et:sts=4:ai
|
||||
|
||||
from docutils import nodes
|
||||
from itertools import count
|
||||
|
||||
from docutils import nodes
|
||||
from sphinx.environment.adapters.toctree import TocTree
|
||||
|
||||
id_counter = count()
|
||||
|
7
setup.py
7
setup.py
@ -6,7 +6,10 @@ __license__ = 'GPL v3'
|
||||
__copyright__ = '2009, Kovid Goyal <kovid@kovidgoyal.net>'
|
||||
__docformat__ = 'restructuredtext en'
|
||||
|
||||
import sys, os, re
|
||||
import os
|
||||
import re
|
||||
import sys
|
||||
|
||||
src_base = os.path.dirname(os.path.abspath(__file__))
|
||||
|
||||
|
||||
@ -32,7 +35,7 @@ check_version_info()
|
||||
sys.path.insert(0, src_base)
|
||||
|
||||
import setup.commands as commands
|
||||
from setup import prints, get_warnings
|
||||
from setup import get_warnings, prints
|
||||
|
||||
|
||||
def option_parser():
|
||||
|
@ -6,6 +6,7 @@ __copyright__ = '2009, Kovid Goyal <kovid@kovidgoyal.net>'
|
||||
__docformat__ = 'restructuredtext en'
|
||||
|
||||
import errno
|
||||
import hashlib
|
||||
import os
|
||||
import re
|
||||
import shutil
|
||||
@ -13,7 +14,6 @@ import subprocess
|
||||
import sys
|
||||
import tempfile
|
||||
import time
|
||||
import hashlib
|
||||
from contextlib import contextmanager
|
||||
from functools import lru_cache
|
||||
|
||||
@ -167,7 +167,7 @@ def get_warnings():
|
||||
|
||||
def edit_file(path):
|
||||
return subprocess.Popen([
|
||||
'vim', '-c', 'ALELint', '-c', 'ALEFirst', '-S', os.path.join(SRC, '../session.vim'), '-f', path
|
||||
os.environ.get('EDITOR', 'vim'), '-S', os.path.join(SRC, '../session.vim'), '-f', path
|
||||
]).wait() == 0
|
||||
|
||||
|
||||
|
@ -4,8 +4,8 @@
|
||||
|
||||
import bz2
|
||||
import os
|
||||
import sys
|
||||
import ssl
|
||||
import sys
|
||||
from datetime import datetime, timezone
|
||||
from urllib.request import urlopen
|
||||
|
||||
|
@ -15,7 +15,7 @@ import sys
|
||||
import sysconfig
|
||||
import textwrap
|
||||
from functools import partial
|
||||
from typing import NamedTuple, List
|
||||
from typing import List, NamedTuple
|
||||
|
||||
from setup import SRC, Command, isbsd, isfreebsd, ishaiku, islinux, ismacos, iswindows
|
||||
|
||||
|
@ -5,8 +5,13 @@ __license__ = 'GPL v3'
|
||||
__copyright__ = '2009, Kovid Goyal <kovid@kovidgoyal.net>'
|
||||
__docformat__ = 'restructuredtext en'
|
||||
|
||||
import os, json, subprocess, errno, hashlib
|
||||
from setup import Command, build_cache_dir, edit_file, dump_json
|
||||
import errno
|
||||
import hashlib
|
||||
import json
|
||||
import os
|
||||
import subprocess
|
||||
|
||||
from setup import Command, build_cache_dir, dump_json, edit_file
|
||||
|
||||
|
||||
class Message:
|
||||
|
@ -23,7 +23,8 @@ __all__ = [
|
||||
'export_packages', 'hyphenation', 'liberation_fonts', 'stylelint', 'xwin',
|
||||
]
|
||||
|
||||
from setup.installers import Linux, Win, OSX, Linux64, LinuxArm64, Win64, ExtDev, BuildDep, ExportPackages
|
||||
from setup.installers import OSX, BuildDep, ExportPackages, ExtDev, Linux, Linux64, LinuxArm64, Win, Win64
|
||||
|
||||
linux, linux64, linuxarm64 = Linux(), Linux64(), LinuxArm64()
|
||||
win, win64 = Win(), Win64()
|
||||
osx = OSX()
|
||||
@ -31,7 +32,8 @@ extdev = ExtDev()
|
||||
build_dep = BuildDep()
|
||||
export_packages = ExportPackages()
|
||||
|
||||
from setup.translations import POT, GetTranslations, Translations, ISO639, ISO3166
|
||||
from setup.translations import ISO639, ISO3166, POT, GetTranslations, Translations
|
||||
|
||||
pot = POT()
|
||||
translations = Translations()
|
||||
get_translations = GetTranslations()
|
||||
@ -39,49 +41,60 @@ iso639 = ISO639()
|
||||
iso3166 = ISO3166()
|
||||
|
||||
from setup.csslint import CSSLint
|
||||
|
||||
stylelint = CSSLint()
|
||||
|
||||
from setup.build import Build
|
||||
|
||||
build = Build()
|
||||
|
||||
from setup.mathjax import MathJax
|
||||
|
||||
mathjax = MathJax()
|
||||
|
||||
from setup.hyphenation import Hyphenation
|
||||
|
||||
hyphenation = Hyphenation()
|
||||
|
||||
from setup.liberation import LiberationFonts
|
||||
|
||||
liberation_fonts = LiberationFonts()
|
||||
|
||||
from setup.git_version import GitVersion
|
||||
|
||||
git_version = GitVersion()
|
||||
|
||||
from setup.install import Develop, Install, Sdist, Bootstrap
|
||||
from setup.install import Bootstrap, Develop, Install, Sdist
|
||||
|
||||
develop = Develop()
|
||||
install = Install()
|
||||
sdist = Sdist()
|
||||
bootstrap = Bootstrap()
|
||||
|
||||
from setup.gui import GUI
|
||||
|
||||
gui = GUI()
|
||||
|
||||
from setup.check import Check, UpgradeSourceCode
|
||||
|
||||
check = Check()
|
||||
upgrade_source_code = UpgradeSourceCode()
|
||||
|
||||
from setup.test import Test, TestRS
|
||||
|
||||
test = Test()
|
||||
test_rs = TestRS()
|
||||
|
||||
from setup.resources import Resources, Kakasi, CACerts, RapydScript, RecentUAs
|
||||
from setup.resources import CACerts, Kakasi, RapydScript, RecentUAs, Resources
|
||||
|
||||
resources = Resources()
|
||||
kakasi = Kakasi()
|
||||
cacerts = CACerts()
|
||||
recent_uas = RecentUAs()
|
||||
rapydscript = RapydScript()
|
||||
|
||||
from setup.publish import Manual, TagRelease, Stage1, Stage2, \
|
||||
Stage3, Stage4, Stage5, Publish, PublishBetas, PublishPreview, ManPages
|
||||
from setup.publish import ManPages, Manual, Publish, PublishBetas, PublishPreview, Stage1, Stage2, Stage3, Stage4, Stage5, TagRelease
|
||||
|
||||
manual = Manual()
|
||||
tag_release = TagRelease()
|
||||
stage1 = Stage1()
|
||||
@ -94,8 +107,8 @@ publish_betas = PublishBetas()
|
||||
publish_preview = PublishPreview()
|
||||
man_pages = ManPages()
|
||||
|
||||
from setup.upload import (UploadUserManual, UploadDemo, UploadInstallers,
|
||||
UploadToServer, ReUpload)
|
||||
from setup.upload import ReUpload, UploadDemo, UploadInstallers, UploadToServer, UploadUserManual
|
||||
|
||||
upload_user_manual = UploadUserManual()
|
||||
upload_demo = UploadDemo()
|
||||
upload_to_server = UploadToServer()
|
||||
@ -104,6 +117,7 @@ reupload = ReUpload()
|
||||
|
||||
|
||||
from setup.xwin import XWin
|
||||
|
||||
xwin = XWin()
|
||||
|
||||
commands = {}
|
||||
|
@ -4,7 +4,9 @@
|
||||
__license__ = 'GPL v3'
|
||||
__copyright__ = '2014, Kovid Goyal <kovid at kovidgoyal.net>'
|
||||
|
||||
import os, subprocess, socket
|
||||
import os
|
||||
import socket
|
||||
import subprocess
|
||||
|
||||
BASE = '/srv/download/bw'
|
||||
|
||||
|
@ -3,7 +3,9 @@
|
||||
__license__ = 'GPL v3'
|
||||
__copyright__ = '2013, Kovid Goyal <kovid at kovidgoyal.net>'
|
||||
|
||||
import os, subprocess, sys
|
||||
import os
|
||||
import subprocess
|
||||
import sys
|
||||
|
||||
prev_rev, current_rev, flags = sys.argv[1:]
|
||||
|
||||
|
@ -3,7 +3,9 @@
|
||||
__license__ = 'GPL v3'
|
||||
__copyright__ = '2014, Kovid Goyal <kovid at kovidgoyal.net>'
|
||||
|
||||
import subprocess, os, sys
|
||||
import os
|
||||
import subprocess
|
||||
import sys
|
||||
|
||||
base = os.path.dirname(os.path.dirname(os.path.realpath(__file__)))
|
||||
os.chdir(base)
|
||||
|
@ -11,6 +11,7 @@ import sys
|
||||
import urllib.error
|
||||
import urllib.parse
|
||||
import urllib.request
|
||||
|
||||
from lxml import html
|
||||
|
||||
'''
|
||||
|
@ -4,11 +4,16 @@ __license__ = 'GPL v3'
|
||||
__copyright__ = '2011, Kovid Goyal <kovid@kovidgoyal.net>'
|
||||
__docformat__ = 'restructuredtext en'
|
||||
|
||||
import os, time, sys, shutil, json, mimetypes
|
||||
from pprint import pprint
|
||||
import json
|
||||
import mimetypes
|
||||
import os
|
||||
import shutil
|
||||
import sys
|
||||
import time
|
||||
from argparse import ArgumentParser, FileType
|
||||
from subprocess import check_call
|
||||
from collections import OrderedDict
|
||||
from pprint import pprint
|
||||
from subprocess import check_call
|
||||
|
||||
|
||||
class ReadFileWithProgressReporting: # {{{
|
||||
|
@ -12,10 +12,7 @@ import tempfile
|
||||
import textwrap
|
||||
import time
|
||||
|
||||
from setup import (
|
||||
Command, __appname__, __version__, basenames, functions,
|
||||
isbsd, ishaiku, islinux, modules
|
||||
)
|
||||
from setup import Command, __appname__, __version__, basenames, functions, isbsd, ishaiku, islinux, modules
|
||||
|
||||
HEADER = '''\
|
||||
#!/usr/bin/env python{py_major_version}
|
||||
|
@ -2,11 +2,14 @@
|
||||
# License: GPLv3 Copyright: 2016, Kovid Goyal <kovid at kovidgoyal.net>
|
||||
|
||||
|
||||
import os, sys, subprocess, binascii, json
|
||||
import binascii
|
||||
import json
|
||||
import os
|
||||
import subprocess
|
||||
import sys
|
||||
|
||||
from setup import Command
|
||||
|
||||
|
||||
d = os.path.dirname
|
||||
|
||||
|
||||
|
@ -3,7 +3,8 @@
|
||||
|
||||
import fnmatch
|
||||
import os
|
||||
import shutil, time
|
||||
import shutil
|
||||
import time
|
||||
import zipfile
|
||||
from io import BytesIO
|
||||
|
||||
|
@ -8,7 +8,11 @@ __copyright__ = '2014, Kovid Goyal <kovid at kovidgoyal.net>'
|
||||
# To regenerate run:
|
||||
# sudo locale-gen -A && python3 lc_time.py
|
||||
|
||||
import locale, os, pprint, sys
|
||||
import locale
|
||||
import os
|
||||
import pprint
|
||||
import sys
|
||||
|
||||
|
||||
def generate_data():
|
||||
def nl(code):
|
||||
|
@ -37,17 +37,18 @@ if machine.startswith('arm') or machine.startswith('aarch64'):
|
||||
if py3:
|
||||
unicode = str
|
||||
raw_input = input
|
||||
from urllib.parse import urlparse
|
||||
from urllib.request import BaseHandler, build_opener, Request, urlopen, getproxies, addinfourl
|
||||
import http.client as httplib
|
||||
from urllib.parse import urlparse
|
||||
from urllib.request import BaseHandler, Request, addinfourl, build_opener, getproxies, urlopen
|
||||
def encode_for_subprocess(x):
|
||||
return x
|
||||
else:
|
||||
from future_builtins import map
|
||||
from urlparse import urlparse
|
||||
from urllib import urlopen, getproxies, addinfourl
|
||||
from urllib2 import BaseHandler, build_opener, Request
|
||||
from urllib import addinfourl, getproxies, urlopen
|
||||
|
||||
import httplib
|
||||
from future_builtins import map
|
||||
from urllib2 import BaseHandler, Request, build_opener
|
||||
from urlparse import urlparse
|
||||
|
||||
def encode_for_subprocess(x):
|
||||
if isinstance(x, unicode):
|
||||
|
@ -5,10 +5,10 @@ __license__ = 'GPL v3'
|
||||
__copyright__ = '2012, Kovid Goyal <kovid at kovidgoyal.net>'
|
||||
__docformat__ = 'restructuredtext en'
|
||||
|
||||
import os, json
|
||||
import json
|
||||
import os
|
||||
from hashlib import sha1
|
||||
|
||||
|
||||
from setup.revendor import ReVendor
|
||||
|
||||
|
||||
|
@ -4,14 +4,20 @@
|
||||
__license__ = 'GPL v3'
|
||||
__copyright__ = '2014, Kovid Goyal <kovid at kovidgoyal.net>'
|
||||
|
||||
import subprocess, os, itertools, json, sys, shlex
|
||||
from multiprocessing.pool import ThreadPool as Pool
|
||||
import itertools
|
||||
import json
|
||||
import os
|
||||
import shlex
|
||||
import subprocess
|
||||
import sys
|
||||
from collections import namedtuple
|
||||
from threading import Thread
|
||||
from functools import partial
|
||||
from contextlib import closing
|
||||
from functools import partial
|
||||
from multiprocessing.pool import ThreadPool as Pool
|
||||
from threading import Thread
|
||||
|
||||
from polyglot.builtins import as_bytes, unicode_type
|
||||
|
||||
from polyglot.builtins import unicode_type, as_bytes
|
||||
Job = namedtuple('Job', 'cmd human_text cwd')
|
||||
|
||||
cpu_count = min(16, max(1, os.cpu_count()))
|
||||
|
@ -45,9 +45,9 @@ except ImportError:
|
||||
|
||||
try:
|
||||
from urllib.error import URLError
|
||||
from urllib.request import urlopen, Request, build_opener
|
||||
from urllib.request import Request, build_opener, urlopen
|
||||
except Exception:
|
||||
from urllib2 import urlopen, Request, build_opener, URLError
|
||||
from urllib2 import Request, URLError, build_opener, urlopen
|
||||
# }}}
|
||||
|
||||
USER_AGENT = 'calibre mirror'
|
||||
|
@ -5,10 +5,17 @@ __license__ = 'GPL v3'
|
||||
__copyright__ = '2009, Kovid Goyal <kovid@kovidgoyal.net>'
|
||||
__docformat__ = 'restructuredtext en'
|
||||
|
||||
import os, shutil, subprocess, tempfile, json, time, filecmp, sys
|
||||
import filecmp
|
||||
import json
|
||||
import os
|
||||
import shutil
|
||||
import subprocess
|
||||
import sys
|
||||
import tempfile
|
||||
import time
|
||||
|
||||
from setup import Command, __version__, require_clean_git, require_git_master, installer_names
|
||||
from setup.parallel_build import parallel_build, create_job
|
||||
from setup import Command, __version__, installer_names, require_clean_git, require_git_master
|
||||
from setup.parallel_build import create_job, parallel_build
|
||||
|
||||
|
||||
class Stage1(Command):
|
||||
|
@ -5,11 +5,17 @@ __license__ = 'GPL v3'
|
||||
__copyright__ = '2009, Kovid Goyal <kovid@kovidgoyal.net>'
|
||||
__docformat__ = 'restructuredtext en'
|
||||
|
||||
import os, re, shutil, zipfile, glob, json, errno
|
||||
import errno
|
||||
import glob
|
||||
import json
|
||||
import os
|
||||
import re
|
||||
import shutil
|
||||
import zipfile
|
||||
from zlib import compress
|
||||
|
||||
from setup import Command, basenames, __appname__, download_securely, dump_json
|
||||
from polyglot.builtins import codepoint_to_chr, itervalues, iteritems, only_unicode_recursive
|
||||
from polyglot.builtins import codepoint_to_chr, iteritems, itervalues, only_unicode_recursive
|
||||
from setup import Command, __appname__, basenames, download_securely, dump_json
|
||||
|
||||
|
||||
def get_opts_from_parser(parser):
|
||||
@ -180,7 +186,7 @@ class RapydScript(Command): # {{{
|
||||
help='Only compile the specified module')
|
||||
|
||||
def run(self, opts):
|
||||
from calibre.utils.rapydscript import compile_srv, compile_editor, compile_viewer
|
||||
from calibre.utils.rapydscript import compile_editor, compile_srv, compile_viewer
|
||||
if opts.only_module:
|
||||
locals()['compile_' + opts.only_module]()
|
||||
else:
|
||||
@ -210,8 +216,7 @@ class Resources(Command): # {{{
|
||||
with open(dest, 'wb') as f:
|
||||
f.write(msgpack_dumps(scripts))
|
||||
|
||||
from calibre.web.feeds.recipes.collection import \
|
||||
serialize_builtin_recipes, iterate_over_builtin_recipe_files
|
||||
from calibre.web.feeds.recipes.collection import iterate_over_builtin_recipe_files, serialize_builtin_recipes
|
||||
|
||||
files = [x[1] for x in iterate_over_builtin_recipe_files()]
|
||||
|
||||
@ -270,6 +275,7 @@ class Resources(Command): # {{{
|
||||
dest = self.j(self.RESOURCES, 'template-functions.json')
|
||||
function_dict = {}
|
||||
import inspect
|
||||
|
||||
from calibre.utils.formatter_functions import formatter_functions
|
||||
for obj in formatter_functions().get_builtins().values():
|
||||
eval_func = inspect.getmembers(obj,
|
||||
|
@ -2,7 +2,9 @@
|
||||
# License: GPLv3 Copyright: 2016, Kovid Goyal <kovid at kovidgoyal.net>
|
||||
|
||||
|
||||
import sys, os
|
||||
import os
|
||||
import sys
|
||||
|
||||
sys.setup_dir = os.path.dirname(os.path.abspath(__file__))
|
||||
SRC = os.path.abspath(os.path.join(os.path.dirname(sys.setup_dir), 'src'))
|
||||
sys.path.insert(0, SRC)
|
||||
@ -11,4 +13,5 @@ sys.extensions_location = os.path.join(SRC, 'calibre', 'plugins')
|
||||
sys.running_from_setup = True
|
||||
|
||||
from calibre.utils.ipc.worker import main
|
||||
|
||||
sys.exit(main())
|
||||
|
@ -6,7 +6,8 @@ import os
|
||||
import subprocess
|
||||
import sys
|
||||
|
||||
from setup import Command, ismacos, is_ci
|
||||
from setup import Command, is_ci, ismacos
|
||||
|
||||
TEST_MODULES = frozenset('srv db polish opf css docx cfi matcher icu smartypants build misc dbcli ebooks'.split())
|
||||
|
||||
|
||||
@ -59,9 +60,7 @@ class Test(BaseTest):
|
||||
sys.libxslt_dylib = ctypes.CDLL(os.path.join(os.environ['SW'], 'lib', 'libxslt.dylib'))
|
||||
sys.libexslt_dylib = ctypes.CDLL(os.path.join(os.environ['SW'], 'lib', 'libexslt.dylib'))
|
||||
print(sys.libxml2_dylib, sys.libxslt_dylib, sys.libexslt_dylib, file=sys.stderr, flush=True)
|
||||
from calibre.utils.run_tests import (
|
||||
filter_tests_by_name, remove_tests_by_name, run_cli, find_tests
|
||||
)
|
||||
from calibre.utils.run_tests import filter_tests_by_name, find_tests, remove_tests_by_name, run_cli
|
||||
tests = find_tests(which_tests=frozenset(opts.test_module), exclude_tests=frozenset(opts.exclude_test_module))
|
||||
if opts.test_name:
|
||||
tests = filter_tests_by_name(tests, *opts.test_name)
|
||||
|
@ -5,15 +5,27 @@ __license__ = 'GPL v3'
|
||||
__copyright__ = '2009, Kovid Goyal <kovid@kovidgoyal.net>'
|
||||
__docformat__ = 'restructuredtext en'
|
||||
|
||||
import os, tempfile, shutil, subprocess, glob, re, time, textwrap, shlex, json, errno, hashlib, sys
|
||||
import errno
|
||||
import glob
|
||||
import hashlib
|
||||
import json
|
||||
import os
|
||||
import re
|
||||
import shlex
|
||||
import shutil
|
||||
import subprocess
|
||||
import sys
|
||||
import tempfile
|
||||
import textwrap
|
||||
import time
|
||||
from collections import defaultdict
|
||||
from locale import normalize as normalize_locale
|
||||
from functools import partial
|
||||
from locale import normalize as normalize_locale
|
||||
|
||||
from setup import Command, __appname__, __version__, require_git_master, build_cache_dir, edit_file, dump_json, is_ci
|
||||
from setup.parallel_build import batched_parallel_jobs
|
||||
from setup.iso_codes import iso_data
|
||||
from polyglot.builtins import codepoint_to_chr, iteritems
|
||||
from setup import Command, __appname__, __version__, build_cache_dir, dump_json, edit_file, is_ci, require_git_master
|
||||
from setup.iso_codes import iso_data
|
||||
from setup.parallel_build import batched_parallel_jobs
|
||||
|
||||
|
||||
def qt_sources():
|
||||
@ -439,7 +451,7 @@ class Translations(POT): # {{{
|
||||
def compile_content_server_translations(self):
|
||||
self.info('Compiling content-server translations')
|
||||
from calibre.utils.rapydscript import msgfmt
|
||||
from calibre.utils.zipfile import ZipFile, ZIP_DEFLATED, ZipInfo, ZIP_STORED
|
||||
from calibre.utils.zipfile import ZIP_DEFLATED, ZIP_STORED, ZipFile, ZipInfo
|
||||
with ZipFile(self.j(self.RESOURCES, 'content-server', 'locales.zip'), 'w', ZIP_DEFLATED) as zf:
|
||||
for src in glob.glob(os.path.join(self.TRANSLATIONS, 'content-server', '*.po')):
|
||||
if not self.is_po_file_ok(src):
|
||||
@ -472,7 +484,7 @@ class Translations(POT): # {{{
|
||||
def freeze_locales(self):
|
||||
zf = self.DEST + '.zip'
|
||||
from calibre import CurrentDir
|
||||
from calibre.utils.zipfile import ZipFile, ZIP_DEFLATED
|
||||
from calibre.utils.zipfile import ZIP_DEFLATED, ZipFile
|
||||
with ZipFile(zf, 'w', ZIP_DEFLATED) as zf:
|
||||
with CurrentDir(self.DEST):
|
||||
zf.add_dir('.')
|
||||
@ -483,9 +495,9 @@ class Translations(POT): # {{{
|
||||
return self.j(self.d(self.DEST), 'stats.calibre_msgpack')
|
||||
|
||||
def _compile_website_translations(self, name='website', threshold=50):
|
||||
from calibre.utils.zipfile import ZipFile, ZipInfo, ZIP_STORED
|
||||
from calibre.ptempfile import TemporaryDirectory
|
||||
from calibre.utils.localization import get_language, translator_for_lang
|
||||
from calibre.utils.zipfile import ZIP_STORED, ZipFile, ZipInfo
|
||||
self.info('Compiling', name, 'translations...')
|
||||
srcbase = self.j(self.d(self.SRC), 'translations', name)
|
||||
if not os.path.exists(srcbase):
|
||||
|
@ -5,18 +5,27 @@ __license__ = 'GPL v3'
|
||||
__copyright__ = '2009, Kovid Goyal <kovid@kovidgoyal.net>'
|
||||
__docformat__ = 'restructuredtext en'
|
||||
|
||||
import os, subprocess, hashlib, shutil, glob, stat, sys, time, json
|
||||
import glob
|
||||
import hashlib
|
||||
import json
|
||||
import os
|
||||
import shutil
|
||||
import stat
|
||||
import subprocess
|
||||
import sys
|
||||
import time
|
||||
from subprocess import check_call
|
||||
from tempfile import NamedTemporaryFile, mkdtemp, gettempdir
|
||||
from tempfile import NamedTemporaryFile, gettempdir, mkdtemp
|
||||
from zipfile import ZipFile
|
||||
|
||||
from polyglot.builtins import iteritems
|
||||
from polyglot.urllib import urlopen, Request
|
||||
from polyglot.urllib import Request, urlopen
|
||||
|
||||
if __name__ == '__main__':
|
||||
d = os.path.dirname
|
||||
sys.path.insert(0, d(d(os.path.abspath(__file__))))
|
||||
|
||||
from setup import Command, __version__, __appname__, installer_names
|
||||
from setup import Command, __appname__, __version__, installer_names
|
||||
|
||||
DOWNLOADS = '/srv/main/downloads'
|
||||
HTML2LRF = "calibre/ebooks/lrf/html/demo"
|
||||
|
@ -2,7 +2,8 @@
|
||||
# License: GPLv3 Copyright: 2023, Kovid Goyal <kovid at kovidgoyal.net>
|
||||
|
||||
|
||||
import os, runpy
|
||||
import os
|
||||
import runpy
|
||||
import shutil
|
||||
|
||||
from setup import Command
|
||||
|
@ -3,10 +3,15 @@ __license__ = 'GPL v3'
|
||||
__copyright__ = '2008, Kovid Goyal <kovid@kovidgoyal.net>'
|
||||
__docformat__ = 'restructuredtext en'
|
||||
|
||||
import sys, os, re, time, warnings
|
||||
from polyglot.builtins import codepoint_to_chr, hasenv, native_string_type
|
||||
from math import floor
|
||||
import os
|
||||
import re
|
||||
import sys
|
||||
import time
|
||||
import warnings
|
||||
from functools import partial
|
||||
from math import floor
|
||||
|
||||
from polyglot.builtins import codepoint_to_chr, hasenv, native_string_type
|
||||
|
||||
if not hasenv('CALIBRE_SHOW_DEPRECATION_WARNINGS'):
|
||||
warnings.simplefilter('ignore', DeprecationWarning)
|
||||
@ -15,13 +20,25 @@ try:
|
||||
except OSError:
|
||||
os.chdir(os.path.expanduser('~'))
|
||||
|
||||
from calibre.constants import (iswindows, ismacos, islinux, isfrozen,
|
||||
isbsd, preferred_encoding, __appname__, __version__, __author__,
|
||||
plugins, filesystem_encoding, config_dir)
|
||||
from calibre.constants import (
|
||||
__appname__,
|
||||
__author__,
|
||||
__version__,
|
||||
config_dir,
|
||||
filesystem_encoding,
|
||||
isbsd,
|
||||
isfrozen,
|
||||
islinux,
|
||||
ismacos,
|
||||
iswindows,
|
||||
plugins,
|
||||
preferred_encoding,
|
||||
)
|
||||
from calibre.startup import initialize_calibre
|
||||
|
||||
initialize_calibre()
|
||||
from calibre.utils.icu import safe_chr
|
||||
from calibre.prints import prints
|
||||
from calibre.utils.icu import safe_chr
|
||||
from calibre.utils.resources import get_path as P
|
||||
|
||||
if False:
|
||||
@ -293,7 +310,7 @@ def is_mobile_ua(ua):
|
||||
|
||||
|
||||
def random_user_agent(choose=None, allow_ie=True):
|
||||
from calibre.utils.random_ua import common_user_agents, choose_randomly_by_popularity
|
||||
from calibre.utils.random_ua import choose_randomly_by_popularity, common_user_agents
|
||||
ua_list = common_user_agents()
|
||||
ua_list = tuple(x for x in ua_list if not is_mobile_ua(x))
|
||||
if not allow_ie:
|
||||
|
@ -1,8 +1,8 @@
|
||||
#!/usr/bin/env python
|
||||
# License: GPL v3 Copyright: 2021, Kovid Goyal <kovid at kovidgoyal.net>
|
||||
|
||||
import os
|
||||
import importlib
|
||||
import os
|
||||
|
||||
|
||||
def form_to_compiled_form(form):
|
||||
@ -39,6 +39,7 @@ def ensure_icons_built(resource_dir, force_compile, info):
|
||||
|
||||
def build_forms(srcdir, info=None, summary=False, check_for_migration=False, check_icons=True):
|
||||
import re
|
||||
|
||||
from qt.core import QT_VERSION_STR
|
||||
qt_major = QT_VERSION_STR.split('.')[0]
|
||||
m = importlib.import_module(f'PyQt{qt_major}.uic')
|
||||
|
@ -1,8 +1,14 @@
|
||||
#!/usr/bin/env python
|
||||
# License: GPLv3 Copyright: 2015, Kovid Goyal <kovid at kovidgoyal.net>
|
||||
from polyglot.builtins import environ_item, hasenv
|
||||
import codecs
|
||||
import collections
|
||||
import collections.abc
|
||||
import locale
|
||||
import os
|
||||
import sys
|
||||
from functools import lru_cache
|
||||
import sys, locale, codecs, os, collections, collections.abc
|
||||
|
||||
from polyglot.builtins import environ_item, hasenv
|
||||
|
||||
__appname__ = 'calibre'
|
||||
numeric_version = (7, 7, 101)
|
||||
@ -173,9 +179,9 @@ def cache_dir():
|
||||
plugins_loc = sys.extensions_location
|
||||
system_plugins_loc = getattr(sys, 'system_plugins_location', None)
|
||||
|
||||
from importlib.machinery import ModuleSpec, EXTENSION_SUFFIXES, ExtensionFileLoader
|
||||
from importlib.util import find_spec
|
||||
from importlib import import_module
|
||||
from importlib.machinery import EXTENSION_SUFFIXES, ExtensionFileLoader, ModuleSpec
|
||||
from importlib.util import find_spec
|
||||
|
||||
|
||||
class DeVendorLoader:
|
||||
@ -389,7 +395,8 @@ else:
|
||||
not os.access(config_dir, os.W_OK) or not \
|
||||
os.access(config_dir, os.X_OK):
|
||||
print('No write access to', config_dir, 'using a temporary dir instead')
|
||||
import tempfile, atexit
|
||||
import atexit
|
||||
import tempfile
|
||||
config_dir = tempfile.mkdtemp(prefix='calibre-config-')
|
||||
|
||||
def cleanup_cdir():
|
||||
|
@ -145,10 +145,7 @@ class Plugin: # {{{
|
||||
True if the user clicks OK, False otherwise. The changes are
|
||||
automatically applied.
|
||||
'''
|
||||
from qt.core import (
|
||||
QApplication, QDialog, QDialogButtonBox, QLabel, QLineEdit, QScrollArea, Qt,
|
||||
QVBoxLayout, QSize
|
||||
)
|
||||
from qt.core import QApplication, QDialog, QDialogButtonBox, QLabel, QLineEdit, QScrollArea, QSize, Qt, QVBoxLayout
|
||||
|
||||
from calibre.gui2 import gprefs
|
||||
|
||||
|
@ -1,12 +1,13 @@
|
||||
__license__ = 'GPL v3'
|
||||
__copyright__ = '2008, Kovid Goyal <kovid at kovidgoyal.net>'
|
||||
|
||||
import os, glob
|
||||
from calibre.customize import (FileTypePlugin, MetadataReaderPlugin,
|
||||
MetadataWriterPlugin, PreferencesPlugin, InterfaceActionBase, StoreBase)
|
||||
import glob
|
||||
import os
|
||||
|
||||
from calibre.constants import numeric_version
|
||||
from calibre.ebooks.metadata.archive import ArchiveExtract, KPFExtract, get_comic_metadata
|
||||
from calibre.customize import FileTypePlugin, InterfaceActionBase, MetadataReaderPlugin, MetadataWriterPlugin, PreferencesPlugin, StoreBase
|
||||
from calibre.ebooks.html.to_zip import HTML2ZIP
|
||||
from calibre.ebooks.metadata.archive import ArchiveExtract, KPFExtract, get_comic_metadata
|
||||
|
||||
plugins = []
|
||||
|
||||
@ -588,47 +589,45 @@ plugins += [x for x in list(locals().values()) if isinstance(x, type) and
|
||||
# }}}
|
||||
|
||||
# Conversion plugins {{{
|
||||
from calibre.ebooks.conversion.plugins.azw4_input import AZW4Input
|
||||
from calibre.ebooks.conversion.plugins.chm_input import CHMInput
|
||||
from calibre.ebooks.conversion.plugins.comic_input import ComicInput
|
||||
from calibre.ebooks.conversion.plugins.djvu_input import DJVUInput
|
||||
from calibre.ebooks.conversion.plugins.docx_input import DOCXInput
|
||||
from calibre.ebooks.conversion.plugins.docx_output import DOCXOutput
|
||||
from calibre.ebooks.conversion.plugins.epub_input import EPUBInput
|
||||
from calibre.ebooks.conversion.plugins.epub_output import EPUBOutput
|
||||
from calibre.ebooks.conversion.plugins.fb2_input import FB2Input
|
||||
from calibre.ebooks.conversion.plugins.fb2_output import FB2Output
|
||||
from calibre.ebooks.conversion.plugins.html_input import HTMLInput
|
||||
from calibre.ebooks.conversion.plugins.html_output import HTMLOutput
|
||||
from calibre.ebooks.conversion.plugins.htmlz_input import HTMLZInput
|
||||
from calibre.ebooks.conversion.plugins.htmlz_output import HTMLZOutput
|
||||
from calibre.ebooks.conversion.plugins.lit_input import LITInput
|
||||
from calibre.ebooks.conversion.plugins.lit_output import LITOutput
|
||||
from calibre.ebooks.conversion.plugins.lrf_input import LRFInput
|
||||
from calibre.ebooks.conversion.plugins.lrf_output import LRFOutput
|
||||
from calibre.ebooks.conversion.plugins.mobi_input import MOBIInput
|
||||
from calibre.ebooks.conversion.plugins.mobi_output import AZW3Output, MOBIOutput
|
||||
from calibre.ebooks.conversion.plugins.odt_input import ODTInput
|
||||
from calibre.ebooks.conversion.plugins.oeb_output import OEBOutput
|
||||
from calibre.ebooks.conversion.plugins.pdb_input import PDBInput
|
||||
from calibre.ebooks.conversion.plugins.azw4_input import AZW4Input
|
||||
from calibre.ebooks.conversion.plugins.pdb_output import PDBOutput
|
||||
from calibre.ebooks.conversion.plugins.pdf_input import PDFInput
|
||||
from calibre.ebooks.conversion.plugins.pdf_output import PDFOutput
|
||||
from calibre.ebooks.conversion.plugins.pml_input import PMLInput
|
||||
from calibre.ebooks.conversion.plugins.pml_output import PMLOutput
|
||||
from calibre.ebooks.conversion.plugins.rb_input import RBInput
|
||||
from calibre.ebooks.conversion.plugins.rb_output import RBOutput
|
||||
from calibre.ebooks.conversion.plugins.recipe_input import RecipeInput
|
||||
from calibre.ebooks.conversion.plugins.rtf_input import RTFInput
|
||||
from calibre.ebooks.conversion.plugins.tcr_input import TCRInput
|
||||
from calibre.ebooks.conversion.plugins.txt_input import TXTInput
|
||||
from calibre.ebooks.conversion.plugins.lrf_input import LRFInput
|
||||
from calibre.ebooks.conversion.plugins.chm_input import CHMInput
|
||||
from calibre.ebooks.conversion.plugins.snb_input import SNBInput
|
||||
from calibre.ebooks.conversion.plugins.docx_input import DOCXInput
|
||||
|
||||
from calibre.ebooks.conversion.plugins.epub_output import EPUBOutput
|
||||
from calibre.ebooks.conversion.plugins.fb2_output import FB2Output
|
||||
from calibre.ebooks.conversion.plugins.lit_output import LITOutput
|
||||
from calibre.ebooks.conversion.plugins.lrf_output import LRFOutput
|
||||
from calibre.ebooks.conversion.plugins.mobi_output import (MOBIOutput,
|
||||
AZW3Output)
|
||||
from calibre.ebooks.conversion.plugins.oeb_output import OEBOutput
|
||||
from calibre.ebooks.conversion.plugins.pdb_output import PDBOutput
|
||||
from calibre.ebooks.conversion.plugins.pdf_output import PDFOutput
|
||||
from calibre.ebooks.conversion.plugins.pml_output import PMLOutput
|
||||
from calibre.ebooks.conversion.plugins.rb_output import RBOutput
|
||||
from calibre.ebooks.conversion.plugins.rtf_output import RTFOutput
|
||||
from calibre.ebooks.conversion.plugins.tcr_output import TCROutput
|
||||
from calibre.ebooks.conversion.plugins.txt_output import TXTOutput, TXTZOutput
|
||||
from calibre.ebooks.conversion.plugins.html_output import HTMLOutput
|
||||
from calibre.ebooks.conversion.plugins.htmlz_output import HTMLZOutput
|
||||
from calibre.ebooks.conversion.plugins.snb_input import SNBInput
|
||||
from calibre.ebooks.conversion.plugins.snb_output import SNBOutput
|
||||
from calibre.ebooks.conversion.plugins.docx_output import DOCXOutput
|
||||
from calibre.ebooks.conversion.plugins.tcr_input import TCRInput
|
||||
from calibre.ebooks.conversion.plugins.tcr_output import TCROutput
|
||||
from calibre.ebooks.conversion.plugins.txt_input import TXTInput
|
||||
from calibre.ebooks.conversion.plugins.txt_output import TXTOutput, TXTZOutput
|
||||
|
||||
plugins += [
|
||||
ComicInput,
|
||||
@ -677,57 +676,92 @@ plugins += [
|
||||
# }}}
|
||||
|
||||
# Catalog plugins {{{
|
||||
from calibre.library.catalogs.csv_xml import CSV_XML
|
||||
from calibre.library.catalogs.bibtex import BIBTEX
|
||||
from calibre.library.catalogs.csv_xml import CSV_XML
|
||||
from calibre.library.catalogs.epub_mobi import EPUB_MOBI
|
||||
|
||||
plugins += [CSV_XML, BIBTEX, EPUB_MOBI]
|
||||
# }}}
|
||||
|
||||
# Profiles {{{
|
||||
from calibre.customize.profiles import input_profiles, output_profiles
|
||||
|
||||
plugins += input_profiles + output_profiles
|
||||
# }}}
|
||||
|
||||
# Device driver plugins {{{
|
||||
from calibre.devices.hanlin.driver import HANLINV3, HANLINV5, BOOX, SPECTRA
|
||||
from calibre.devices.android.driver import ANDROID, S60, WEBOS
|
||||
from calibre.devices.binatone.driver import README
|
||||
from calibre.devices.blackberry.driver import BLACKBERRY, PLAYBOOK
|
||||
from calibre.devices.cybook.driver import CYBOOK, ORIZON, MUSE, DIVA
|
||||
from calibre.devices.eb600.driver import (EB600, COOL_ER, SHINEBOOK, TOLINO,
|
||||
POCKETBOOK360, GER2, ITALICA, ECLICTO, DBOOK, INVESBOOK,
|
||||
BOOQ, ELONEX, POCKETBOOK301, MENTOR, POCKETBOOK602,
|
||||
POCKETBOOK701, POCKETBOOK740, POCKETBOOK360P, PI2, POCKETBOOK622,
|
||||
POCKETBOOKHD)
|
||||
from calibre.devices.boeye.driver import BOEYE_BDX, BOEYE_BEX
|
||||
from calibre.devices.cybook.driver import CYBOOK, DIVA, MUSE, ORIZON
|
||||
from calibre.devices.eb600.driver import (
|
||||
BOOQ,
|
||||
COOL_ER,
|
||||
DBOOK,
|
||||
EB600,
|
||||
ECLICTO,
|
||||
ELONEX,
|
||||
GER2,
|
||||
INVESBOOK,
|
||||
ITALICA,
|
||||
MENTOR,
|
||||
PI2,
|
||||
POCKETBOOK301,
|
||||
POCKETBOOK360,
|
||||
POCKETBOOK360P,
|
||||
POCKETBOOK602,
|
||||
POCKETBOOK622,
|
||||
POCKETBOOK701,
|
||||
POCKETBOOK740,
|
||||
POCKETBOOKHD,
|
||||
SHINEBOOK,
|
||||
TOLINO,
|
||||
)
|
||||
from calibre.devices.edge.driver import EDGE
|
||||
from calibre.devices.eslick.driver import EBK52, ESLICK
|
||||
from calibre.devices.folder_device.driver import FOLDER_DEVICE_FOR_CONFIG
|
||||
from calibre.devices.hanlin.driver import BOOX, HANLINV3, HANLINV5, SPECTRA
|
||||
from calibre.devices.hanvon.driver import ALEX, AZBOOKA, EB511, KIBANO, LIBREAIR, N516, ODYSSEY, THEBOOK
|
||||
from calibre.devices.iliad.driver import ILIAD
|
||||
from calibre.devices.irexdr.driver import IREXDR1000, IREXDR800
|
||||
from calibre.devices.jetbook.driver import (JETBOOK, MIBUK, JETBOOK_MINI,
|
||||
JETBOOK_COLOR)
|
||||
from calibre.devices.kindle.driver import (KINDLE, KINDLE2, KINDLE_DX,
|
||||
KINDLE_FIRE)
|
||||
from calibre.devices.irexdr.driver import IREXDR800, IREXDR1000
|
||||
from calibre.devices.iriver.driver import IRIVER_STORY
|
||||
from calibre.devices.jetbook.driver import JETBOOK, JETBOOK_COLOR, JETBOOK_MINI, MIBUK
|
||||
from calibre.devices.kindle.driver import KINDLE, KINDLE2, KINDLE_DX, KINDLE_FIRE
|
||||
from calibre.devices.kobo.driver import KOBO, KOBOTOUCH
|
||||
from calibre.devices.misc import (
|
||||
ADAM,
|
||||
ALURATEK_COLOR,
|
||||
AVANT,
|
||||
CERVANTES,
|
||||
COBY,
|
||||
EEEREADER,
|
||||
EX124G,
|
||||
GEMEI,
|
||||
LUMIREAD,
|
||||
MOOVYBOOK,
|
||||
NEXTBOOK,
|
||||
PALMPRE,
|
||||
PDNOVEL,
|
||||
PDNOVEL_KOBO,
|
||||
POCKETBOOK626,
|
||||
SONYDPTS1,
|
||||
SWEEX,
|
||||
TREKSTOR,
|
||||
VELOCITYMICRO,
|
||||
WAYTEQ,
|
||||
WOXTER,
|
||||
)
|
||||
from calibre.devices.mtp.driver import MTP_DEVICE
|
||||
from calibre.devices.nokia.driver import E52, E71X, N770, N810
|
||||
from calibre.devices.nook.driver import NOOK, NOOK_COLOR
|
||||
from calibre.devices.nuut2.driver import NUUT2
|
||||
from calibre.devices.prs505.driver import PRS505
|
||||
from calibre.devices.prst1.driver import PRST1
|
||||
from calibre.devices.user_defined.driver import USER_DEFINED
|
||||
from calibre.devices.android.driver import ANDROID, S60, WEBOS
|
||||
from calibre.devices.nokia.driver import N770, N810, E71X, E52
|
||||
from calibre.devices.eslick.driver import ESLICK, EBK52
|
||||
from calibre.devices.nuut2.driver import NUUT2
|
||||
from calibre.devices.iriver.driver import IRIVER_STORY
|
||||
from calibre.devices.binatone.driver import README
|
||||
from calibre.devices.hanvon.driver import (N516, EB511, ALEX, AZBOOKA, THEBOOK,
|
||||
LIBREAIR, ODYSSEY, KIBANO)
|
||||
from calibre.devices.edge.driver import EDGE
|
||||
from calibre.devices.teclast.driver import (TECLAST_K3, NEWSMY, IPAPYRUS,
|
||||
SOVOS, PICO, SUNSTECH_EB700, ARCHOS7O, STASH, WEXLER)
|
||||
from calibre.devices.sne.driver import SNE
|
||||
from calibre.devices.misc import (
|
||||
PALMPRE, AVANT, SWEEX, PDNOVEL, GEMEI, VELOCITYMICRO, PDNOVEL_KOBO,
|
||||
LUMIREAD, ALURATEK_COLOR, TREKSTOR, EEEREADER, NEXTBOOK, ADAM, MOOVYBOOK,
|
||||
COBY, EX124G, WAYTEQ, WOXTER, POCKETBOOK626, SONYDPTS1, CERVANTES)
|
||||
from calibre.devices.folder_device.driver import FOLDER_DEVICE_FOR_CONFIG
|
||||
from calibre.devices.kobo.driver import KOBO, KOBOTOUCH
|
||||
from calibre.devices.boeye.driver import BOEYE_BEX, BOEYE_BDX
|
||||
from calibre.devices.smart_device_app.driver import SMART_DEVICE_APP
|
||||
from calibre.devices.mtp.driver import MTP_DEVICE
|
||||
from calibre.devices.sne.driver import SNE
|
||||
from calibre.devices.teclast.driver import ARCHOS7O, IPAPYRUS, NEWSMY, PICO, SOVOS, STASH, SUNSTECH_EB700, TECLAST_K3, WEXLER
|
||||
from calibre.devices.user_defined.driver import USER_DEFINED
|
||||
|
||||
# Order here matters. The first matched device is the one used.
|
||||
plugins += [
|
||||
@ -805,12 +839,12 @@ plugins += [
|
||||
# }}}
|
||||
|
||||
# New metadata download plugins {{{
|
||||
from calibre.ebooks.metadata.sources.google import GoogleBooks
|
||||
from calibre.ebooks.metadata.sources.amazon import Amazon
|
||||
from calibre.ebooks.metadata.sources.edelweiss import Edelweiss
|
||||
from calibre.ebooks.metadata.sources.openlibrary import OpenLibrary
|
||||
from calibre.ebooks.metadata.sources.google_images import GoogleImages
|
||||
from calibre.ebooks.metadata.sources.big_book_search import BigBookSearch
|
||||
from calibre.ebooks.metadata.sources.edelweiss import Edelweiss
|
||||
from calibre.ebooks.metadata.sources.google import GoogleBooks
|
||||
from calibre.ebooks.metadata.sources.google_images import GoogleImages
|
||||
from calibre.ebooks.metadata.sources.openlibrary import OpenLibrary
|
||||
|
||||
plugins += [GoogleBooks, GoogleImages, Amazon, Edelweiss, OpenLibrary, BigBookSearch]
|
||||
|
||||
@ -1936,7 +1970,8 @@ plugins += [
|
||||
|
||||
if __name__ == '__main__':
|
||||
# Test load speed
|
||||
import subprocess, textwrap
|
||||
import subprocess
|
||||
import textwrap
|
||||
try:
|
||||
subprocess.check_call(['python', '-c', textwrap.dedent(
|
||||
'''
|
||||
|
@ -1,7 +1,10 @@
|
||||
'''
|
||||
Defines the plugin system for conversions.
|
||||
'''
|
||||
import re, os, shutil, numbers
|
||||
import numbers
|
||||
import os
|
||||
import re
|
||||
import shutil
|
||||
|
||||
from calibre import CurrentDir
|
||||
from calibre.customize import Plugin
|
||||
|
@ -1,26 +1,38 @@
|
||||
__license__ = 'GPL v3'
|
||||
__copyright__ = '2008, Kovid Goyal <kovid at kovidgoyal.net>'
|
||||
|
||||
import os, shutil, traceback, functools, sys
|
||||
import functools
|
||||
import os
|
||||
import shutil
|
||||
import sys
|
||||
import traceback
|
||||
from collections import defaultdict
|
||||
from itertools import chain, repeat
|
||||
|
||||
from calibre.customize import (CatalogPlugin, FileTypePlugin, PluginNotFound,
|
||||
MetadataReaderPlugin, MetadataWriterPlugin,
|
||||
InterfaceActionBase as InterfaceAction,
|
||||
PreferencesPlugin, platform, InvalidPlugin,
|
||||
StoreBase as Store, EditBookToolPlugin,
|
||||
LibraryClosedPlugin, PluginInstallationType)
|
||||
from calibre.customize.conversion import InputFormatPlugin, OutputFormatPlugin
|
||||
from calibre.customize.zipplugin import loader
|
||||
from calibre.customize.profiles import InputProfile, OutputProfile
|
||||
from calibre.constants import DEBUG, ismacos, numeric_version, system_plugins_loc
|
||||
from calibre.customize import (
|
||||
CatalogPlugin,
|
||||
EditBookToolPlugin,
|
||||
FileTypePlugin,
|
||||
InvalidPlugin,
|
||||
LibraryClosedPlugin,
|
||||
MetadataReaderPlugin,
|
||||
MetadataWriterPlugin,
|
||||
PluginInstallationType,
|
||||
PluginNotFound,
|
||||
PreferencesPlugin,
|
||||
platform,
|
||||
)
|
||||
from calibre.customize import InterfaceActionBase as InterfaceAction
|
||||
from calibre.customize import StoreBase as Store
|
||||
from calibre.customize.builtins import plugins as builtin_plugins
|
||||
from calibre.customize.conversion import InputFormatPlugin, OutputFormatPlugin
|
||||
from calibre.customize.profiles import InputProfile, OutputProfile
|
||||
from calibre.customize.zipplugin import loader
|
||||
from calibre.devices.interface import DevicePlugin
|
||||
from calibre.ebooks.metadata import MetaInformation
|
||||
from calibre.utils.config import (make_config_dir, Config, ConfigProxy,
|
||||
plugin_dir, OptionParser)
|
||||
from calibre.ebooks.metadata.sources.base import Source
|
||||
from calibre.constants import DEBUG, numeric_version, system_plugins_loc, ismacos
|
||||
from calibre.utils.config import Config, ConfigProxy, OptionParser, make_config_dir, plugin_dir
|
||||
from polyglot.builtins import iteritems, itervalues
|
||||
|
||||
builtin_names = frozenset(p.name for p in builtin_plugins)
|
||||
@ -757,8 +769,8 @@ def initialize_plugins(perf=False):
|
||||
system_plugins.pop(name, None)
|
||||
ostdout, ostderr = sys.stdout, sys.stderr
|
||||
if perf:
|
||||
from collections import defaultdict
|
||||
import time
|
||||
from collections import defaultdict
|
||||
times = defaultdict(int)
|
||||
|
||||
for zfp, installation_type in chain(
|
||||
@ -815,7 +827,7 @@ def initialized_plugins():
|
||||
def build_plugin(path):
|
||||
from calibre import prints
|
||||
from calibre.ptempfile import PersistentTemporaryFile
|
||||
from calibre.utils.zipfile import ZipFile, ZIP_STORED
|
||||
from calibre.utils.zipfile import ZIP_STORED, ZipFile
|
||||
path = str(path)
|
||||
names = frozenset(os.listdir(path))
|
||||
if '__init__.py' not in names:
|
||||
|
@ -18,9 +18,7 @@ from importlib.machinery import ModuleSpec
|
||||
from importlib.util import decode_source
|
||||
|
||||
from calibre import as_unicode
|
||||
from calibre.customize import (
|
||||
InvalidPlugin, Plugin, PluginNotFound, numeric_version, platform
|
||||
)
|
||||
from calibre.customize import InvalidPlugin, Plugin, PluginNotFound, numeric_version, platform
|
||||
from polyglot.builtins import itervalues, reload, string_or_bytes
|
||||
|
||||
|
||||
|
@ -8,6 +8,7 @@ __docformat__ = 'restructuredtext en'
|
||||
SPOOL_SIZE = 30*1024*1024
|
||||
|
||||
import numbers
|
||||
|
||||
from polyglot.builtins import iteritems
|
||||
|
||||
|
||||
@ -20,8 +21,9 @@ class FTSQueryError(ValueError):
|
||||
|
||||
|
||||
def _get_next_series_num_for_list(series_indices, unwrap=True):
|
||||
from calibre.utils.config_base import tweaks
|
||||
from math import ceil, floor
|
||||
|
||||
from calibre.utils.config_base import tweaks
|
||||
if not series_indices:
|
||||
if isinstance(tweaks['series_index_auto_increment'], numbers.Number):
|
||||
return float(tweaks['series_index_auto_increment'])
|
||||
@ -77,6 +79,7 @@ def get_data_as_dict(self, prefix=None, authors_as_string=False, ids=None, conve
|
||||
all entries in database.
|
||||
'''
|
||||
import os
|
||||
|
||||
from calibre.ebooks.metadata import authors_to_string
|
||||
from calibre.utils.date import as_local_time
|
||||
backend = getattr(self, 'backend', self) # Works with both old and legacy interfaces
|
||||
|
@ -6,7 +6,6 @@ __copyright__ = '2011, Kovid Goyal <kovid@kovidgoyal.net>'
|
||||
__docformat__ = 'restructuredtext en'
|
||||
|
||||
# Imports {{{
|
||||
import apsw
|
||||
import errno
|
||||
import hashlib
|
||||
import json
|
||||
@ -17,48 +16,64 @@ import sys
|
||||
import time
|
||||
import uuid
|
||||
from contextlib import closing, suppress
|
||||
from typing import Optional
|
||||
from functools import partial
|
||||
from typing import Optional
|
||||
|
||||
import apsw
|
||||
|
||||
from calibre import as_unicode, force_unicode, isbytestring, prints
|
||||
from calibre.constants import (
|
||||
filesystem_encoding, iswindows, plugins, preferred_encoding,
|
||||
)
|
||||
from calibre.constants import filesystem_encoding, iswindows, plugins, preferred_encoding
|
||||
from calibre.db import SPOOL_SIZE, FTSQueryError
|
||||
from calibre.db.annotations import annot_db_data, unicode_normalize
|
||||
from calibre.db.constants import (
|
||||
BOOK_ID_PATH_TEMPLATE, COVER_FILE_NAME, DEFAULT_TRASH_EXPIRY_TIME_SECONDS,
|
||||
METADATA_FILE_NAME, NOTES_DIR_NAME, TRASH_DIR_NAME, TrashEntry,
|
||||
BOOK_ID_PATH_TEMPLATE,
|
||||
COVER_FILE_NAME,
|
||||
DEFAULT_TRASH_EXPIRY_TIME_SECONDS,
|
||||
METADATA_FILE_NAME,
|
||||
NOTES_DIR_NAME,
|
||||
TRASH_DIR_NAME,
|
||||
TrashEntry,
|
||||
)
|
||||
from calibre.db.errors import NoSuchFormat
|
||||
from calibre.db.schema_upgrades import SchemaUpgrade
|
||||
from calibre.db.tables import (
|
||||
AuthorsTable, CompositeTable, FormatsTable, IdentifiersTable, ManyToManyTable,
|
||||
ManyToOneTable, OneToOneTable, PathTable, RatingTable, SizeTable, UUIDTable,
|
||||
AuthorsTable,
|
||||
CompositeTable,
|
||||
FormatsTable,
|
||||
IdentifiersTable,
|
||||
ManyToManyTable,
|
||||
ManyToOneTable,
|
||||
OneToOneTable,
|
||||
PathTable,
|
||||
RatingTable,
|
||||
SizeTable,
|
||||
UUIDTable,
|
||||
)
|
||||
from calibre.ebooks.metadata import author_to_author_sort, title_sort
|
||||
from calibre.library.field_metadata import FieldMetadata
|
||||
from calibre.ptempfile import PersistentTemporaryFile, TemporaryFile
|
||||
from calibre.utils import pickle_binary_string, unpickle_binary_string
|
||||
from calibre.utils.config import from_json, prefs, to_json, tweaks
|
||||
from calibre.utils.copy_files import (
|
||||
copy_files, copy_tree, rename_files, windows_check_if_files_in_use,
|
||||
)
|
||||
from calibre.utils.copy_files import copy_files, copy_tree, rename_files, windows_check_if_files_in_use
|
||||
from calibre.utils.date import EPOCH, parse_date, utcfromtimestamp, utcnow
|
||||
from calibre.utils.filenames import (
|
||||
ascii_filename, atomic_rename, copyfile_using_links, copytree_using_links,
|
||||
get_long_path_name, hardlink_file, is_case_sensitive, is_fat_filesystem,
|
||||
make_long_path_useable, remove_dir_if_empty, samefile,
|
||||
ascii_filename,
|
||||
atomic_rename,
|
||||
copyfile_using_links,
|
||||
copytree_using_links,
|
||||
get_long_path_name,
|
||||
hardlink_file,
|
||||
is_case_sensitive,
|
||||
is_fat_filesystem,
|
||||
make_long_path_useable,
|
||||
remove_dir_if_empty,
|
||||
samefile,
|
||||
)
|
||||
from calibre.utils.formatter_functions import (
|
||||
compile_user_template_functions, formatter_functions, load_user_template_functions,
|
||||
unload_user_template_functions,
|
||||
)
|
||||
from calibre.utils.icu import lower as icu_lower, sort_key
|
||||
from calibre.utils.formatter_functions import compile_user_template_functions, formatter_functions, load_user_template_functions, unload_user_template_functions
|
||||
from calibre.utils.icu import lower as icu_lower
|
||||
from calibre.utils.icu import sort_key
|
||||
from calibre.utils.resources import get_path as P
|
||||
from polyglot.builtins import (
|
||||
cmp, iteritems, itervalues, native_string_type, reraise, string_or_bytes,
|
||||
)
|
||||
from polyglot.builtins import cmp, iteritems, itervalues, native_string_type, reraise, string_or_bytes
|
||||
|
||||
# }}}
|
||||
|
||||
@ -1375,6 +1390,7 @@ class DB:
|
||||
|
||||
def dump_and_restore(self, callback=None, sql=None):
|
||||
import codecs
|
||||
|
||||
from apsw import Shell
|
||||
if callback is None:
|
||||
def callback(x):
|
||||
|
@ -5,8 +5,10 @@ __license__ = 'GPL v3'
|
||||
__copyright__ = '2013, Kovid Goyal <kovid at kovidgoyal.net>'
|
||||
__docformat__ = 'restructuredtext en'
|
||||
|
||||
import weakref, traceback, sys
|
||||
from threading import Thread, Event
|
||||
import sys
|
||||
import traceback
|
||||
import weakref
|
||||
from threading import Event, Thread
|
||||
|
||||
from calibre.ebooks.metadata.opf2 import metadata_to_opf
|
||||
|
||||
|
@ -25,10 +25,7 @@ from typing import NamedTuple, Optional, Tuple
|
||||
|
||||
from calibre import as_unicode, detect_ncpus, isbytestring
|
||||
from calibre.constants import iswindows, preferred_encoding
|
||||
from calibre.customize.ui import (
|
||||
run_plugins_on_import, run_plugins_on_postadd, run_plugins_on_postdelete,
|
||||
run_plugins_on_postimport,
|
||||
)
|
||||
from calibre.customize.ui import run_plugins_on_import, run_plugins_on_postadd, run_plugins_on_postdelete, run_plugins_on_postimport
|
||||
from calibre.db import SPOOL_SIZE, _get_next_series_num_for_list
|
||||
from calibre.db.annotations import merge_annotations
|
||||
from calibre.db.categories import get_categories
|
||||
@ -37,9 +34,7 @@ from calibre.db.errors import NoSuchBook, NoSuchFormat
|
||||
from calibre.db.fields import IDENTITY, InvalidLinkTable, create_field
|
||||
from calibre.db.lazy import FormatMetadata, FormatsList, ProxyMetadata
|
||||
from calibre.db.listeners import EventDispatcher, EventType
|
||||
from calibre.db.locking import (
|
||||
DowngradeLockError, LockingError, SafeReadLock, create_locks, try_lock,
|
||||
)
|
||||
from calibre.db.locking import DowngradeLockError, LockingError, SafeReadLock, create_locks, try_lock
|
||||
from calibre.db.notes.connect import copy_marked_up_text
|
||||
from calibre.db.search import Search
|
||||
from calibre.db.tables import VirtualTable
|
||||
@ -51,9 +46,11 @@ from calibre.ebooks.metadata.book.base import Metadata
|
||||
from calibre.ebooks.metadata.opf2 import metadata_to_opf
|
||||
from calibre.ptempfile import PersistentTemporaryFile, SpooledTemporaryFile, base_dir
|
||||
from calibre.utils.config import prefs, tweaks
|
||||
from calibre.utils.date import UNDEFINED_DATE, now as nowf, utcnow
|
||||
from calibre.utils.date import UNDEFINED_DATE, utcnow
|
||||
from calibre.utils.date import now as nowf
|
||||
from calibre.utils.filenames import make_long_path_useable
|
||||
from calibre.utils.icu import lower as icu_lower, sort_key
|
||||
from calibre.utils.icu import lower as icu_lower
|
||||
from calibre.utils.icu import sort_key
|
||||
from calibre.utils.localization import canonicalize_lang
|
||||
from polyglot.builtins import cmp, iteritems, itervalues, string_or_bytes
|
||||
|
||||
|
@ -11,9 +11,9 @@ from functools import partial
|
||||
|
||||
from calibre.ebooks.metadata import author_to_author_sort
|
||||
from calibre.utils.config_base import prefs, tweaks
|
||||
from calibre.utils.icu import (
|
||||
collation_order, lower as icu_lower, sort_key, upper as icu_upper,
|
||||
)
|
||||
from calibre.utils.icu import collation_order, sort_key
|
||||
from calibre.utils.icu import lower as icu_lower
|
||||
from calibre.utils.icu import upper as icu_upper
|
||||
from polyglot.builtins import iteritems, native_string_type
|
||||
|
||||
CATEGORY_SORTS = ('name', 'popularity', 'rating') # This has to be a tuple not a set
|
||||
|
@ -8,10 +8,7 @@ from contextlib import contextmanager
|
||||
from optparse import OptionGroup, OptionValueError
|
||||
|
||||
from calibre import prints
|
||||
from calibre.db.adding import (
|
||||
cdb_find_in_dir, cdb_recursive_find, compile_rule, create_format_map,
|
||||
run_import_plugins, run_import_plugins_before_metadata
|
||||
)
|
||||
from calibre.db.adding import cdb_find_in_dir, cdb_recursive_find, compile_rule, create_format_map, run_import_plugins, run_import_plugins_before_metadata
|
||||
from calibre.db.utils import find_identical_books
|
||||
from calibre.ebooks.metadata import MetaInformation, string_to_authors
|
||||
from calibre.ebooks.metadata.book.serialize import read_cover, serialize_cover
|
||||
|
@ -5,11 +5,9 @@
|
||||
import os
|
||||
|
||||
from calibre.db.cli import integers_from_string
|
||||
from calibre.db.errors import NoSuchFormat
|
||||
from calibre.db.constants import DATA_FILE_PATTERN
|
||||
from calibre.library.save_to_disk import (
|
||||
config, do_save_book_to_disk, get_formats, sanitize_args
|
||||
)
|
||||
from calibre.db.errors import NoSuchFormat
|
||||
from calibre.library.save_to_disk import config, do_save_book_to_disk, get_formats, sanitize_args
|
||||
from calibre.utils.formatter_functions import load_user_template_functions
|
||||
|
||||
readonly = True
|
||||
|
@ -102,8 +102,8 @@ Do a full text search on the entire library or a subset of it.
|
||||
|
||||
|
||||
def output_results_as_text(results, metadata_cache, include_snippets):
|
||||
from calibre.utils.terminal import geometry
|
||||
from calibre.ebooks.metadata import authors_to_string
|
||||
from calibre.utils.terminal import geometry
|
||||
width = max(5, geometry()[0])
|
||||
separator = '─' * width
|
||||
if not include_snippets:
|
||||
|
@ -71,7 +71,7 @@ information is the equivalent of what is shown in the Tag browser.
|
||||
|
||||
|
||||
def do_list(fields, data, opts):
|
||||
from calibre.utils.terminal import geometry, ColoredStream
|
||||
from calibre.utils.terminal import ColoredStream, geometry
|
||||
|
||||
separator = ' '
|
||||
widths = list(map(lambda x: 0, fields))
|
||||
|
@ -3,6 +3,7 @@
|
||||
|
||||
|
||||
import sys
|
||||
|
||||
from calibre import prints
|
||||
from calibre.db.legacy import LibraryDatabase
|
||||
|
||||
|
@ -195,7 +195,8 @@ class DBCtx:
|
||||
|
||||
def remote_run(self, name, m, *args):
|
||||
from mechanize import HTTPError, Request
|
||||
from calibre.utils.serialize import msgpack_loads, msgpack_dumps
|
||||
|
||||
from calibre.utils.serialize import msgpack_dumps, msgpack_loads
|
||||
url = self.url + '/cdb/cmd/{}/{}'.format(name, getattr(m, 'version', 0))
|
||||
if self.library_id:
|
||||
url += '?' + urlencode({'library_id':self.library_id})
|
||||
|
@ -6,21 +6,20 @@ __copyright__ = '2011, Kovid Goyal <kovid@kovidgoyal.net>'
|
||||
__docformat__ = 'restructuredtext en'
|
||||
|
||||
import sys
|
||||
from threading import Lock
|
||||
from collections import defaultdict, Counter
|
||||
from collections import Counter, defaultdict
|
||||
from functools import partial
|
||||
from threading import Lock
|
||||
|
||||
from calibre.db.tables import ONE_ONE, MANY_ONE, MANY_MANY, null
|
||||
from calibre.db.tables import MANY_MANY, MANY_ONE, ONE_ONE, null
|
||||
from calibre.db.utils import atof, force_to_bool
|
||||
from calibre.db.write import Writer
|
||||
from calibre.db.utils import force_to_bool, atof
|
||||
from calibre.ebooks.metadata import title_sort, author_to_author_sort, rating_to_stars
|
||||
from calibre.ebooks.metadata import author_to_author_sort, rating_to_stars, title_sort
|
||||
from calibre.utils.config_base import tweaks
|
||||
from calibre.utils.icu import sort_key
|
||||
from calibre.utils.date import UNDEFINED_DATE, clean_date_for_sort, parse_date
|
||||
from calibre.utils.icu import sort_key
|
||||
from calibre.utils.localization import calibre_langcode_to_name
|
||||
from polyglot.builtins import iteritems
|
||||
|
||||
|
||||
rendering_composite_name = '__rendering_composite__'
|
||||
|
||||
|
||||
|
@ -2,14 +2,15 @@
|
||||
# License: GPL v3 Copyright: 2022, Kovid Goyal <kovid at kovidgoyal.net>
|
||||
|
||||
|
||||
import apsw
|
||||
import builtins
|
||||
import hashlib
|
||||
import os
|
||||
import sys
|
||||
from contextlib import suppress
|
||||
from threading import Lock
|
||||
from itertools import count
|
||||
from threading import Lock
|
||||
|
||||
import apsw
|
||||
|
||||
from calibre.db import FTSQueryError
|
||||
from calibre.db.annotations import unicode_normalize
|
||||
|
@ -6,11 +6,11 @@ __copyright__ = '2012, Kovid Goyal <kovid@kovidgoyal.net>'
|
||||
__docformat__ = 'restructuredtext en'
|
||||
|
||||
import weakref
|
||||
from functools import wraps
|
||||
from collections.abc import MutableMapping, MutableSequence
|
||||
from copy import deepcopy
|
||||
from functools import wraps
|
||||
|
||||
from calibre.ebooks.metadata.book.base import Metadata, SIMPLE_GET, TOP_LEVEL_IDENTIFIERS, NULL_VALUES, ALL_METADATA_FIELDS
|
||||
from calibre.ebooks.metadata.book.base import ALL_METADATA_FIELDS, NULL_VALUES, SIMPLE_GET, TOP_LEVEL_IDENTIFIERS, Metadata
|
||||
from calibre.ebooks.metadata.book.formatter import SafeFormat
|
||||
from calibre.utils.date import utcnow
|
||||
from polyglot.builtins import native_string_type
|
||||
|
@ -11,14 +11,10 @@ from collections.abc import MutableMapping
|
||||
|
||||
from calibre import force_unicode, isbytestring
|
||||
from calibre.constants import preferred_encoding
|
||||
from calibre.db import (
|
||||
_get_next_series_num_for_list, _get_series_values, get_data_as_dict,
|
||||
)
|
||||
from calibre.db.adding import (
|
||||
add_catalog, add_news, find_books_in_directory, import_book_directory,
|
||||
import_book_directory_multiple, recursive_import,
|
||||
)
|
||||
from calibre.db.backend import DB, set_global_state as backend_set_global_state
|
||||
from calibre.db import _get_next_series_num_for_list, _get_series_values, get_data_as_dict
|
||||
from calibre.db.adding import add_catalog, add_news, find_books_in_directory, import_book_directory, import_book_directory_multiple, recursive_import
|
||||
from calibre.db.backend import DB
|
||||
from calibre.db.backend import set_global_state as backend_set_global_state
|
||||
from calibre.db.cache import Cache
|
||||
from calibre.db.categories import CATEGORY_SORTS
|
||||
from calibre.db.errors import NoSuchFormat
|
||||
|
@ -3,9 +3,9 @@
|
||||
|
||||
import weakref
|
||||
from contextlib import suppress
|
||||
from enum import Enum, auto
|
||||
from queue import Queue
|
||||
from threading import Thread
|
||||
from enum import Enum, auto
|
||||
|
||||
|
||||
class EventType(Enum):
|
||||
|
@ -5,9 +5,11 @@ __license__ = 'GPL v3'
|
||||
__copyright__ = '2011, Kovid Goyal <kovid@kovidgoyal.net>'
|
||||
__docformat__ = 'restructuredtext en'
|
||||
|
||||
import traceback, sys, os
|
||||
from threading import Lock, Condition, current_thread
|
||||
import os
|
||||
import sys
|
||||
import traceback
|
||||
from contextlib import contextmanager
|
||||
from threading import Condition, Lock, current_thread
|
||||
|
||||
|
||||
@contextmanager
|
||||
|
@ -1,17 +1,18 @@
|
||||
#!/usr/bin/env python
|
||||
# License: GPLv3 Copyright: 2023, Kovid Goyal <kovid at kovidgoyal.net>
|
||||
|
||||
import apsw
|
||||
import json
|
||||
import os
|
||||
import shutil
|
||||
import time
|
||||
import xxhash
|
||||
from collections import defaultdict
|
||||
from contextlib import suppress
|
||||
from itertools import count, repeat
|
||||
from collections import defaultdict
|
||||
from typing import Optional
|
||||
|
||||
import apsw
|
||||
import xxhash
|
||||
|
||||
from calibre import sanitize_file_name
|
||||
from calibre.constants import iswindows
|
||||
from calibre.db import FTSQueryError
|
||||
@ -20,8 +21,8 @@ from calibre.utils.copy_files import WINDOWS_SLEEP_FOR_RETRY_TIME
|
||||
from calibre.utils.filenames import copyfile_using_links, make_long_path_useable
|
||||
from calibre.utils.icu import lower as icu_lower
|
||||
|
||||
from ..constants import NOTES_DB_NAME, NOTES_DIR_NAME
|
||||
from .schema_upgrade import SchemaUpgrade
|
||||
from ..constants import NOTES_DB_NAME, NOTES_DIR_NAME
|
||||
|
||||
if iswindows:
|
||||
from calibre_extensions import winutil
|
||||
|
@ -3,9 +3,10 @@
|
||||
|
||||
import base64
|
||||
import os
|
||||
from urllib.parse import unquote, urlparse
|
||||
|
||||
from html5_parser import parse
|
||||
from lxml import html
|
||||
from urllib.parse import unquote, urlparse
|
||||
|
||||
from calibre import guess_extension, guess_type
|
||||
from calibre.db.constants import RESOURCE_URL_SCHEME
|
||||
|
@ -18,8 +18,8 @@ from threading import Thread
|
||||
from calibre import force_unicode, isbytestring
|
||||
from calibre.constants import filesystem_encoding, iswindows
|
||||
from calibre.db.backend import DB, DBPrefs
|
||||
from calibre.db.constants import METADATA_FILE_NAME, TRASH_DIR_NAME, NOTES_DIR_NAME, NOTES_DB_NAME
|
||||
from calibre.db.cache import Cache
|
||||
from calibre.db.constants import METADATA_FILE_NAME, NOTES_DB_NAME, NOTES_DIR_NAME, TRASH_DIR_NAME
|
||||
from calibre.ebooks.metadata.opf2 import OPF
|
||||
from calibre.ptempfile import TemporaryDirectory
|
||||
from calibre.utils.date import utcfromtimestamp
|
||||
|
@ -8,7 +8,7 @@ __docformat__ = 'restructuredtext en'
|
||||
import os
|
||||
|
||||
from calibre import prints
|
||||
from calibre.utils.date import isoformat, DEFAULT_DATE
|
||||
from calibre.utils.date import DEFAULT_DATE, isoformat
|
||||
from polyglot.builtins import itervalues
|
||||
|
||||
|
||||
@ -590,8 +590,7 @@ class SchemaUpgrade:
|
||||
def upgrade_version_19(self):
|
||||
recipes = self.db.get('SELECT id,title,script FROM feeds')
|
||||
if recipes:
|
||||
from calibre.web.feeds.recipes import (custom_recipes,
|
||||
custom_recipe_filename)
|
||||
from calibre.web.feeds.recipes import custom_recipe_filename, custom_recipes
|
||||
bdir = os.path.dirname(custom_recipes.file_path)
|
||||
for id_, title, script in recipes:
|
||||
existing = frozenset(map(int, custom_recipes))
|
||||
|
@ -6,19 +6,19 @@ __copyright__ = '2013, Kovid Goyal <kovid at kovidgoyal.net>'
|
||||
__docformat__ = 'restructuredtext en'
|
||||
|
||||
import operator
|
||||
import regex
|
||||
import weakref
|
||||
from collections import OrderedDict, deque
|
||||
from datetime import timedelta
|
||||
from functools import partial
|
||||
|
||||
import regex
|
||||
|
||||
from calibre.constants import DEBUG, preferred_encoding
|
||||
from calibre.db.utils import force_to_bool
|
||||
from calibre.utils.config_base import prefs
|
||||
from calibre.utils.date import UNDEFINED_DATE, dt_as_local, now, parse_date
|
||||
from calibre.utils.icu import (
|
||||
lower as icu_lower, primary_contains, primary_no_punc_contains, sort_key,
|
||||
)
|
||||
from calibre.utils.icu import lower as icu_lower
|
||||
from calibre.utils.icu import primary_contains, primary_no_punc_contains, sort_key
|
||||
from calibre.utils.localization import canonicalize_lang, lang_map
|
||||
from calibre.utils.search_query_parser import ParseException, SearchQueryParser
|
||||
from polyglot.builtins import iteritems, string_or_bytes
|
||||
|
@ -5,7 +5,9 @@ __license__ = 'GPL v3'
|
||||
__copyright__ = '2013, Kovid Goyal <kovid at kovidgoyal.net>'
|
||||
__docformat__ = 'restructuredtext en'
|
||||
|
||||
import unittest, os, time
|
||||
import os
|
||||
import time
|
||||
import unittest
|
||||
from io import BytesIO
|
||||
|
||||
from calibre.constants import iswindows
|
||||
@ -174,7 +176,7 @@ class FilesystemTest(BaseTest):
|
||||
|
||||
# Test on folder with hardlinks
|
||||
from calibre.ptempfile import TemporaryDirectory
|
||||
from calibre.utils.filenames import hardlink_file, WindowsAtomicFolderMove
|
||||
from calibre.utils.filenames import WindowsAtomicFolderMove, hardlink_file
|
||||
raw = b'xxx'
|
||||
with TemporaryDirectory() as tdir1, TemporaryDirectory() as tdir2:
|
||||
a, b = os.path.join(tdir1, 'a'), os.path.join(tdir1, 'b')
|
||||
@ -296,7 +298,7 @@ class FilesystemTest(BaseTest):
|
||||
self.assertLess(abs(at-bt), 2)
|
||||
|
||||
def test_find_books_in_directory(self):
|
||||
from calibre.db.adding import find_books_in_directory, compile_rule
|
||||
from calibre.db.adding import compile_rule, find_books_in_directory
|
||||
def strip(files):
|
||||
return frozenset({os.path.basename(x) for x in files})
|
||||
|
||||
|
@ -6,6 +6,7 @@ import builtins
|
||||
import os
|
||||
import sys
|
||||
import tempfile
|
||||
|
||||
from apsw import Connection
|
||||
|
||||
from calibre.constants import plugins
|
||||
@ -71,7 +72,7 @@ class FTSTest(BaseTest):
|
||||
set_ui_language('en')
|
||||
|
||||
def test_fts_tokenize(self): # {{{
|
||||
from calibre_extensions.sqlite_extension import set_ui_language, FTS5_TOKENIZE_QUERY, FTS5_TOKENIZE_DOCUMENT
|
||||
from calibre_extensions.sqlite_extension import FTS5_TOKENIZE_DOCUMENT, FTS5_TOKENIZE_QUERY, set_ui_language
|
||||
|
||||
def t(x, s, e, f=0):
|
||||
return {'text': x, 'start': s, 'end': e, 'flags': f}
|
||||
|
@ -8,8 +8,8 @@ import shutil
|
||||
import sys
|
||||
import time
|
||||
from io import BytesIO, StringIO
|
||||
from zipfile import ZipFile
|
||||
from unittest.mock import patch
|
||||
from zipfile import ZipFile
|
||||
|
||||
from calibre.db.fts.text import html_to_text
|
||||
from calibre.db.tests.base import BaseTest
|
||||
@ -25,8 +25,8 @@ class FTSAPITest(BaseTest):
|
||||
|
||||
def setUp(self):
|
||||
super().setUp()
|
||||
from calibre_extensions.sqlite_extension import set_ui_language
|
||||
from calibre.db.cache import Cache
|
||||
from calibre_extensions.sqlite_extension import set_ui_language
|
||||
self.orig_sleep_time = Cache.fts_indexing_sleep_time
|
||||
Cache.fts_indexing_sleep_time = 0
|
||||
set_ui_language('en')
|
||||
@ -35,8 +35,8 @@ class FTSAPITest(BaseTest):
|
||||
def tearDown(self):
|
||||
[c.close() for c in self.libraries_to_close]
|
||||
super().tearDown()
|
||||
from calibre_extensions.sqlite_extension import set_ui_language
|
||||
from calibre.db.cache import Cache
|
||||
from calibre_extensions.sqlite_extension import set_ui_language
|
||||
Cache.fts_indexing_sleep_time = self.orig_sleep_time
|
||||
set_ui_language('en')
|
||||
|
||||
|
@ -4,10 +4,12 @@
|
||||
__license__ = 'GPL v3'
|
||||
__copyright__ = '2013, Kovid Goyal <kovid at kovidgoyal.net>'
|
||||
|
||||
import time, random
|
||||
import random
|
||||
import time
|
||||
from threading import Thread
|
||||
|
||||
from calibre.db.locking import LockingError, RWLockWrapper, SHLock
|
||||
from calibre.db.tests.base import BaseTest
|
||||
from calibre.db.locking import SHLock, RWLockWrapper, LockingError
|
||||
|
||||
|
||||
def wait_for(period):
|
||||
|
@ -4,7 +4,8 @@
|
||||
__license__ = 'GPL v3'
|
||||
__copyright__ = '2013, Kovid Goyal <kovid at kovidgoyal.net>'
|
||||
|
||||
import os, cProfile
|
||||
import cProfile
|
||||
import os
|
||||
from tempfile import gettempdir
|
||||
|
||||
from calibre.db.legacy import LibraryDatabase
|
||||
|
@ -5,13 +5,14 @@ __license__ = 'GPL v3'
|
||||
__copyright__ = '2011, Kovid Goyal <kovid@kovidgoyal.net>'
|
||||
__docformat__ = 'restructuredtext en'
|
||||
|
||||
import datetime, os
|
||||
import datetime
|
||||
import os
|
||||
from io import BytesIO
|
||||
from time import time
|
||||
|
||||
from calibre.db.tests.base import BaseTest
|
||||
from calibre.utils.date import utc_tz
|
||||
from calibre.utils.localization import calibre_langcode_to_name
|
||||
from calibre.db.tests.base import BaseTest
|
||||
from polyglot.builtins import iteritems, itervalues
|
||||
|
||||
|
||||
@ -244,8 +245,8 @@ class ReadingTest(BaseTest):
|
||||
# }}}
|
||||
|
||||
def test_serialize_metadata(self): # {{{
|
||||
from calibre.utils.serialize import json_dumps, json_loads, msgpack_dumps, msgpack_loads
|
||||
from calibre.library.field_metadata import fm_as_dict
|
||||
from calibre.utils.serialize import json_dumps, json_loads, msgpack_dumps, msgpack_loads
|
||||
cache = self.init_cache(self.library_path)
|
||||
fm = cache.field_metadata
|
||||
for d, l in ((json_dumps, json_loads), (msgpack_dumps, msgpack_loads)):
|
||||
@ -427,8 +428,8 @@ class ReadingTest(BaseTest):
|
||||
|
||||
def test_get_formats(self): # {{{
|
||||
'Test reading ebook formats using the format() method'
|
||||
from calibre.library.database2 import LibraryDatabase2
|
||||
from calibre.db.cache import NoSuchFormat
|
||||
from calibre.library.database2 import LibraryDatabase2
|
||||
old = LibraryDatabase2(self.library_path)
|
||||
ids = old.all_ids()
|
||||
lf = {i:set(old.formats(i, index_is_id=True).split(',')) if old.formats(
|
||||
@ -515,8 +516,8 @@ class ReadingTest(BaseTest):
|
||||
|
||||
def test_datetime(self): # {{{
|
||||
' Test the reading of datetimes stored in the db '
|
||||
from calibre.db.tables import UNDEFINED_DATE, _c_speedup, c_parse
|
||||
from calibre.utils.date import parse_date
|
||||
from calibre.db.tables import c_parse, UNDEFINED_DATE, _c_speedup
|
||||
|
||||
# First test parsing of string to UTC time
|
||||
for raw in ('2013-07-22 15:18:29+05:30', ' 2013-07-22 15:18:29+00:00', '2013-07-22 15:18:29', '2003-09-21 23:30:00-06:00'):
|
||||
@ -775,8 +776,8 @@ class ReadingTest(BaseTest):
|
||||
|
||||
def test_find_identical_books(self): # {{{
|
||||
' Test find_identical_books '
|
||||
from calibre.ebooks.metadata.book.base import Metadata
|
||||
from calibre.db.utils import find_identical_books
|
||||
from calibre.ebooks.metadata.book.base import Metadata
|
||||
# 'find_identical_books': [(,), (Metadata('unknown'),), (Metadata('xxxx'),)],
|
||||
cache = self.init_cache(self.library_path)
|
||||
cache.set_field('languages', {1: ('fra', 'deu')})
|
||||
@ -941,8 +942,7 @@ def evaluate(book, ctx):
|
||||
self.assertEqual(set(v.split(',')), {'Tag One', 'News', 'Tag Two'})
|
||||
|
||||
# test calling a python stored template from a GPM template
|
||||
from calibre.utils.formatter_functions import (
|
||||
load_user_template_functions, unload_user_template_functions)
|
||||
from calibre.utils.formatter_functions import load_user_template_functions, unload_user_template_functions
|
||||
load_user_template_functions('aaaaa',
|
||||
[['python_stored_template',
|
||||
"",
|
||||
|
@ -15,9 +15,7 @@ from locale import localeconv
|
||||
from threading import Lock
|
||||
|
||||
from calibre import as_unicode, prints
|
||||
from calibre.constants import (
|
||||
cache_dir, get_windows_number_formats, iswindows, preferred_encoding,
|
||||
)
|
||||
from calibre.constants import cache_dir, get_windows_number_formats, iswindows, preferred_encoding
|
||||
from calibre.utils.icu import lower as icu_lower
|
||||
from calibre.utils.localization import canonicalize_lang
|
||||
from polyglot.builtins import iteritems, itervalues, string_or_bytes
|
||||
|
@ -5,13 +5,16 @@ __license__ = 'GPL v3'
|
||||
__copyright__ = '2011, Kovid Goyal <kovid@kovidgoyal.net>'
|
||||
__docformat__ = 'restructuredtext en'
|
||||
|
||||
import weakref, operator, numbers, sys
|
||||
import numbers
|
||||
import operator
|
||||
import sys
|
||||
import weakref
|
||||
from functools import partial
|
||||
from polyglot.builtins import iteritems, itervalues
|
||||
|
||||
from calibre.ebooks.metadata import title_sort
|
||||
from calibre.utils.config_base import tweaks, prefs
|
||||
from calibre.db.write import uniq
|
||||
from calibre.ebooks.metadata import title_sort
|
||||
from calibre.utils.config_base import prefs, tweaks
|
||||
from polyglot.builtins import iteritems, itervalues
|
||||
|
||||
|
||||
def sanitize_sort_field_name(field_metadata, field):
|
||||
|
@ -11,10 +11,9 @@ from functools import partial
|
||||
|
||||
from calibre.constants import preferred_encoding
|
||||
from calibre.ebooks.metadata import author_to_author_sort, title_sort
|
||||
from calibre.utils.date import (
|
||||
UNDEFINED_DATE, is_date_undefined, isoformat, parse_date, parse_only_date,
|
||||
)
|
||||
from calibre.utils.icu import lower as icu_lower, strcmp
|
||||
from calibre.utils.date import UNDEFINED_DATE, is_date_undefined, isoformat, parse_date, parse_only_date
|
||||
from calibre.utils.icu import lower as icu_lower
|
||||
from calibre.utils.icu import strcmp
|
||||
from calibre.utils.localization import canonicalize_lang
|
||||
from polyglot.builtins import iteritems, itervalues
|
||||
|
||||
|
@ -7,11 +7,14 @@ __copyright__ = '2008, Kovid Goyal <kovid at kovidgoyal.net>'
|
||||
Embedded console for debugging.
|
||||
'''
|
||||
|
||||
import sys, os, functools
|
||||
from calibre.utils.config import OptionParser
|
||||
from calibre.constants import iswindows
|
||||
import functools
|
||||
import os
|
||||
import sys
|
||||
|
||||
from calibre import prints
|
||||
from calibre.constants import iswindows
|
||||
from calibre.startup import get_debug_executable
|
||||
from calibre.utils.config import OptionParser
|
||||
from polyglot.builtins import exec_path
|
||||
|
||||
|
||||
@ -132,7 +135,9 @@ def debug_device_driver():
|
||||
|
||||
|
||||
def add_simple_plugin(path_to_plugin):
|
||||
import tempfile, zipfile, shutil
|
||||
import shutil
|
||||
import tempfile
|
||||
import zipfile
|
||||
tdir = tempfile.mkdtemp()
|
||||
open(os.path.join(tdir, 'custom_plugin.py'),
|
||||
'wb').write(open(path_to_plugin, 'rb').read())
|
||||
@ -152,8 +157,8 @@ def print_basic_debug_info(out=None):
|
||||
out = sys.stdout
|
||||
out = functools.partial(prints, file=out)
|
||||
import platform
|
||||
from calibre.constants import (__appname__, get_version, isportable, ismacos,
|
||||
isfrozen)
|
||||
|
||||
from calibre.constants import __appname__, get_version, isfrozen, ismacos, isportable
|
||||
from calibre.utils.localization import set_translators
|
||||
out(__appname__, get_version(), 'Portable' if isportable else '',
|
||||
'embedded-python:', isfrozen)
|
||||
|
@ -5,7 +5,9 @@ __copyright__ = '2008, Kovid Goyal <kovid at kovidgoyal.net>'
|
||||
Device drivers.
|
||||
'''
|
||||
|
||||
import sys, time, pprint
|
||||
import pprint
|
||||
import sys
|
||||
import time
|
||||
from functools import partial
|
||||
|
||||
DAY_MAP = dict(Sun=0, Mon=1, Tue=2, Wed=3, Thu=4, Fri=5, Sat=6)
|
||||
@ -67,11 +69,12 @@ def debug(ioreg_to_tmp=False, buf=None, plugins=None,
|
||||
device plugins as the plugins parameter.
|
||||
'''
|
||||
import textwrap
|
||||
|
||||
from calibre import prints
|
||||
from calibre.constants import debug, is_debugging, ismacos, iswindows
|
||||
from calibre.customize.ui import device_plugins, disabled_device_plugins
|
||||
from calibre.debug import print_basic_debug_info
|
||||
from calibre.devices.scanner import DeviceScanner
|
||||
from calibre.constants import iswindows, ismacos, debug, is_debugging
|
||||
from calibre import prints
|
||||
from polyglot.io import PolyglotStringIO
|
||||
oldo, olde = sys.stdout, sys.stderr
|
||||
|
||||
|
@ -9,12 +9,14 @@ Provides a command-line interface to ebook devices.
|
||||
For usage information run the script.
|
||||
"""
|
||||
|
||||
import sys, time, os
|
||||
import os
|
||||
import sys
|
||||
import time
|
||||
from optparse import OptionParser
|
||||
|
||||
from calibre import __version__, __appname__, human_readable, fsync, prints
|
||||
from calibre.devices.errors import ArgumentError, DeviceError, DeviceLocked
|
||||
from calibre import __appname__, __version__, fsync, human_readable, prints
|
||||
from calibre.customize.ui import device_plugins
|
||||
from calibre.devices.errors import ArgumentError, DeviceError, DeviceLocked
|
||||
from calibre.devices.scanner import DeviceScanner
|
||||
from calibre.utils.config import device_prefs
|
||||
from polyglot.io import PolyglotStringIO
|
||||
|
@ -9,11 +9,11 @@ Device driver for Bookeen's Cybook Gen 3 and Opus and Orizon
|
||||
import os
|
||||
import re
|
||||
|
||||
import calibre.devices.cybook.t2b as t2b
|
||||
import calibre.devices.cybook.t4b as t4b
|
||||
from calibre import fsync
|
||||
from calibre.constants import isunix
|
||||
from calibre.devices.usbms.driver import USBMS
|
||||
import calibre.devices.cybook.t2b as t2b
|
||||
import calibre.devices.cybook.t4b as t4b
|
||||
|
||||
|
||||
class CYBOOK(USBMS):
|
||||
|
File diff suppressed because one or more lines are too long
@ -5,7 +5,8 @@ __docformat__ = 'restructuredtext en'
|
||||
'''
|
||||
Device driver for Hanvon devices
|
||||
'''
|
||||
import re, os
|
||||
import os
|
||||
import re
|
||||
|
||||
from calibre import fsync
|
||||
from calibre.devices.usbms.driver import USBMS
|
||||
|
@ -2,7 +2,7 @@ __license__ = 'GPL v3'
|
||||
__copyright__ = '2011, John Schember <john at nachtimwald.com>, refactored: 2022, Vaso Peras-Likodric <vaso at vipl.in.rs>'
|
||||
__docformat__ = 'restructuredtext en'
|
||||
|
||||
from typing import Optional, Dict
|
||||
from typing import Dict, Optional
|
||||
|
||||
'''
|
||||
Generates and writes an APNX page mapping file.
|
||||
@ -10,19 +10,18 @@ Generates and writes an APNX page mapping file.
|
||||
|
||||
import struct
|
||||
|
||||
from calibre.ebooks.pdb.header import PdbHeaderReader
|
||||
from calibre.ebooks.mobi.reader.headers import MetadataHeader
|
||||
from calibre.utils.logging import default_log
|
||||
from calibre import prints, fsync
|
||||
from calibre import fsync, prints
|
||||
from calibre.constants import DEBUG
|
||||
from polyglot.builtins import as_unicode, as_bytes
|
||||
|
||||
from calibre.devices.kindle.apnx_page_generator.generators.accurate_page_generator import AccuratePageGenerator
|
||||
from calibre.devices.kindle.apnx_page_generator.generators.pagebreak_page_generator import PagebreakPageGenerator
|
||||
from calibre.devices.kindle.apnx_page_generator.generators.exact_page_generator import ExactPageGenerator
|
||||
from calibre.devices.kindle.apnx_page_generator.generators.fast_page_generator import FastPageGenerator
|
||||
from calibre.devices.kindle.apnx_page_generator.generators.pagebreak_page_generator import PagebreakPageGenerator
|
||||
from calibre.devices.kindle.apnx_page_generator.i_page_generator import IPageGenerator
|
||||
from calibre.devices.kindle.apnx_page_generator.pages import Pages
|
||||
from calibre.ebooks.mobi.reader.headers import MetadataHeader
|
||||
from calibre.ebooks.pdb.header import PdbHeaderReader
|
||||
from calibre.utils.logging import default_log
|
||||
from polyglot.builtins import as_bytes, as_unicode
|
||||
|
||||
|
||||
class APNXBuilder:
|
||||
|
@ -2,12 +2,12 @@ __license__ = 'GPL v3'
|
||||
__copyright__ = '2022, Vaso Peras-Likodric <vaso at vipl.in.rs>'
|
||||
__docformat__ = 'restructuredtext en'
|
||||
|
||||
import re
|
||||
from typing import Optional
|
||||
|
||||
from calibre.devices.kindle.apnx_page_generator.generators.fast_page_generator import FastPageGenerator
|
||||
from calibre.devices.kindle.apnx_page_generator.i_page_generator import IPageGenerator, mobi_html
|
||||
from calibre.devices.kindle.apnx_page_generator.pages import Pages
|
||||
import re
|
||||
|
||||
|
||||
class PagebreakPageGenerator(IPageGenerator):
|
||||
|
@ -3,13 +3,13 @@ __copyright__ = '2022, Vaso Peras-Likodric <vaso at vipl.in.rs>'
|
||||
__docformat__ = 'restructuredtext en'
|
||||
|
||||
import struct
|
||||
from abc import abstractmethod, ABCMeta
|
||||
from abc import ABCMeta, abstractmethod
|
||||
from typing import Optional
|
||||
|
||||
from calibre.devices.kindle.apnx_page_generator.pages import Pages
|
||||
from calibre.ebooks.pdb.header import PdbHeaderReader
|
||||
from calibre.utils.logging import default_log
|
||||
from polyglot.builtins import as_bytes
|
||||
from calibre.ebooks.pdb.header import PdbHeaderReader
|
||||
|
||||
|
||||
class IPageGenerator(metaclass=ABCMeta):
|
||||
|
@ -2,7 +2,7 @@ __license__ = 'GPL v3'
|
||||
__copyright__ = '2022, Vaso Peras-Likodric <vaso at vipl.in.rs>'
|
||||
__docformat__ = 'restructuredtext en'
|
||||
|
||||
from typing import Union, List, Tuple
|
||||
from typing import List, Tuple, Union
|
||||
|
||||
from calibre.devices.kindle.apnx_page_generator.page_number_type import PageNumberTypes
|
||||
|
||||
|
@ -3,7 +3,7 @@ __copyright__ = '2022, Vaso Peras-Likodric <vaso at vipl.in.rs>'
|
||||
__docformat__ = 'restructuredtext en'
|
||||
|
||||
import itertools
|
||||
from typing import Optional, List
|
||||
from typing import List, Optional
|
||||
|
||||
from calibre.devices.kindle.apnx_page_generator.page_group import PageGroup
|
||||
from calibre.devices.kindle.apnx_page_generator.page_number_type import PageNumberTypes
|
||||
|
@ -1,8 +1,8 @@
|
||||
__license__ = 'GPL v3'
|
||||
__docformat__ = 'restructuredtext en'
|
||||
|
||||
import os
|
||||
import io
|
||||
import os
|
||||
from struct import unpack
|
||||
|
||||
|
||||
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
x
Reference in New Issue
Block a user