betty.assets module

The Assets API.

class betty.assets.AssetRepository[source]

Bases: object

Manages a set of assets.

This repository unifies several directory paths on disk, overlaying them on each other. Paths added later act as fallbacks, e.g. earlier paths have priority.

__init__(*assets_directory_paths: Path)[source]
Parameters:

assets_directory_paths – Earlier paths have priority over later paths.

property assets_directory_paths: Sequence[Path]

The paths to the individual virtual layers.

async get(path: Path) Path[source]

Get the path to a single asset file.

Parameters:

path – The virtual asset path.

Returns:

The path to the actual file on disk.

async walk(asset_directory_path: Path | None = None) AsyncIterator[Path][source]

Get virtual paths to available assets.

Parameters:

asset_directory_path – If given, only asses under the directory are returned.