summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/python/gudhi/datasets/remote.py13
-rw-r--r--src/python/test/test_remote_datasets.py7
2 files changed, 7 insertions, 13 deletions
diff --git a/src/python/gudhi/datasets/remote.py b/src/python/gudhi/datasets/remote.py
index 525a7b66..fdd20f74 100644
--- a/src/python/gudhi/datasets/remote.py
+++ b/src/python/gudhi/datasets/remote.py
@@ -39,7 +39,7 @@ def _checksum_sha256(file_path):
sha256_hash.update(buffer)
return sha256_hash.hexdigest()
-def fetch(url, filename, dirname = "remote_datasets", checksum_flag = False, file_checksum = None):
+def fetch(url, filename, dirname = "remote_datasets", file_checksum = None):
"""
Fetch the wanted dataset from the given url and save it in file_path
@@ -51,12 +51,8 @@ def fetch(url, filename, dirname = "remote_datasets", checksum_flag = False, fil
The name to give to downloaded file.
dirname : string
The directory to save the file to. Default is "remote_datasets".
- checksum_flag : boolean
- To set if the user wants the file checksum. Default is 'False'.
- Note that if checksum_flag is set to 'True', the file_checksum must be provided.
file_checksum : string
The file checksum using sha256 to check against the one computed on the downloaded file.
- To be considered, checksum_flag must be set to 'True'.
Default is 'None'.
Returns
@@ -71,10 +67,7 @@ def fetch(url, filename, dirname = "remote_datasets", checksum_flag = False, fil
urlretrieve(url, file_path)
- if (checksum_flag):
- if file_checksum is None:
- raise ValueError("The file checksum must be provided - different from None - for the check to be performed.")
-
+ if file_checksum is not None:
checksum = _checksum_sha256(file_path)
if file_checksum != checksum:
raise IOError("{} has a SHA256 checksum : {}, "
@@ -100,5 +93,5 @@ def fetch_spiral_2d(filename = "spiral_2d.csv", dirname = "remote_datasets"):
file_path: string
Full path of the created file.
"""
- return fetch("https://raw.githubusercontent.com/GUDHI/gudhi-data/main/points/spiral_2d.csv", filename, dirname, True,
+ return fetch("https://raw.githubusercontent.com/GUDHI/gudhi-data/main/points/spiral_2d.csv", filename, dirname,
'37530355d980d957c4ec06b18c775f90a91e446107d06c6201c9b4000b077f38')
diff --git a/src/python/test/test_remote_datasets.py b/src/python/test/test_remote_datasets.py
index 63ad7885..6c9217c8 100644
--- a/src/python/test/test_remote_datasets.py
+++ b/src/python/test/test_remote_datasets.py
@@ -25,14 +25,15 @@ def test_fetch_remote_datasets():
# Test files download with checksums provided
- path_file_dw = remote.fetch("https://raw.githubusercontent.com/GUDHI/gudhi-data/main/points/spiral_2d.csv", "spiral_2d.csv", checksum_flag = True,
- file_checksum = '37530355d980d957c4ec06b18c775f90a91e446107d06c6201c9b4000b077f38')
+ path_file_dw = remote.fetch("https://raw.githubusercontent.com/GUDHI/gudhi-data/main/points/spiral_2d.csv", "spiral_2d.csv",
+ file_checksum = '37530355d980d957c4ec06b18c775f90a91e446107d06c6201c9b4000b077f38')
names_dw = re.split(r' |/|\\', path_file_dw)
assert 'remote_datasets' == names_dw[0]
assert 'spiral_2d.csv' == names_dw[1]
path_file_dw = remote.fetch("https://raw.githubusercontent.com/GUDHI/gudhi-data/main/points/sphere3D_pts_on_grid.off", "sphere3D_pts_on_grid.off",
- checksum_flag = True, file_checksum = '32f96d2cafb1177f0dd5e0a019b6ff5658e14a619a7815ae55ad0fc5e8bd3f88')
+ file_checksum = '32f96d2cafb1177f0dd5e0a019b6ff5658e14a619a7815ae55ad0fc5e8bd3f88')
+
names_dw = re.split(r' |/|\\', path_file_dw)
assert 'remote_datasets' == names_dw[0]
assert 'sphere3D_pts_on_grid.off' == names_dw[1]