bovine.parse

This module contains an experimental ActivityStreams object parser.

class bovine.parse.Activity(data: dict, domain: str | None = None, domain_may_differ: bool = False)[source]

Represents an activity

async accept_for_follow(retrieve) Self | None[source]

If the activity is an Accept for a Follow request, returns said Follow request. Basic validation is run on the Accept and Follow request.

In case of not an Accept for a Follow request or it being invalid None is returned.

Parameters:
  • retrieve – a coroutine str -> dict that takes an object_id and resolves it to the corresponding object

  • retrieve – a coroutine str -> dict that takes an object_id and resolves it to the corresponding object

async object_for_create(retrieve) Object | None[source]

If activity is a create, returns the corresponding object

async undo_of_follow(retrieve) Self | None[source]

If the activity is an Undo of a Follow request, returns said Follow request. Basic validation is run on the Undo and Follow request.

In case of not an Undo of a Follow request or it being invalid None is returned.

Parameters:

retrieve – a coroutine str -> dict that takes an object_id and resolves it to the corresponding object

class bovine.parse.Actor(data, domain: str = None, domain_may_differ: bool = False)[source]

Parses an actor object

property id

id of the actor

property identifiers

Lists the identifiers of the actor.

In order for the account uri to be listed as an identifier, the coroutine validate_acct_uri needs to be run

async validate_acct_uri(session=None) bool[source]

Checks if the acct uri defined by preferredUsername and the domain can be verified using a webfinger lookup. If yes, returns True and adds the acct uri to the identifiers of the actor.

class bovine.parse.Object(data: dict, domain: str | None = None, domain_may_differ: bool = False)[source]

Basic representation of an object

class bovine.parse.bovine_object.BovineObject(data: dict, domain: str | None = None, domain_may_differ: bool = False)[source]

Initializes an Object to be parsed

Parameters:

data – The data to be parsed. It is assumed that data is compacted against the about:bovine context and the parts making it up are validated.

property actor_id

If the object has an actor property, set to its id

property object_id

If the object has an object property, set to its id