bpod_core.misc.SettingsDict

class bpod_core.misc.SettingsDict

Bases: MutableMapping

A dictionary-like persistent settings storage backed by a JSON file.

This class implements the MutableMapping interface, storing key-value pairs that are automatically persisted to a JSON file on every write. It supports standard dictionary operations (get, set, delete, iterate) as well as nested key access.

File access is protected by a file lock for safe concurrent access from multiple processes.

__init__(json_path) None

Initialize the SettingsDict instance.

Parameters:

json_path (PathLike or str) – Path to the JSON configuration file.

Return type:

None

get_nested(keys, default=None) Any

Retrieve a nested value using a sequence of keys.

Parameters:
  • keys (Sequence) – A 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) – A sequence of keys representing the nested path.

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

Return type:

None