Skip to content

Commit 97b974e

Browse files
committed
Also check for checksums in a checksum subdictionary
1 parent 344b0d3 commit 97b974e

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

pooch/downloaders.py

+12
Original file line numberDiff line numberDiff line change
@@ -1159,8 +1159,20 @@ def populate_registry(self, pooch):
11591159

11601160
for filedata in self.api_response.json()["data"]["latestVersion"]["files"]:
11611161
for algorithm in ["md5", "sha1", "sha256", "sha512"]:
1162+
# Look for the checksum directly in the file dictionary
11621163
if algorithm in filedata["dataFile"]:
11631164
pooch.registry[filedata["dataFile"]["filename"]] = (
11641165
f"{algorithm}:{filedata['dataFile'][algorithm]}"
11651166
)
11661167
break
1168+
# Look for the checksum in the checksum sub-dictionary
1169+
if algorithm in filedata["dataFile"].get("checksum", {}):
1170+
pooch.registry[filedata["dataFile"]["filename"]] = (
1171+
f"{algorithm}:{filedata['dataFile']['checksum'][algorithm]}"
1172+
)
1173+
break
1174+
1175+
raise ValueError(
1176+
f"Checksum for file '{filedata["dataFile"]["filename"]}'"
1177+
" not found in the DataVerse API response."
1178+
)

0 commit comments

Comments
 (0)