ResearchObject / ro-crate-py

Python library for RO-Crate
https://pypi.org/project/rocrate/
Apache License 2.0
46 stars 23 forks source link

Add add_tree method #151

Closed simleo closed 1 year ago

simleo commented 1 year ago

Adds an add_tree method to recursively add a directory along with its contents to the JSON-LD metadata (add_dataset already adds contents recursively to the crate's payload), listing directory contents in the hasPart of the Dataset instances.

rsirvent commented 1 year ago

I have a doubt in line 330 of rocrate/rocrate.py, the "add_dataset" call:

Would this add a "Dataset" entity for every sub-folder inside the root folder passed as initial parameter??? Shouldn't this be only done for the root folder?

simleo commented 1 year ago

I have a doubt in line 330 of rocrate/rocrate.py, the "add_dataset" call:

Would this add a "Dataset" entity for every sub-folder inside the root folder passed as initial parameter??? Shouldn't this be only done for the root folder?

Dataset is the type used in RO-Crate to represent all directory data entities. It's OK to have a Dataset entity for all subfolders, and that's what the newly added add_tree method does. It's also OK to only list the top-level folder, and that's what you get with the existing add_dataset method (see the tip at the end of the spec section on Referencing files and folders from the Root Data Entity: "There is no requirement to represent every file and folder in an RO-Crate as Data Entities in the RO-Crate JSON-LD").