betty.linked_data module

Provide JSON-LD utilities.

class betty.linked_data.JsonLdObject

Bases: Object

A JSON Schema for an object with JSON-LD.

__init__(*, def_name: str | None = None, title: ResolvableLocalizable | None = None, description: ResolvableLocalizable | None = None)
final class betty.linked_data.JsonLdSchema

Bases: Schema

A JSON-LD JSON Schema reference.

__init__()
class betty.linked_data.LinkedDataDumpable

Bases: Generic

Describe an object that can be dumped to linked data.

abstractmethod async dump_linked_data(project: Project, /) PortableDataT

Dump this instance to JSON-LD.

class betty.linked_data.LinkedDataDumpableWithSchema

Bases: LinkedDataDumpable, Generic

Describe an object that can be dumped to linked data.

abstractmethod async classmethod linked_data_schema(project: Project, /) SchemaT

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

class betty.linked_data.LinkedDataDumpableWithSchemaJsonLdObject

Bases: LinkedDataDumpableWithSchema[JsonLdObject, PortableMapping], ABC

A betty.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.portable.PortableMapping dump.

async dump_linked_data(project: Project, /) PortableMapping

Dump this instance to JSON-LD.

async classmethod linked_data_schema(project: Project, /) JsonLdObject

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

class betty.linked_data.LinkedDataDumper

Bases: ABC, Generic

Provide linked data for instances of a target type.

abstractmethod async dump_linked_data_for(project: Project, target: T, /) PortableDataT

Dump the given target to JSON-LD.

abstractmethod async linked_data_schema_for(project: Project, /) SchemaT

Define the JSON Schema for betty.linked_data.LinkedDataDumper.dump_linked_data_for().

betty.linked_data.dump_context(portable: PortableMapping, **context_definitions: str) None

Add one or more contexts to a dump.

Add one or more links to a dump.

async betty.linked_data.dump_schema(project: Project, portable: PortableMapping, linked_data_dumpable: LinkedDataDumpableWithSchema[Object, PortableMapping], /) None

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