mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
delay load utils.zipfile
This commit is contained in:
parent
dbe7302f7b
commit
6ed5f6d86b
@ -1762,7 +1762,9 @@ if __name__ == '__main__':
|
||||
for x in ('lxml', 'calibre.ebooks.BeautifulSoup', 'uuid',
|
||||
'calibre.utils.terminal', 'calibre.utils.magick', 'PIL', 'Image',
|
||||
'sqlite3', 'mechanize', 'httplib', 'xml', 'inspect', 'urllib',
|
||||
'calibre.utils.date', 'calibre.utils.config', 'platform'):
|
||||
'calibre.utils.date', 'calibre.utils.config', 'platform',
|
||||
'calibre.utils.zipfile',
|
||||
):
|
||||
if x in sys.modules:
|
||||
ret = 1
|
||||
print (x, 'has been loaded by a plugin')
|
||||
|
@ -18,7 +18,6 @@ from calibre.ebooks.metadata import (author_to_author_sort, authors_to_string,
|
||||
MetaInformation, title_sort)
|
||||
from calibre.ebooks.metadata.book.base import Metadata
|
||||
from calibre.utils.config_base import config_dir, prefs
|
||||
from calibre.utils.zipfile import ZipFile
|
||||
|
||||
DEBUG = CALIBRE_DEBUG
|
||||
|
||||
@ -862,6 +861,7 @@ class ITUNES(DriverBase):
|
||||
Note that most of the initialization is necessarily performed in can_handle(), as
|
||||
we need to talk to iTunes to discover if there's a connected iPod
|
||||
'''
|
||||
from calibre.utils.zipfile import ZipFile
|
||||
if self.iTunes is None:
|
||||
raise OpenFeedback(self.ITUNES_SANDBOX_LOCKOUT_MESSAGE)
|
||||
|
||||
@ -933,6 +933,7 @@ class ITUNES(DriverBase):
|
||||
NB: This will not find books that were added by a different installation of calibre
|
||||
as uuids are different
|
||||
'''
|
||||
from calibre.utils.zipfile import ZipFile
|
||||
if DEBUG:
|
||||
logger().info("%s.remove_books_from_metadata()" % self.__class__.__name__)
|
||||
for path in paths:
|
||||
@ -1432,6 +1433,7 @@ class ITUNES(DriverBase):
|
||||
as of iTunes 9.2, iBooks 1.1, can't set artwork for PDF files via automation
|
||||
'''
|
||||
from PIL import Image as PILImage
|
||||
from calibre.utils.zipfile import ZipFile
|
||||
|
||||
if DEBUG:
|
||||
logger().info(" %s._cover_to_thumb()" % self.__class__.__name__)
|
||||
@ -1765,6 +1767,7 @@ class ITUNES(DriverBase):
|
||||
'''
|
||||
'''
|
||||
from calibre.ebooks.BeautifulSoup import BeautifulSoup
|
||||
from calibre.utils.zipfile import ZipFile
|
||||
|
||||
logger().info(" %s.__get_epub_metadata()" % self.__class__.__name__)
|
||||
title = None
|
||||
@ -2018,6 +2021,7 @@ class ITUNES(DriverBase):
|
||||
as of iTunes 9.2, iBooks 1.1, can't set artwork for PDF files via automation
|
||||
'''
|
||||
from PIL import Image as PILImage
|
||||
from calibre.utils.zipfile import ZipFile
|
||||
|
||||
if not self.settings().extra_customization[self.CACHE_COVERS]:
|
||||
thumb_data = None
|
||||
@ -2130,6 +2134,7 @@ class ITUNES(DriverBase):
|
||||
'''
|
||||
Calculate the exploded size of file
|
||||
'''
|
||||
from calibre.utils.zipfile import ZipFile
|
||||
exploded_file_size = compressed_size
|
||||
format = file.rpartition('.')[2].lower()
|
||||
if format == 'epub':
|
||||
@ -2784,6 +2789,7 @@ class ITUNES(DriverBase):
|
||||
from calibre.utils.date import parse_date, now
|
||||
from calibre.ebooks.metadata.epub import set_metadata
|
||||
from lxml import etree
|
||||
from calibre.utils.zipfile import ZipFile
|
||||
|
||||
if DEBUG:
|
||||
logger().info(" %s._update_epub_metadata()" % self.__class__.__name__)
|
||||
@ -3425,6 +3431,7 @@ class ITUNES_ASYNC(ITUNES):
|
||||
Note that most of the initialization is necessarily performed in can_handle(), as
|
||||
we need to talk to iTunes to discover if there's a connected iPod
|
||||
'''
|
||||
from calibre.utils.zipfile import ZipFile
|
||||
if self.iTunes is None:
|
||||
raise OpenFeedback(self.ITUNES_SANDBOX_LOCKOUT_MESSAGE)
|
||||
|
||||
|
@ -10,7 +10,6 @@ import shutil
|
||||
|
||||
from calibre.customize.conversion import InputFormatPlugin
|
||||
from calibre.ptempfile import TemporaryDirectory
|
||||
from calibre.utils.zipfile import ZipFile
|
||||
|
||||
class PMLInput(InputFormatPlugin):
|
||||
|
||||
@ -86,6 +85,7 @@ class PMLInput(InputFormatPlugin):
|
||||
accelerators):
|
||||
from calibre.ebooks.metadata.toc import TOC
|
||||
from calibre.ebooks.metadata.opf2 import OPFCreator
|
||||
from calibre.utils.zipfile import ZipFile
|
||||
|
||||
self.options = options
|
||||
self.log = log
|
||||
|
@ -389,9 +389,10 @@ def _get_affiliateId(): # {{{
|
||||
return aff_id
|
||||
# }}}
|
||||
|
||||
# for now only RUS ISBN are supported
|
||||
#http://ru.wikipedia.org/wiki/ISBN_российских_издательств
|
||||
isbn_pat = re.compile(r"""
|
||||
def _format_isbn(log, isbn): # {{{
|
||||
# for now only RUS ISBN are supported
|
||||
#http://ru.wikipedia.org/wiki/ISBN_российских_издательств
|
||||
isbn_pat = re.compile(r"""
|
||||
^
|
||||
(\d{3})? # match GS1 Prefix for ISBN13
|
||||
(5) # group identifier for rRussian-speaking countries
|
||||
@ -413,9 +414,9 @@ isbn_pat = re.compile(r"""
|
||||
(\d+) # Title
|
||||
([\dX]) # Check digit
|
||||
$
|
||||
""", re.VERBOSE)
|
||||
""", re.VERBOSE)
|
||||
|
||||
|
||||
def _format_isbn(log, isbn): # {{{
|
||||
res = check_isbn(isbn)
|
||||
if res:
|
||||
m = isbn_pat.match(res)
|
||||
|
Loading…
x
Reference in New Issue
Block a user