Skip to content

Commit

Permalink
Also check for checksums in a checksum subdictionary
Browse files Browse the repository at this point in the history
  • Loading branch information
dokempf committed Nov 13, 2024
1 parent 344b0d3 commit 97b974e
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions pooch/downloaders.py
Original file line number Diff line number Diff line change
Expand Up @@ -1159,8 +1159,20 @@ def populate_registry(self, pooch):

for filedata in self.api_response.json()["data"]["latestVersion"]["files"]:
for algorithm in ["md5", "sha1", "sha256", "sha512"]:
# Look for the checksum directly in the file dictionary
if algorithm in filedata["dataFile"]:
pooch.registry[filedata["dataFile"]["filename"]] = (
f"{algorithm}:{filedata['dataFile'][algorithm]}"
)
break
# Look for the checksum in the checksum sub-dictionary
if algorithm in filedata["dataFile"].get("checksum", {}):
pooch.registry[filedata["dataFile"]["filename"]] = (
f"{algorithm}:{filedata['dataFile']['checksum'][algorithm]}"
)
break

raise ValueError(
f"Checksum for file '{filedata["dataFile"]["filename"]}'"
" not found in the DataVerse API response."
)

0 comments on commit 97b974e

Please sign in to comment.