betty.json.linked_data module - Betty documentation

Hide navigation sidebar
Hide table of contents sidebar
Skip to content
Back to top
View this page
Toggle table of contents sidebar

# betty.json.linked_data module

Provide JSON-LD utilities.

class betty.json.linked_data.JsonLdObject

  Bases: `Object`

  A JSON Schema for an object with JSON-LD.

  __init__(json_ld_schema: JsonLdSchema, *, def_name: str | None = None, title: str | None = None, description: str | None = None)

final class betty.json.linked_data.JsonLdSchema

  Bases: `FileBasedSchema`

  A JSON-LD JSON Schema reference.

  async classmethod new() → Self

    Create a new instance.

class betty.json.linked_data.LinkedDataDumpable

  Bases: `Generic`[`_SchemaTypeT`, `_DumpT`]

  Describe an object that can be dumped to linked data.

  abstract async dump_linked_data(project: Project) → _DumpT

    Dump this instance to JSON-LD.

  abstract async classmethod linked_data_schema(project: Project) → _SchemaTypeT

    Define the JSON Schema for `betty.json.linked_data.LinkedDataDumpable.dump_linked_data()`.

class betty.json.linked_data.LinkedDataDumpableJsonLdObject

  Bases: `LinkedDataDumpable`[`JsonLdObject`, `MutableMapping`[`str`, `bool` | `int` | `float` | `str` | `None` | `MutableSequence`[Dump] | `MutableMapping`[`str`, Dump]]], `ABC`

  A `betty.json.linked_data.LinkedDataDumpable` implementation for object/mapping data.

  This is helpful when working with diamond class hierarchies where parent classes that may not be the root class want to make changes to the linked data, and expect an :py:class`betty.json.schema.Object` schema and a `betty.serde.dump.DumpMapping` dump.

  async dump_linked_data(project: Project) → DumpMapping[Dump]

    Dump this instance to JSON-LD.

  async classmethod linked_data_schema(project: Project) → JsonLdObject

    Define the JSON Schema for `betty.json.linked_data.LinkedDataDumpable.dump_linked_data()`.

class betty.json.linked_data.LinkedDataDumpableProvider

  Bases: `Generic`[`_T`, `_SchemaTypeT`, `_DumpT`], `ABC`

  Provide linked data for instances of a target type.

  abstract async dump_linked_data_for(project: Project, target: _T) → _DumpT

    Dump the given target to JSON-LD.

  abstract async linked_data_schema_for(project: Project) → _SchemaTypeT

    Define the JSON Schema for `betty.json.linked_data.LinkedDataDumpableProvider.dump_linked_data_for()`.

betty.json.linked_data.dump_context(dump: MutableMapping[str, bool | int | float | str | None | MutableSequence[bool | int | float | str | None | MutableSequence[Dump] | MutableMapping[str, Dump]] | MutableMapping[str, bool | int | float | str | None | MutableSequence[Dump] | MutableMapping[str, Dump]]], **context_definitions: str) → None

  Add one or more contexts to a dump.

async betty.json.linked_data.dump_link(dump: DumpMapping[Dump], project: Project, *links: Link) → None

  Add one or more links to a dump.

async betty.json.linked_data.dump_schema(project: Project, dump: DumpMapping[Dump], linked_data_dumpable: LinkedDataDumpable[Object, DumpMapping[Dump]]) → None

  Add the $schema item to a JSON-LD dump.