.tool.transformer
fediverse_pasture_inputs.tool.transformer
Helper class to create object and activity from examples
ExampleTransformer
Class to create objects and activities from examples
Source code in fediverse_pasture_inputs/tool/transformer.py
create_activity(example)
async
Creates the sample activity
>>> import asyncio
>>> et = ExampleTransformer()
>>> asyncio.run(et.create_activity({"content": "moo"}))
{'@context': ['https://www.w3.org/ns/activitystreams',
{'Hashtag': 'as:Hashtag', 'sensitive': 'as:sensitive'}],
'type': 'Create',
'actor': 'http://actor.example',
'to': [...],
'id': 'http://actor.example/...',
'published': '...',
'object': {'type': 'Note',
'attributedTo': 'http://actor.example',
'to': ['as:Public', 'http://remote.example/'],
'id': 'http://actor.example/...',
'published': '...',
'content': 'moo'}}
Source code in fediverse_pasture_inputs/tool/transformer.py
create_object(example)
async
Creates the sample object
>>> import asyncio
>>> et = ExampleTransformer()
>>> asyncio.run(et.create_object({"content": "moo"}))
{'type': 'Note',
'attributedTo': 'http://actor.example',
'to': ['as:Public'],
'id': 'http://actor.example/...',
'published': '...',
'content': 'moo',
'@context': ['https://www.w3.org/ns/activitystreams',
{'Hashtag': 'as:Hashtag', 'sensitive': 'as:sensitive'}]}