fediverse_pasture_inputs.tool
python -mfediverse_pasture_inputs.tool
Tool for helping with creating the documentation for the fediverse-pasture-inputs
Usage:
Options:
Name | Type | Description | Default |
---|---|---|---|
--help |
boolean | Show this message and exit. | False |
Subcommands
- docs: Creates a documentation page for each input
- zip-file: Creates a zip file containing the the generated ActivityPub objects
python -mfediverse_pasture_inputs.tool docs
Creates a documentation page for each input
Usage:
Options:
Name | Type | Description | Default |
---|---|---|---|
--path |
text | Path of the directory the documentation pages are to be deposited | docs/inputs |
--help |
boolean | Show this message and exit. | False |
python -mfediverse_pasture_inputs.tool zip-file
Creates a zip file containing the the generated ActivityPub objects and activities
Usage:
Options:
Name | Type | Description | Default |
---|---|---|---|
--path |
text | Path of the directory the zip file is created at | docs/assets |
--help |
boolean | Show this message and exit. | False |
fediverse_pasture_inputs.tool
current_asset_archive(tag=__version__)
Downloads the zipfile for tag
and then
provides it as a generator.
>>> with current_asset_archive("0.1.8") as assets:
... assets.namelist()
['assets/', 'assets/note2.jsonap', ...]
Returns:
Type | Description |
---|---|
Generator[ZipFile, None, None]
|
archive of the inputs |
Source code in fediverse_pasture_inputs/tool/__init__.py
extract(tag=__version__)
make_url(tag)
Returns the url of the asset zip file
>>> make_url("0.1.8")
'https://codeberg.org/api/packages/funfedidev/generic/fediverse_pasture_assets/0.1.8/fediverse_pasture_assets.zip'
Source code in fediverse_pasture_inputs/tool/__init__.py
__main__
docs(path)
Creates a documentation page for each input
Source code in fediverse_pasture_inputs/tool/__main__.py
main()
zip_file(path)
Creates a zip file containing the the generated ActivityPub objects and activities
Source code in fediverse_pasture_inputs/tool/__main__.py
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'}]}