diff --git a/docs/tutorial.rst b/docs/tutorial.rst index f2224b0..5381816 100644 --- a/docs/tutorial.rst +++ b/docs/tutorial.rst @@ -298,12 +298,15 @@ pages_title "Pages" spine_direction True package_direction False play_order {'enabled': False, 'start_from': 1} +compresslevel 6 ================= ==================================== In the future version default value for ignore_ncx will be changed. According to the documentation default behaviour should be "EPUB 3 Reading Systems must ignore the NCX in favor of the EPUB Navigation Document". Because we have been doing wrong this all time we will keep the default behavior to prepare for the change. +compresslevel goes from 0 to 9, where 0 is no compression. + Example when overriding default options: :: diff --git a/ebooklib/epub.py b/ebooklib/epub.py index 866bf50..84b3617 100644 --- a/ebooklib/epub.py +++ b/ebooklib/epub.py @@ -870,7 +870,8 @@ class EpubWriter(object): 'play_order': { 'enabled': False, 'start_from': 1 - } + }, + 'compresslevel': 6 } def __init__(self, name, book, options=None): @@ -1363,7 +1364,7 @@ def _write_items(self): def write(self): # check for the option allowZip64 - self.out = zipfile.ZipFile(self.file_name, 'w', zipfile.ZIP_DEFLATED) + self.out = zipfile.ZipFile(self.file_name, 'w', zipfile.ZIP_DEFLATED, compresslevel=self.options['compresslevel']) self.out.writestr('mimetype', 'application/epub+zip', compress_type=zipfile.ZIP_STORED) self._write_container() diff --git a/setup.py b/setup.py index 2589c77..c2e4523 100644 --- a/setup.py +++ b/setup.py @@ -32,6 +32,7 @@ def read(path): "Programming Language :: Python :: 3.4", "Programming Language :: Python :: 3.5", "Programming Language :: Python :: 3.6", + "Programming Language :: Python :: 3.7", "Topic :: Software Development :: Libraries :: Python Modules" ], install_requires = [