bovine.jsonld

This modules contains some helper functions to deal with json-ld. It realies on the pyld library to perform the actual algorithms on json-ld.

The goal of using with_bovine_context is to achieve simpler access for certain values. With the base ActivityStreams Namespace the value of to can either be a string or a list. With the bovine context, it will always be a list.

bovine.jsonld.bovine_context = ['https://www.w3.org/ns/activitystreams', {'publicKey': {'@id': 'https://w3id.org/security#publicKey', '@type': '@id'}, 'publicKeyPem': 'https://w3id.org/security#publicKeyPem', 'owner': {'@id': 'https://w3id.org/security#owner', '@type': '@id'}, 'to': {'@id': 'as:to', '@type': '@id', '@container': '@set'}, 'cc': {'@id': 'as:cc', '@type': '@id', '@container': '@set'}, 'tag': {'@id': 'as:tag', '@type': '@id', '@container': '@set'}, 'items': {'@id': 'as:items', '@type': '@id', '@container': '@set'}, 'attachment': {'@id': 'as:attachment', '@type': '@id', '@container': '@set'}, 'Hashtag': 'as:Hashtag'}]

Defines the context about:bovine used internally in the bovine stack

bovine.jsonld.bovine_context_name = 'about:bovine'

Defines the name of the bovine context

bovine.jsonld.combine_items(data: dict, items: List[dict]) dict[source]

Takes data and replaces ids by the corresponding objects from items

bovine.jsonld.default_context = ['https://www.w3.org/ns/activitystreams', 'https://w3id.org/security/v1', {'Hashtag': 'as:Hashtag'}]

Defines the context used to communicate with other Fediverse software

async bovine.jsonld.split_into_objects(input_data: dict) List[dict][source]

Takes an object with an “id” property and separates out all the subobjects with an id

bovine.jsonld.with_activitystreams_context(data: dict) dict[source]

Returns the object with the ActivityStreams context

bovine.jsonld.with_bovine_context(data: dict) dict[source]

Returns the object with the about:bovine context

bovine.jsonld.with_external_context(data: dict) dict[source]

Returns the object with the default external context