Skip to content

Provide abstracted API for data access by clients #376

@sdruskat

Description

@sdruskat

Implement as follows:

model/__init__.py

Use the Schema.org names SoftwareSourceCode and SoftwareApplication and provide classes for both (here still called SoftwareMetadata), or (perhaps better) add a flag software_application: bool = False to auto-add @type to the returned data.

from .types.software_metadata import SoftwareMetadata
  • Create SoftwareMetadata class in .types.software_metadata similar to the following, but taking either:
    • a single schema or a list of schemas, or
    • a list of schemas (as below)
class SoftwareMetadata(ld_dict):
    def __init__(self, extra_contexts=[]):
        super().__init__([{}], context=[*ld_context.HERMES_BASE_CONTEXT, *extra_contexts])

Now, clients can access data (and inject new schemas to be used) by doing:

from hermes.model import SoftwareMetadata

data = SoftwareMetadata(extra_contexts=[{"my_schema": "https://my_schema.tld", "other_schema": "https://other_schema.tld"}])
data["my_schema:field"] = "foo"
data["other_schema:field"] = "bar"
data["funding"] = "nope"  # from CodeMeta

return data

Sub-issues

Metadata

Metadata

Assignees

Labels

data modelRelated to the hermes data model

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions