Fix for returning a fileobject in compression_utils.py when handling a zipfile.

Will return the first named object in the archive. zipfile.os_zipfile does not exist...
This commit is contained in:
Daniel Blankenberg
2017-05-31 16:55:32 -04:00
parent 42e274d334
commit a9d0d3671a
+3 -1
View File
@@ -29,5 +29,7 @@ def get_fileobj(filename, mode="r", gzip_only=False, bz2_only=False, zip_only=Fa
if not gzip_only and not zip_only and is_bz2(filename):
return bz2.BZ2File(filename, cmode)
if not bz2_only and not gzip_only and zipfile.is_zipfile(filename):
return zipfile.os_zipfile(filename, cmode)
# Return fileobj for the first file in a zip file.
with zipfile.ZipFile(filename, cmode) as zh:
return zh.open(zh.namelist()[0], cmode)
return open(filename, mode)