betty.assets module - Betty documentation

Hide navigation sidebar
Hide table of contents sidebar
Skip to content
Back to top
View this page
Toggle table of contents sidebar

# betty.assets module

The Assets API.

class betty.assets.AssetRepository

  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.

  This is thread-safe, which means you can safely use this between different threads.

  __init__(*assets_directory_paths: Path)
    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

    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]

    Get virtual paths to available assets.

    Parameters:

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