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,33 +389,34 @@ def _get_affiliateId(): # {{{
|
|||||||
return aff_id
|
return aff_id
|
||||||
# }}}
|
# }}}
|
||||||
|
|
||||||
# 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
|
|
||||||
( # begin variable length for Publisher
|
|
||||||
[01]\d{1}| # 2x
|
|
||||||
[2-6]\d{2}| # 3x
|
|
||||||
7\d{3}| # 4x (starting with 7)
|
|
||||||
8[0-4]\d{2}| # 4x (starting with 8)
|
|
||||||
9[2567]\d{2}| # 4x (starting with 9)
|
|
||||||
99[26]\d{1}| # 4x (starting with 99)
|
|
||||||
8[5-9]\d{3}| # 5x (starting with 8)
|
|
||||||
9[348]\d{3}| # 5x (starting with 9)
|
|
||||||
900\d{2}| # 5x (starting with 900)
|
|
||||||
91[0-8]\d{2}| # 5x (starting with 91)
|
|
||||||
90[1-9]\d{3}| # 6x (starting with 90)
|
|
||||||
919\d{3}| # 6x (starting with 919)
|
|
||||||
99[^26]\d{4} # 7x (starting with 99)
|
|
||||||
) # end variable length for Publisher
|
|
||||||
(\d+) # Title
|
|
||||||
([\dX]) # Check digit
|
|
||||||
$
|
|
||||||
""", re.VERBOSE)
|
|
||||||
|
|
||||||
def _format_isbn(log, isbn): # {{{
|
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
|
||||||
|
( # begin variable length for Publisher
|
||||||
|
[01]\d{1}| # 2x
|
||||||
|
[2-6]\d{2}| # 3x
|
||||||
|
7\d{3}| # 4x (starting with 7)
|
||||||
|
8[0-4]\d{2}| # 4x (starting with 8)
|
||||||
|
9[2567]\d{2}| # 4x (starting with 9)
|
||||||
|
99[26]\d{1}| # 4x (starting with 99)
|
||||||
|
8[5-9]\d{3}| # 5x (starting with 8)
|
||||||
|
9[348]\d{3}| # 5x (starting with 9)
|
||||||
|
900\d{2}| # 5x (starting with 900)
|
||||||
|
91[0-8]\d{2}| # 5x (starting with 91)
|
||||||
|
90[1-9]\d{3}| # 6x (starting with 90)
|
||||||
|
919\d{3}| # 6x (starting with 919)
|
||||||
|
99[^26]\d{4} # 7x (starting with 99)
|
||||||
|
) # end variable length for Publisher
|
||||||
|
(\d+) # Title
|
||||||
|
([\dX]) # Check digit
|
||||||
|
$
|
||||||
|
""", re.VERBOSE)
|
||||||
|
|
||||||
|
|
||||||
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