bpod_core.misc.SettingsDict

class bpod_core.misc.SettingsDict

Bases: MutableMapping

Represents a dictionary-like persistent settings storage.

This class is a mutable mapping implementation that stores and retrieves key-value pairs, persisting them to a JSON configuration file. The settings are associated with a specific application name and, optionally, an application author to organize the file path appropriately. You can use this class to manage configuration data that needs to be saved and reused across sessions. Changes to the dictionary are automatically saved to the file.

This class supports standard dictionary operations such as getting, setting, deleting items, checking for the existence of keys, and iterating over keys. Additionally, it provides functionality for accessing nested values using a sequence of keys.

__init__(app_name, app_author=None, filename='settings.json') None

Initialize the SettingsDict instance.

Parameters:
  • app_name (str) – Name of the application.

  • app_author (str, optional) – Name of the application author.

  • filename (str, optional) – Name of the settings file. Defaults to ‘settings.json’.

Return type:

None

get_nested(keys, default=None) Any

Retrieve a nested value using a sequence of keys.

Parameters:
  • keys (Sequence) – An sequence of keys representing the nested path.

  • default (Any, optional) – The value to return if the path does not exist. Defaults to None.

Returns:

The value at the nested path, or default if any key in the path is missing.

Return type:

Any

set_nested(keys, value) None

Set a nested value using a sequence of keys.

Parameters:
  • keys (Sequence) – An sequence of keys representing the nested path.

  • value (Any) – The value to set at the nested path.

Return type:

None