Skip to content

Commit

Permalink
[pre-commit.ci] auto fixes from pre-commit.com hooks
Browse files Browse the repository at this point in the history
for more information, see https://pre-commit.ci
  • Loading branch information
pre-commit-ci[bot] committed Dec 17, 2024
1 parent b854b77 commit f9e3d70
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 9 deletions.
10 changes: 5 additions & 5 deletions repo2docker/contentproviders/dataverse.py
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ def parse_dataverse_url(self, url: str) -> Tuple[str, bool]:
Raises a ValueError if we can not parse the url
"""
parsed_url= urlparse(url)
parsed_url = urlparse(url)
path = parsed_url.path
qs = parse_qs(parsed_url.query)
base_url = f"{parsed_url.scheme}://{parsed_url.netloc}"
Expand Down Expand Up @@ -157,10 +157,10 @@ def get_datafiles(self, url: str) -> List[dict]:
resp = self._request(dataset_api_url, headers={"accept": "application/json"})
if resp.status_code == 404 and is_ambiguous:
# It's possible this is a *file* persistent_id, not a dataset one
persistent_id = self.get_dataset_id_from_file_id(
base_url, persistent_id
persistent_id = self.get_dataset_id_from_file_id(base_url, persistent_id)
dataset_api_url = (
f"{base_url}/api/datasets/:persistentId?persistentId={persistent_id}"
)
dataset_api_url = f"{base_url}/api/datasets/:persistentId?persistentId={persistent_id}"
resp = self._request(
dataset_api_url, headers={"accept": "application/json"}
)
Expand All @@ -181,7 +181,7 @@ def fetch(self, spec, output_dir, yield_output=False):
url = spec
parsed_url = urlparse(url)
# FIXME: Support determining API URL better
base_url = f'{parsed_url.scheme}://{parsed_url.netloc}'
base_url = f"{parsed_url.scheme}://{parsed_url.netloc}"

yield f"Fetching Dataverse record {url}.\n"

Expand Down
9 changes: 5 additions & 4 deletions tests/contentproviders/test_dataverse.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@

from repo2docker.contentproviders import Dataverse


@pytest.mark.parametrize(
("doi", "resolved"),
[
Expand Down Expand Up @@ -45,22 +46,22 @@ def test_detect(doi, resolved):
(
"https://dataverse.harvard.edu/file.xhtml?persistentId=doi:10.7910/DVN/6ZXAGT/3YRRYJ",
"doi:10.7910/DVN/6ZXAGT",
False
False,
),
(
"https://dataverse.harvard.edu/citation?persistentId=doi:10.7910/DVN/TJCLKP",
"doi:10.7910/DVN/TJCLKP",
True
True,
),
(
"https://dataverse.harvard.edu/api/access/datafile/3323458",
"doi:10.7910/DVN/3MJ7IR",
False
False,
),
(
"https://data.cimmyt.org/dataset.xhtml?persistentId=hdl:11529/10016",
"hdl:11529/10016",
False
False,
),
],
)
Expand Down

0 comments on commit f9e3d70

Please sign in to comment.