simvx.core.asset_resolver

Asset path resolution.

resolve_asset_path is the engine’s single canonical way to turn an asset specification into a filesystem :class:~pathlib.Path. It accepts:

  • class:

    str / :class:os.PathLike – a filesystem path, absolute or resolved relative to project_root (or the current working directory).

  • class:

    ~simvx.core.resource.Resource – a Python-package handle, looked up via :mod:importlib.resources.

  • class:

    importlib.resources.abc.Traversable – the raw return type of importlib.resources.files(pkg) / name; resolved to a real path via

    func:

    importlib.resources.as_file.

Strict by default: missing files raise :class:FileNotFoundError, missing packages raise :class:ModuleNotFoundError, anything else raises

class:

TypeError. There are no URI schemes – strings are paths.

Module Contents

Functions

resolve_asset_path

Resolve spec to a filesystem :class:Path.

Data

API

simvx.core.asset_resolver.AssetSpec

None

simvx.core.asset_resolver.resolve_asset_path(spec: simvx.core.asset_resolver.AssetSpec, project_root: pathlib.Path | None = None) pathlib.Path[source]

Resolve spec to a filesystem :class:Path.

  • str / os.PathLike: filesystem path. Absolute paths pass through; relative paths resolve from project_root (or the CWD).

  • Resource: package + name resolved via :mod:importlib.resources.

  • Traversable: package-resource handle resolved via

    func:

    importlib.resources.as_file.

Raises :class:TypeError for any other type, :class:FileNotFoundError if the resolved file is missing, and :class:ModuleNotFoundError if a Resource references a package that cannot be imported.