Skip to content

Commit

Permalink
Merge pull request #5 from micafer/osf_revert
Browse files Browse the repository at this point in the history
Osf revert
  • Loading branch information
micafer authored Sep 25, 2024
2 parents b4a9c04 + b28d4c1 commit 5eadfee
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 26 deletions.
21 changes: 1 addition & 20 deletions datahugger/services.py
Original file line number Diff line number Diff line change
Expand Up @@ -326,7 +326,7 @@ class OSFDataset(DatasetDownloader):
API_URL = "https://api.osf.io/v2/nodes/"

# the files and metadata about the dataset
API_URL_META = "{api_url}{record_id}/files/"
API_URL_META = "{api_url}{record_id}/files/osfstorage/?format=jsonapi"
META_FILES_JSONPATH = "data[*]"

PAGINATION_JSONPATH = "links.next"
Expand All @@ -342,25 +342,6 @@ class OSFDataset(DatasetDownloader):
ATTR_HASH_JSONPATH = "attributes.extra.hashes.sha256"
ATTR_HASH_TYPE_VALUE = "sha256"

def _get_node_providers(self):
"""Get the providers of a node."""
record_id = self._params["record_id"]
res = requests.get(f"{self.API_URL}/{record_id}/files/")
return set([prov["attributes"]["provider"] for prov in res.json()["data"]])

def _get_files_recursive(self, url, folder_name=None, base_url=None):
files = []
# In case of the top-level folder, we need to get first the providers
if folder_name is None:
for provider in self._get_node_providers():
# and then the files of each provider
files.extend(
super()._get_files_recursive(f"{url}{provider}/", None, base_url)
)
else:
files = super()._get_files_recursive(url, folder_name, base_url)
return files


class ZenodoDataset(DatasetDownloader):
"""Downloader for Zenodo repository.
Expand Down
8 changes: 2 additions & 6 deletions tests/test_repositories.toml
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,8 @@ location = "https://figshare.com/articles/dataset/Long-term_behavioral_repeatabi
files = "cross_year_data2.csv"

[[figshare]]
location = "https://doi.org/10.15131/shef.data.22010159.v2"
files = "ScHARR QUIT evaluation statistical and health economic analysis plan.pdf"
location = "https://doi.org/10.15131/shef.data.26977237.v1"
files = "README.txt"

[[djehuty]]
location = "https://doi.org/10.4121/21989216.v1"
Expand All @@ -62,10 +62,6 @@ files = "ReadmeFile.txt"
location = "https://doi.org/10.5061/dryad.31zcrjdm5"
files = "ReadmeFile.txt"

[[osf]]
location = "https://osf.io/ews27/"
files = "Cross-comparison/amarlt1"

[[osf]]
location = "https://osf.io/kq573/"
files = "nest_area_data.xlsx"
Expand Down

0 comments on commit 5eadfee

Please sign in to comment.