Skip to content

Commit 17484f2

Browse files
committed
If the downloaded file is a tarfile, then decompress
1 parent 64863b7 commit 17484f2

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

dials_data/download.py

+7
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
import contextlib
44
import os
5+
import tarfile
56

67
import dials_data.datasets
78
from six.moves.urllib.request import urlopen
@@ -180,6 +181,12 @@ def _fetch_filelist(filelist, file_hash):
180181
print("Downloading {}".format(source["url"]))
181182
_download_to_file(source["url"], source["file"])
182183

184+
# If the file is a tar archive, then decompress
185+
if tarfile.is_tarfile(source["file"]):
186+
print(f"Decompressing {source['file']}")
187+
with tarfile.open(source["file"]) as tar:
188+
tar.extractall(path=source["file"].dirname)
189+
183190
# verify
184191
valid = True
185192
fileinfo = {

0 commit comments

Comments
 (0)