magneticalc.Config.Config

# ``magneticalc`.`Config`.`Config``

class documentation

`class Config:`

Known subclasses: `magneticalc.Project.Project`

Constructor: `Config()`

View In Hierarchy

Config class.

Method | `__init__` | Initializes the configuration.
Method | `cleanup` | Perform clean-up.
Method | `get_bool` | Gets boolean value, convert from string.
Method | `get_float` | Gets float value, convert from string.
Method | `get_generic` | Gets some "_key"-"_value" of data type "_type".
Method | `get_int` | Gets integer value, convert from string.
Method | `get_point` | Gets a single 3D point, convert from string.
Method | `get_points` | Gets list of 3D points, convert from string.
Method | `get_str` | Reads a configuration value.
Method | `load` | Loads the default configuration.
Method | `load_file` | Loads the configuration from file.
Method | `on_changed` | Gets called when the configuration was loaded, saved or changed.
Method | `remove_key` | Removes a key from the configuration.
Method | `save_file` | Saves the configuration to file.
Method | `set_bool` | Sets boolean value, convert to string.
Method | `set_float` | Sets float value, convert to string.
Method | `set_generic` | Sets some "_key"-"_value" of data type "_type".
Method | `set_get_bool` | If value is not None, writes and returns key-value; otherwise (if value is None), reads and returns key-value.
Method | `set_get_dict` | If "values" is None, reads and returns all key-values in "types". Note: The actual keys saved in the configuration file are prefixed with "prefix", and suffixed with "suffix".
Method | `set_get_float` | If value is not None, writes and returns key-value; otherwise (if value is None), reads and returns key-value.
Method | `set_get_int` | If value is not None, writes and returns key-value; otherwise (if value is None), reads and returns key-value.
Method | `set_get_point` | If value is not None, writes and returns key-value; otherwise (if value is None), reads and returns key-value.
Method | `set_get_points` | If value is not None, writes and returns key-value; otherwise (if value is None), reads and returns key-value.
Method | `set_get_str` | If value is not None, writes and returns key-value; otherwise (if value is None), reads and returns key-value.
Method | `set_int` | Sets integer value, convert to string.
Method | `set_point` | Sets a single 3D point, convert to string.
Method | `set_points` | Sets list of 3D points, convert to string.
Method | `set_str` | Writes a configuration value.
Class Variable | `DebugAccess` | Undocumented
Instance Variable | `filename` | Undocumented
Instance Variable | `synced` | Undocumented
Instance Variable | `_parser` | Undocumented

def __init__(self):
overridden in `magneticalc.Project.Project`

Initializes the configuration.

def cleanup(self):

Perform clean-up.

def get_bool(self, key: `str`) -> `bool`:

Gets boolean value, convert from string.

Parameters
key: `str` | Key

Returns
`bool` | Value

def get_float(self, key: `str`) -> `float`:

Gets float value, convert from string.

Parameters
key: `str` | Key

Returns
`float` | Value

def get_generic(self, _key: `str`, _type: `str`) -> `str | bool | int | float | np.ndarray | list[float] | list[list[float]]`:

Gets some "_key"-"_value" of data type "_type".

Parameters
_key: `str` | Key
_type: `str` | Data type

Returns
`str | bool | int | float | np.ndarray | list[float] | list[list[float]]` | Data (type determined by "_type")

def get_int(self, key: `str`) -> `int`:

Gets integer value, convert from string.

Parameters
key: `str` | Key

Returns
`int` | Value

def get_point(self, key: `str`) -> `list[float]`:

Gets a single 3D point, convert from string.

Parameters
key: `str` | Key

Returns
`list[float]` | Single 3D point

def get_points(self, key: `str`) -> `list[list[float]]`:

Gets list of 3D points, convert from string.

Parameters
key: `str` | Key

Returns
`list[list[float]]` | List of 3D points

def get_str(self, key: `str`) -> `str`:

Reads a configuration value.

Parameters
key: `str` | Key

Returns
`str` | Value

def load(self, default_config: `dict`, signal_changed: `bool` = True):

Loads the default configuration.

Parameters
default_config: `dict` | Default configuration
signal_changed: `bool` | Undocumented

def load_file(self, filename: `str`, default_config: `dict`):

Loads the configuration from file.

Parameters
filename: `str` | Filename
default_config: `dict` | Default configuration

