Fix AttributeError: ZipFile instance has no attribute '__exit__' in Python 2.6.x
This commit is contained in:
parent
f54ba5fdba
commit
fe28417809
1 changed files with 4 additions and 4 deletions
|
|
@ -125,7 +125,7 @@ class Renderer(object):
|
|||
self.log.debug('Unpacking template file')
|
||||
|
||||
archive_files = {}
|
||||
with zipfile.ZipFile(template, 'r') as archive:
|
||||
archive = zipfile.ZipFile(template, 'r')
|
||||
for zfile in archive.filelist:
|
||||
archive_files[zfile.filename] = archive.read(zfile.filename)
|
||||
|
||||
|
|
@ -139,7 +139,7 @@ class Renderer(object):
|
|||
self.log.debug('packing document')
|
||||
zip_file = io.BytesIO()
|
||||
|
||||
with zipfile.ZipFile(zip_file, 'a') as zipdoc:
|
||||
zipdoc = zipfile.ZipFile(zip_file, 'a')
|
||||
for fname, content in files.items():
|
||||
if sys.version_info >= (2, 7):
|
||||
zipdoc.writestr(fname, content, zipfile.ZIP_DEFLATED)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue