Skip to content

Commit

Permalink
Merge pull request #321 from mih/iter
Browse files Browse the repository at this point in the history
fix(`download_file`): accomodate newer pyDataverse versions (0.3.2+)
  • Loading branch information
mih authored Jul 19, 2024
2 parents 98ef1b0 + 8405f09 commit 8e54971
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion datalad_dataverse/dataset.py
Original file line number Diff line number Diff line change
Expand Up @@ -175,9 +175,14 @@ def download_file(self, fid: int, path: Path):
# http error handling
response.raise_for_status()
with path.open("wb") as f:
# accommodate old and newer pydataverse version
try:
it = response.iter_content
except AttributeError:
it = response.iter_bytes
# `chunk_size=None` means
# "read data in whatever size the chunks are received"
for chunk in response.iter_content(chunk_size=None):
for chunk in it(chunk_size=None):
f.write(chunk)

def remove_file(self, fid: int):
Expand Down

0 comments on commit 8e54971

Please sign in to comment.