@abc.abstractmethod
def on_changed(self):
overridden in `magneticalc.Project.Project`

Gets called when the configuration was loaded, saved or changed.

def remove_key(self, key: `str`):

Removes a key from the configuration.

Parameters
key: `str` | Key

def save_file(self, filename: `str | None` = None):

Saves the configuration to file.

Parameters
filename: `str | None` | Filename (optional)

def set_bool(self, key: `str`, value: `bool`):

Sets boolean value, convert to string.

Parameters
key: `str` | Key
value: `bool` | Value

def set_float(self, key: `str`, value: `float`):

Sets float value, convert to string.

Parameters
key: `str` | Key
value: `float` | Value

def set_generic(self, _key: `str`, _type: `str`, _value: `str | bool | int | float | np.ndarray | list[float] | list[list[float]]`):

Sets some "_key"-"_value" of data type "_type".

Parameters
_key: `str` | Key
_type: `str` | Data type
_value: `str | bool | int | float | np.ndarray | list[float] | list[list[float]]` | Data (type determined by "_type")

def set_get_bool(self, key: `str`, value: `bool`) -> `bool`:

If value is not None, writes and returns key-value; otherwise (if value is None), reads and returns key-value.

Parameters
key: `str` | Key
value: `bool` | Value

Returns
`bool` | Undocumented

def set_get_dict(self, prefix: `str`, suffix: `str`, types: `dict`, values: `dict | None`) -> `dict`:

If "values" is None, reads and returns all key-values in "types". Note: The actual keys saved in the configuration file are prefixed with "prefix", and suffixed with "suffix".

If "values" is not None, writes and returns all key-values in "types". Note: In this case, "values" must have the same keys as "types".

Parameters
prefix: `str` | Prefix
suffix: `str` | Suffix
types: `dict` | Key:Type (Dictionary)
values: `dict | None` | Key:Value (Dictionary)

Returns
`dict` | Undocumented

def set_get_float(self, key: `str`, value: `float`) -> `float`:

If value is not None, writes and returns key-value; otherwise (if value is None), reads and returns key-value.

Parameters
key: `str` | Key
value: `float` | Value

Returns
`float` | Undocumented

def set_get_int(self, key: `str`, value: `int`) -> `int`:

If value is not None, writes and returns key-value; otherwise (if value is None), reads and returns key-value.

Parameters
key: `str` | Key
value: `int` | Value

Returns
`int` | Undocumented

def set_get_point(self, key: `str`, value: `np.ndarray | list[float]`) -> `np.ndarray | list[float]`:

If value is not None, writes and returns key-value; otherwise (if value is None), reads and returns key-value.

Parameters
key: `str` | Key
value: `np.ndarray | list[float]` | Value

Returns
`np.ndarray | list[float]` | Undocumented

def set_get_points(self, key: `str`, value: `np.ndarray | list[list[float]]`) -> `np.ndarray | list[list[float]]`:

If value is not None, writes and returns key-value; otherwise (if value is None), reads and returns key-value.

Parameters
key: `str` | Key
value: `np.ndarray | list[list[float]]` | Value

Returns
`np.ndarray | list[list[float]]` | Undocumented

def set_get_str(self, key: `str`, value: `str`) -> `str`:

If value is not None, writes and returns key-value; otherwise (if value is None), reads and returns key-value.

Parameters
key: `str` | Key
value: `str` | Value

Returns
`str` | Undocumented

def set_int(self, key: `str`, value: `int`):

Sets integer value, convert to string.

Parameters
key: `str` | Key
value: `int` | Value

def set_point(self, key: `str`, value: `np.ndarray | list[float]`):

Sets a single 3D point, convert to string.

Parameters
key: `str` | Key
value: `np.ndarray | list[float]` | Single 3D point

def set_points(self, key: `str`, value: `np.ndarray | list[list[float]]`):

Sets list of 3D points, convert to string.

Parameters
key: `str` | Key
value: `np.ndarray | list[list[float]]` | List of 3D points

def set_str(self, key: `str`, value: `str`):

Writes a configuration value.

Parameters
key: `str` | Key
value: `str` | Value

DebugAccess: `bool` =

Undocumented

filename: `str | None` =

Undocumented

synced: `bool` =

Undocumented

_parser: `configparser.ConfigParser | None` =

Undocumented