Vultron ActivityStreams Vocabulary Base Package
vultron.as_vocab.base
Provides an implementation of the ActivityStreams 2.0 protocol.
activitystreams_activity(cls)
Register an activity for a given activity type.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
cls
|
type
|
The class to register. |
required |
Returns:
| Type | Description |
|---|---|
type
|
A decorator that registers the activity class. |
Source code in vultron/as_vocab/base/__init__.py
43 44 45 46 47 48 49 50 51 52 53 54 | |
activitystreams_link(cls)
Register a link for a given link type.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
cls
|
type
|
The class to register. |
required |
Returns:
| Type | Description |
|---|---|
type
|
A decorator that registers the link class. |
Source code in vultron/as_vocab/base/__init__.py
57 58 59 60 61 62 63 64 65 66 67 68 | |
activitystreams_object(cls)
Register an object for a given object type.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
cls
|
type
|
The class to register. |
required |
Returns:
| Type | Description |
|---|---|
type
|
A decorator that registers the object class. |
Source code in vultron/as_vocab/base/__init__.py
29 30 31 32 33 34 35 36 37 38 39 40 | |
vultron.as_vocab.base.base
file: base author: adh created_at: 2/17/23 3:59 PM
Objects
Links
Activities
Utilities
vultron.as_vocab.base.dt_utils
This module contains utilities for working with datetime objects.
days_from_now_utc(days=45)
Get a datetime object representing the current time plus the number of days specified.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
days
|
int
|
The number of days to add to the current time |
45
|
Returns:
| Type | Description |
|---|---|
datetime
|
A datetime object representing the current time plus the number |
datetime
|
of days specified |
Source code in vultron/as_vocab/base/dt_utils.py
29 30 31 32 33 34 35 36 37 38 39 | |
from_isofmt(datestring)
Decodes a string into a datetime object. If datestring isn't actually a string, but it is a datetime, or None, just return it.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
datestring
|
str | datetime | None
|
an iso-formatted date time string |
required |
Returns:
| Type | Description |
|---|---|
datetime
|
a datetime object |
Source code in vultron/as_vocab/base/dt_utils.py
68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 | |
now_utc()
Get the current time in UTC at one second resolution
Returns:
| Type | Description |
|---|---|
datetime
|
A timezone-aware datetime object representing the current time in UTC |
Source code in vultron/as_vocab/base/dt_utils.py
42 43 44 45 46 47 48 | |
to_isofmt(dt)
Encodes a datetime object into a string. If dt isn't actually a datetime, but it is a string, or None, just return it.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
dt
|
datetime | str | None
|
a datetime object, or a string, or None |
required |
Returns:
| Type | Description |
|---|---|
str
|
an iso-formatted date time string if dt is a datetime, otherwise dt |
Source code in vultron/as_vocab/base/dt_utils.py
51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 | |
vultron.as_vocab.base.utils
Provides utilities for the ActivityStreams Vocabulary.
exclude_if_empty(value)
Exclude a field if it is empty
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
value
|
any
|
The value to check |
required |
Returns:
| Type | Description |
|---|---|
bool
|
True if the value is empty, False otherwise |
Source code in vultron/as_vocab/base/utils.py
49 50 51 52 53 54 55 56 57 58 | |
exclude_if_none(value)
Exclude a field if it is None
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
value
|
any
|
The value to check |
required |
Returns:
| Type | Description |
|---|---|
bool
|
True if the value is None, False otherwise |
Source code in vultron/as_vocab/base/utils.py
37 38 39 40 41 42 43 44 45 46 | |
generate_new_id()
Generate a new ID for an object
Returns:
| Type | Description |
|---|---|
str
|
the new ID |
Source code in vultron/as_vocab/base/utils.py
61 62 63 64 65 66 67 68 69 70 71 72 73 | |
name_of(obj)
Get the name of an object if it has one, otherwise return the object itself
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
obj
|
any
|
The object to get the name of |
required |
Returns:
| Type | Description |
|---|---|
str
|
Either the name of the object or the object itself |
Source code in vultron/as_vocab/base/utils.py
21 22 23 24 25 26 27 28 29 30 31 32 33 34 | |
print_activity_examples()
Print out empty examples of the classes in the given module
Source code in vultron/as_vocab/base/utils.py
94 95 96 97 98 99 | |
print_link_examples()
Print out empty examples of the classes in the given module
Source code in vultron/as_vocab/base/utils.py
102 103 104 105 106 107 | |
print_object_examples()
Print out empty examples of the classes in the given module
Source code in vultron/as_vocab/base/utils.py
86 87 88 89 90 91 | |
vultron.as_vocab.base.objects.utils
Provides Utility functions for the as_vocab.base.objects module
object_from_dict(data)
Create an object from the given json data. Figures out the type and creates the appropriate object.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
data
|
dict
|
the json data |
required |
Returns:
| Type | Description |
|---|---|
as_Base
|
an object that is a subclass of as_Base |
Raises:
| Type | Description |
|---|---|
MissingTypeError
|
if the type is missing |
UnrecognizedTypeError
|
if the type is not recognized |
UnrecognizedTypeError
|
if the type of any sub-object is not recognized |
Source code in vultron/as_vocab/base/objects/utils.py
70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 | |
simple_object_from_dict(data)
Get the object from the given json data
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
data
|
dict
|
the json data |
required |
Returns:
| Type | Description |
|---|---|
as_Base
|
the object |
Raises:
| Type | Description |
|---|---|
MissingTypeError
|
if the type is missing |
UnrecognizedTypeError
|
if the type is not recognized |
Source code in vultron/as_vocab/base/objects/utils.py
28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 | |
Errors
vultron.as_vocab.base.errors
file: errors author: adh created_at: 2/17/23 1:49 PM
ActivityVocabularyError
Bases: VultronError
Base class for all ActivityPub as_vocab errors.
Source code in vultron/as_vocab/base/errors.py
27 28 | |
DeserializationError
Bases: ActivityVocabularyError
Raised when a JSON object cannot be deserialized.
Source code in vultron/as_vocab/base/errors.py
52 53 | |
IsoDecodingError
Bases: DeserializationError
Raised when an ISO decoding is not recognized.
Source code in vultron/as_vocab/base/errors.py
64 65 | |
IsoEncodingError
Bases: SerializationError
Raised when an ISO encoding is not recognized.
Source code in vultron/as_vocab/base/errors.py
41 42 | |
MissingTypeError
Bases: DeserializationError
Raised when a type is missing from a JSON object.
Source code in vultron/as_vocab/base/errors.py
56 57 | |
SerializationError
Bases: ActivityVocabularyError
Raised when a JSON object cannot be serialized.
Source code in vultron/as_vocab/base/errors.py
37 38 | |
UnrecognizedTypeError
Bases: DeserializationError
Raised when an unknown type is encountered.
Source code in vultron/as_vocab/base/errors.py
60 61 | |
vultron.as_vocab.base.objects.errors
file: errors author: adh created_at: 2/17/23 1:50 PM
ActivityVocabularyObjectError
Bases: ActivityVocabularyError
Base class for all ActivityPub object errors.
Source code in vultron/as_vocab/base/objects/errors.py
23 24 | |
vultron.as_vocab.base.objects.activities.errors
file: errors author: adh created_at: 2/17/23 1:52 PM
ActivityVocabularyActivityError
Bases: ActivityVocabularyObjectError
Base class for all ActivityPub activity errors.
Source code in vultron/as_vocab/base/objects/activities/errors.py
25 26 | |