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.
- Parameters:
paths (
tuple
[pathlib.Path
,str
|None
])
- __init__(*paths: tuple[pathlib.Path, str | None])[source]¶
- Parameters:
paths (
tuple
[pathlib.Path
,str
|None
])
- async copy2(source_path: pathlib.Path, destination_path: pathlib.Path) pathlib.Path [source]¶
Copy a file to a destination using
shutil.copy2()
.- Parameters:
source_path (
pathlib.Path
)destination_path (
pathlib.Path
)
- Return type:
- async copytree(source_path: pathlib.Path, destination_path: pathlib.Path) AsyncIterable[pathlib.Path] [source]¶
Recursively copy the files in a directory tree to another directory.
- Parameters:
source_path (
pathlib.Path
)destination_path (
pathlib.Path
)
- Return type:
- open(*file_paths: pathlib.Path) betty.assets._Open [source]¶
Open a file. :rtype:
betty.assets._Open
- Parameters:
file_paths (
pathlib.Path
) – One or more file paths within the file system. The first file path to exist
will cause this function to return. Previously missing file paths will not cause errors.
- Raises:
FileNotFoundError – Raised when none of the provided paths matches an existing file.
- prepend(path: pathlib.Path, fs_encoding: str | None = None) None [source]¶
Prepend a layer path, e.g. override existing layers with the given one.
- Parameters:
path (
pathlib.Path
)
- Return type: