Fixed problem using Python 3.6

- ZipFile's compresslevel argument introduced in 3.7
This commit is contained in:
Salvador E. Tropea 2021-02-16 12:54:33 -03:00
parent 95b48ab053
commit 2b845d81a0
3 changed files with 17 additions and 1 deletions

View File

@ -7,6 +7,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
## [Unreleased]
## [0.10.0-4] - 2021-02-16
### Fixed
- Problem using Python 3.6 (ZipFile's compresslevel arg needs 3.7)
## [0.10.0-3] - 2021-02-16
### Fixed
- Problem using Python 3.6 (StreamHandler.setStream introduced in 3.7)

7
debian/changelog vendored
View File

@ -1,3 +1,10 @@
kibot (0.10.0-4) stable; urgency=medium
* Fixed problem using Python 3.6
(ZipFile's compresslevel argument introduced in 3.7)
-- Salvador E. Tropea <salvador@inti.gob.ar> Tue, 16 Feb 2021 12:51:24 -0300
kibot (0.10.0-3) stable; urgency=medium
* Fixed problem using Python 3.6 (#52)

View File

@ -6,6 +6,7 @@
import re
import os
import glob
import sys
from sys import exit
from subprocess import check_output, STDOUT, CalledProcessError
from zipfile import ZipFile, ZIP_STORED, ZIP_DEFLATED, ZIP_BZIP2, ZIP_LZMA
@ -68,7 +69,11 @@ class CompressOptions(BaseOptions):
logger.warning(W_EMPTYZIP+'No files provided, creating an empty archive')
def create_zip(self, output, files):
with ZipFile(output, 'w', compression=self.ZIP_ALGORITHMS[self.compression], compresslevel=9) as zip:
extra = {}
extra['compression'] = self.ZIP_ALGORITHMS[self.compression]
if sys.version_info.major > 3 or (sys.version_info.major == 3 and sys.version_info.minor >= 7):
extra['compresslevel'] = 9
with ZipFile(output, 'w', **extra) as zip:
for fname, dest in files.items():
logger.debug('Adding '+fname+' as '+dest)
zip.write(fname, dest)