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',
|
for x in ('lxml', 'calibre.ebooks.BeautifulSoup', 'uuid',
|
||||||
'calibre.utils.terminal', 'calibre.utils.magick', 'PIL', 'Image',
|
'calibre.utils.terminal', 'calibre.utils.magick', 'PIL', 'Image',
|
||||||
'sqlite3', 'mechanize', 'httplib', 'xml', 'inspect', 'urllib',
|
'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:
|
if x in sys.modules:
|
||||||
ret = 1
|
ret = 1
|
||||||
print (x, 'has been loaded by a plugin')
|
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)
|
MetaInformation, title_sort)
|
||||||
from calibre.ebooks.metadata.book.base import Metadata
|
from calibre.ebooks.metadata.book.base import Metadata
|
||||||
from calibre.utils.config_base import config_dir, prefs
|
from calibre.utils.config_base import config_dir, prefs
|
||||||
from calibre.utils.zipfile import ZipFile
|
|
||||||
|
|
||||||
DEBUG = CALIBRE_DEBUG
|
DEBUG = CALIBRE_DEBUG
|
||||||
|
|
||||||
@ -862,6 +861,7 @@ class ITUNES(DriverBase):
|
|||||||
Note that most of the initialization is necessarily performed in can_handle(), as
|
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
|
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:
|
if self.iTunes is None:
|
||||||
raise OpenFeedback(self.ITUNES_SANDBOX_LOCKOUT_MESSAGE)
|
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
|
NB: This will not find books that were added by a different installation of calibre
|
||||||
as uuids are different
|
as uuids are different
|
||||||
'''
|
'''
|
||||||
|
from calibre.utils.zipfile import ZipFile
|
||||||
if DEBUG:
|
if DEBUG:
|
||||||
logger().info("%s.remove_books_from_metadata()" % self.__class__.__name__)
|
logger().info("%s.remove_books_from_metadata()" % self.__class__.__name__)
|
||||||
for path in paths:
|
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
|
as of iTunes 9.2, iBooks 1.1, can't set artwork for PDF files via automation
|
||||||
'''
|
'''
|
||||||
from PIL import Image as PILImage
|
from PIL import Image as PILImage
|
||||||
|
from calibre.utils.zipfile import ZipFile
|
||||||
|
|
||||||
if DEBUG:
|
if DEBUG:
|
||||||
logger().info(" %s._cover_to_thumb()" % self.__class__.__name__)
|
logger().info(" %s._cover_to_thumb()" % self.__class__.__name__)
|
||||||
@ -1765,6 +1767,7 @@ class ITUNES(DriverBase):
|
|||||||
'''
|
'''
|
||||||
'''
|
'''
|
||||||
from calibre.ebooks.BeautifulSoup import BeautifulSoup
|
from calibre.ebooks.BeautifulSoup import BeautifulSoup
|
||||||
|
from calibre.utils.zipfile import ZipFile
|
||||||
|
|
||||||
logger().info(" %s.__get_epub_metadata()" % self.__class__.__name__)
|
logger().info(" %s.__get_epub_metadata()" % self.__class__.__name__)
|
||||||
title = None
|
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
|
as of iTunes 9.2, iBooks 1.1, can't set artwork for PDF files via automation
|
||||||
'''
|
'''
|
||||||
from PIL import Image as PILImage
|
from PIL import Image as PILImage
|
||||||
|
from calibre.utils.zipfile import ZipFile
|
||||||
|
|
||||||
if not self.settings().extra_customization[self.CACHE_COVERS]:
|
if not self.settings().extra_customization[self.CACHE_COVERS]:
|
||||||
thumb_data = None
|
thumb_data = None
|
||||||
@ -2130,6 +2134,7 @@ class ITUNES(DriverBase):
|
|||||||
'''
|
'''
|
||||||
Calculate the exploded size of file
|
Calculate the exploded size of file
|
||||||
'''
|
'''
|
||||||
|
from calibre.utils.zipfile import ZipFile
|
||||||
exploded_file_size = compressed_size
|
exploded_file_size = compressed_size
|
||||||
format = file.rpartition('.')[2].lower()
|
format = file.rpartition('.')[2].lower()
|
||||||
if format == 'epub':
|
if format == 'epub':
|
||||||
@ -2784,6 +2789,7 @@ class ITUNES(DriverBase):
|
|||||||
from calibre.utils.date import parse_date, now
|
from calibre.utils.date import parse_date, now
|
||||||
from calibre.ebooks.metadata.epub import set_metadata
|
from calibre.ebooks.metadata.epub import set_metadata
|
||||||
from lxml import etree
|
from lxml import etree
|
||||||
|
from calibre.utils.zipfile import ZipFile
|
||||||
|
|
||||||
if DEBUG:
|
if DEBUG:
|
||||||
logger().info(" %s._update_epub_metadata()" % self.__class__.__name__)
|
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
|
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
|
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:
|
if self.iTunes is None:
|
||||||
raise OpenFeedback(self.ITUNES_SANDBOX_LOCKOUT_MESSAGE)
|
raise OpenFeedback(self.ITUNES_SANDBOX_LOCKOUT_MESSAGE)
|
||||||
|
|
||||||
|
@ -10,7 +10,6 @@ import shutil
|
|||||||
|
|
||||||
from calibre.customize.conversion import InputFormatPlugin
|
from calibre.customize.conversion import InputFormatPlugin
|
||||||
from calibre.ptempfile import TemporaryDirectory
|
from calibre.ptempfile import TemporaryDirectory
|
||||||
from calibre.utils.zipfile import ZipFile
|
|
||||||
|
|
||||||
class PMLInput(InputFormatPlugin):
|
class PMLInput(InputFormatPlugin):
|
||||||
|
|
||||||
@ -86,6 +85,7 @@ class PMLInput(InputFormatPlugin):
|
|||||||
accelerators):
|
accelerators):
|
||||||
from calibre.ebooks.metadata.toc import TOC
|
from calibre.ebooks.metadata.toc import TOC
|
||||||
from calibre.ebooks.metadata.opf2 import OPFCreator
|
from calibre.ebooks.metadata.opf2 import OPFCreator
|
||||||
|
from calibre.utils.zipfile import ZipFile
|
||||||
|
|
||||||
self.options = options
|
self.options = options
|
||||||
self.log = log
|
self.log = log
|
||||||
|
@ -389,6 +389,7 @@ def _get_affiliateId(): # {{{
|
|||||||
return aff_id
|
return aff_id
|
||||||
# }}}
|
# }}}
|
||||||
|
|
||||||
|
def _format_isbn(log, isbn): # {{{
|
||||||
# for now only RUS ISBN are supported
|
# for now only RUS ISBN are supported
|
||||||
#http://ru.wikipedia.org/wiki/ISBN_российских_издательств
|
#http://ru.wikipedia.org/wiki/ISBN_российских_издательств
|
||||||
isbn_pat = re.compile(r"""
|
isbn_pat = re.compile(r"""
|
||||||
@ -415,7 +416,7 @@ isbn_pat = re.compile(r"""
|
|||||||
$
|
$
|
||||||
""", re.VERBOSE)
|
""", re.VERBOSE)
|
||||||
|
|
||||||
def _format_isbn(log, isbn): # {{{
|
|
||||||
res = check_isbn(isbn)
|
res = check_isbn(isbn)
|
||||||
if res:
|
if res:
|
||||||
m = isbn_pat.match(res)
|
m = isbn_pat.match(res)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user