mex.common.assets package

Submodules

mex.common.assets.base module

class mex.common.assets.base.BaseAssetsConnector

Bases: BaseConnector

Base class for assets connectors that handle file loading.

abstractmethod read(path: str) bytes

Read a file from the given path and return bytes.

Parameters:

path – The path pointing to the file to read

Returns:

The file contents as bytes

Raises:

PermissionError – For file access permission issues

mex.common.assets.filesystem module

class mex.common.assets.filesystem.FilesystemAssetsConnector

Bases: BaseAssetsConnector

Filesystem-based implementation of assets connector.

__init__() None

Create a new connector instance.

close() None

Nothing to close for filesystem access.

read(path: str) bytes

Read a file from the filesystem.

Parameters:

path – The path pointing to the file to load

Returns:

The file contents as bytes

Raises:

PermissionError – For file access permission issues

mex.common.assets.registry module

mex.common.assets.registry.get_assets_connector() BaseAssetsConnector

Get an instance of the assets connector as configured by assets_connector.

Raises:

RuntimeError – When the configured connector is not registered

Returns:

An instance of a subclass of BaseAssetsConnector

mex.common.assets.registry.register_assets_connector(key: AssetsConnectorType, connector_cls: type[BaseAssetsConnector]) None

Register an implementation of an assets connector to a settings key.

Parameters:
  • key – Possible value of BaseSettings.assets_connector

  • connector_cls – Implementation of an assets connector

Raises:

RuntimeError – When the key is already registered

Module contents

class mex.common.assets.BaseAssetsConnector

Bases: BaseConnector

Base class for assets connectors that handle file loading.

abstractmethod read(path: str) bytes

Read a file from the given path and return bytes.

Parameters:

path – The path pointing to the file to read

Returns:

The file contents as bytes

Raises:

PermissionError – For file access permission issues

class mex.common.assets.FilesystemAssetsConnector

Bases: BaseAssetsConnector

Filesystem-based implementation of assets connector.

__init__() None

Create a new connector instance.

close() None

Nothing to close for filesystem access.

read(path: str) bytes

Read a file from the filesystem.

Parameters:

path – The path pointing to the file to load

Returns:

The file contents as bytes

Raises:

PermissionError – For file access permission issues

mex.common.assets.get_assets_connector() BaseAssetsConnector

Get an instance of the assets connector as configured by assets_connector.

Raises:

RuntimeError – When the configured connector is not registered

Returns:

An instance of a subclass of BaseAssetsConnector

mex.common.assets.register_assets_connector(key: AssetsConnectorType, connector_cls: type[BaseAssetsConnector]) None

Register an implementation of an assets connector to a settings key.

Parameters:
  • key – Possible value of BaseSettings.assets_connector

  • connector_cls – Implementation of an assets connector

Raises:

RuntimeError – When the key is already registered