From f74046fb09401facbece39056dd53dafe3f814e9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Christopher=20Ram=C3=ADrez?= Date: Fri, 14 Jul 2017 12:11:40 -0600 Subject: [PATCH] Fix bug storing mimefiles. --- secretary.py | 13 +++++++------ tox.ini | 2 +- 2 files changed, 8 insertions(+), 7 deletions(-) diff --git a/secretary.py b/secretary.py index c0277b7..760be55 100644 --- a/secretary.py +++ b/secretary.py @@ -180,15 +180,16 @@ class Renderer(object): mimetype = files['mimetype'] del files['mimetype'] - zipdoc = zipfile.ZipFile(zip_file, 'a') + zipdoc = zipfile.ZipFile(zip_file, 'a', zipfile.ZIP_DEFLATED) - zipdoc.writestr('mimetype', mimetype, zipfile.ZIP_STORED) + # Store mimetype without without compression using a ZipInfo object + # for compatibility with Py2.6 which doesn't have compress_type + # parameter in ZipFile.writestr function + mime_zipinfo = zipfile.ZipInfo('mimetype') + zipdoc.writestr(mime_zipinfo, mimetype) for fname, content in files.items(): - if sys.version_info >= (2, 7): - zipdoc.writestr(fname, content, zipfile.ZIP_DEFLATED) - else: - zipdoc.writestr(fname, content) + zipdoc.writestr(fname, content) self.log.debug('Document packing completed') diff --git a/tox.ini b/tox.ini index 6f64342..fbb1117 100644 --- a/tox.ini +++ b/tox.ini @@ -3,4 +3,4 @@ envlist = py26, py27, py3, py33, py34, py35, py36 [testenv] deps = pytest -commands= py.test +commands = py.test