cremalink.devices package

This module handles the discovery and loading of device definition files, referred to as “device maps.”

exception cremalink.devices.DeviceMapNotFoundError[source]

Bases: FileNotFoundError

Custom exception raised when a specific device map cannot be found.

cremalink.devices.device_map(model_id: str) str[source]

Finds the absolute path to a device map file for a given model ID.

This function handles packaged resources, extracting them to a temporary directory if they are not directly accessible on the filesystem.

Parameters:

model_id – The model ID of the device.

Returns:

The absolute path to the device map JSON file as a string.

Raises:

DeviceMapNotFoundError – If the map for the given model ID doesn’t exist.

cremalink.devices.get_device_maps() List[str][source]

Lists all available device maps by scanning the package data.

Returns:

A sorted list of unique model IDs (without the .json extension).

cremalink.devices.load_device_map(model_id: str) dict[str, Any][source]

Loads a device map from its JSON file into a dictionary.

Parameters:

model_id – The model ID of the device to load.

Returns:

A dictionary containing the device map data, or an empty dict on failure.