From a9d0d3671afc2be90509517b53b96af694ff22e5 Mon Sep 17 00:00:00 2001 From: Daniel Blankenberg Date: Wed, 31 May 2017 16:55:32 -0400 Subject: [PATCH] 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... --- lib/galaxy/util/compression_utils.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/lib/galaxy/util/compression_utils.py b/lib/galaxy/util/compression_utils.py index b948951bea3..6a94c543196 100644 --- a/lib/galaxy/util/compression_utils.py +++ b/lib/galaxy/util/compression_utils.py @@ -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)