Skip to content

Improve utilisation of ro-crate-py (rocrate) features #13

Description

@elichad

We already have rocrate as a dependency, but we could make better use of its features (unless otherwise indicated these are documented in that package's README):

  1. use the rocrate.model.Person helper class to add people in
    def _person(crate, spec, fallback_id):
  2. avoid patterns like the last line here:
    lic = crate.add(ContextEntity(crate, str(license), properties={
    "@type": "CreativeWork", "name": str(license),
    }))
    crate.root_dataset["license"] = {"@id": lic.id}
    and instead use the library's append_to feature - will add the property if it's not yet present, and preserve existing values if they are present.
    crate.root_dataset.append_to("license", lic)
    
    This can also allow you to avoid building your own lists of formatted references like you do here - you can just list the entities and feed that list into append_to (or use append_to in the loop instead of adding to the list at all, if you create the target entity first)
    instruments.append({"@id": ent.id})
  3. utilise the add_action helper function to build the CreateAction and link it to instruments, objects, results: https://github.com/ResearchObject/ro-crate-py/blob/05effe591443934e48e3fe59c53d7bc01a3334e0/rocrate/rocrate.py#L771

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions