Skip to content

Commit

Permalink
Fixes #2029 Handle gzip files without extensions (#2126)
Browse files Browse the repository at this point in the history
  • Loading branch information
AlexandreAbraham authored and GaelVaroquaux committed Sep 25, 2019
1 parent 920f7bd commit 64d97dd
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion nilearn/datasets/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -336,9 +336,13 @@ def _uncompress_file(file_, delete_archive=True, verbose=1):
processed = True
elif ext == '.gz' or header.startswith(b'\x1f\x8b'):
import gzip
gz = gzip.open(file_)
if ext == '.tgz':
filename = filename + '.tar'
elif ext == '':
# For gzip file, we rely on the assumption that there is an extenstion
shutil.move(file_, file_ + '.gz')
file_ = file_ + '.gz'
gz = gzip.open(file_)
out = open(filename, 'wb')
shutil.copyfileobj(gz, out, 8192)
gz.close()
Expand Down

0 comments on commit 64d97dd

Please sign in to comment.