fediverse_pasture_inputs.tool¶
python -mfediverse_pasture_inputs¶
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
- navigation: Writes the .pages file for the inputs used to generate the documentation.
- zip-file: Creates a zip file containing the the generated ActivityPub objects
python -mfediverse_pasture_inputs 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 |
--no_navigation |
boolean | N/A | False |
--watch |
boolean | Watch for changes in the fediverse_pasture_inputs directory | False |
--help |
boolean | Show this message and exit. | False |
python -mfediverse_pasture_inputs navigation¶
Writes the .pages file for the inputs used to generate the documentation. Usually runs automatically when generating the documentation.
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 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 ¶
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
make_url ¶
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
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
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': ['https://www.w3.org/ns/activitystreams#Public', 'http://remote.example/'],
'id': 'http://actor.example/...',
'published': '...',
'content': 'moo'}}
Source code in fediverse_pasture_inputs/tool/transformer.py
create_object
async
¶
Creates the sample object
>>> import asyncio
>>> et = ExampleTransformer()
>>> asyncio.run(et.create_object({"content": "moo"}))
{'type': 'Note',
'attributedTo': 'http://actor.example',
'to': ['https://www.w3.org/ns/activitystreams#Public'],
'id': 'http://actor.example/...',
'published': '...',
'content': 'moo',
'@context': ['https://www.w3.org/ns/activitystreams',
{'Hashtag': 'as:Hashtag', 'sensitive': 'as:sensitive'}]}