Skip to content

fediverse_pasture_inputs.resources

image_base_path module-attribute

image_base_path = 'http://pasture-one-actor/images/'

Base path for images

resource_base_path module-attribute

resource_base_path = 'http://pasture-one-actor/assets/'

Base path to resources

used_resources module-attribute

used_resources: set[str] = set()

List of used resources

random_image_path

random_image_path(file_ending: str = '.png') -> str

Returns the path for a random image

Source code in fediverse_pasture_inputs/resources.py
def random_image_path(file_ending: str = ".png") -> str:
    """Returns the path for a random image"""
    return image_base_path + str(uuid4()) + file_ending

resource_path

resource_path(asset: str) -> str

Returns the path to the asset

>>> resource_path("cow_emoji.png")
'http://pasture-one-actor/assets/cow_emoji.png'
Source code in fediverse_pasture_inputs/resources.py
def resource_path(asset: str) -> str:
    """Returns the path to the asset

    ```pycon
    >>> resource_path("cow_emoji.png")
    'http://pasture-one-actor/assets/cow_emoji.png'

    ```
    """

    used_resources.add(asset)

    return urljoin(resource_base_path, asset)