diff --git a/src/calibre/customize/builtins.py b/src/calibre/customize/builtins.py index 5fdddbf190..1b2d37299d 100644 --- a/src/calibre/customize/builtins.py +++ b/src/calibre/customize/builtins.py @@ -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') diff --git a/src/calibre/devices/apple/driver.py b/src/calibre/devices/apple/driver.py index e4b21fce8f..61c4654a32 100644 --- a/src/calibre/devices/apple/driver.py +++ b/src/calibre/devices/apple/driver.py @@ -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) diff --git a/src/calibre/ebooks/conversion/plugins/pml_input.py b/src/calibre/ebooks/conversion/plugins/pml_input.py index 63e22271f6..b61ac2116c 100644 --- a/src/calibre/ebooks/conversion/plugins/pml_input.py +++ b/src/calibre/ebooks/conversion/plugins/pml_input.py @@ -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 diff --git a/src/calibre/ebooks/metadata/sources/ozon.py b/src/calibre/ebooks/metadata/sources/ozon.py index b630910e15..627c7830c1 100644 --- a/src/calibre/ebooks/metadata/sources/ozon.py +++ b/src/calibre/ebooks/metadata/sources/ozon.py @@ -389,33 +389,34 @@ def _get_affiliateId(): # {{{ 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): # {{{ + # 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) if res: m = isbn_pat.match(res)