Configuration.config.Config¶
- class Configuration.config.Config¶
Loader for the base device configuration file.
Reads and parses
Configuration/config.jsonon instantiation, making the resulting dictionary available via theconfigattribute.- Variables:
config (
dict) – Parsed contents ofconfig.json. Contains base settings such as sampling intervals, device identifiers, and default parameter configurations shared by all sensor wrappers.
Example
Instantiate the loader and read a configured value:
>>> from Configuration.config import Config >>> cfg = Config() >>> isinstance(cfg.config, dict) True
Note
Construction performs blocking filesystem I/O against
Configuration/config.jsonand is intended to run once at firmware start-up on the target Raspberry Pi device.Load
Configuration/config.jsonintoconfig.Resolves the JSON file path relative to this module’s directory, opens it in text mode, parses it with
json.load(), and stores the resulting mapping on the instance asconfig.- Returns:
This initializer mutates instance state and returns nothing.
- Return type:
None
- Raises:
FileNotFoundError – If
Configuration/config.jsondoes not exist next to this module on disk.PermissionError – If the process cannot read the configuration file (for example, due to filesystem permissions on the target device).
json.JSONDecodeError – If the configuration file contents are not valid JSON.
Example
Construct the loader and access the parsed settings:
>>> from Configuration.config import Config >>> cfg = Config() >>> cfg.config {...}
Note
This method touches the filesystem, so doctest examples that instantiate
Configare marked# doctest: +SKIPto keep the test suite hardware- and device-independent.