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):

Initializes the configuration.

def cleanup(self):

Perform clean-up.

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

Gets boolean value, convert from string.

Parameters
key:strKey
Returns
boolValue
def get_float(self, key: str) -> float:

Gets float value, convert from string.

Parameters
key:strKey
Returns
floatValue
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:strKey
_type:strData 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:strKey
Returns
intValue
def get_point(self, key: str) -> list[float]:

Gets a single 3D point, convert from string.

Parameters
key:strKey
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:strKey
Returns
list[list[float]]List of 3D points
def get_str(self, key: str) -> str:

Reads a configuration value.

Parameters
key:strKey
Returns
strValue
def load(self, default_config: dict, signal_changed: bool = True):

Loads the default configuration.

Parameters
default_config:dictDefault configuration
signal_changed:boolUndocumented
def load_file(self, filename: str, default_config: dict):

Loads the configuration from file.

Parameters
filename:strFilename
default_config:dictDefault configuration
@abc.abstractmethod
def on_changed(self):

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

def remove_key(self, key: str):

Removes a key from the configuration.

Parameters
key:strKey
def save_file(self, filename: str | None = None):

Saves the configuration to file.

Parameters
filename:str | NoneFilename (optional)
def set_bool(self, key: str, value: bool):

Sets boolean value, convert to string.

Parameters
key:strKey
value:boolValue
def set_float(self, key: str, value: float):

Sets float value, convert to string.

Parameters
key:strKey
value:floatValue
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:strKey
_type:strData 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:strKey
value:boolValue
Returns
boolUndocumented
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:strPrefix
suffix:strSuffix
types:dictKey:Type (Dictionary)
values:dict | NoneKey:Value (Dictionary)
Returns
dictUndocumented
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:strKey
value:floatValue
Returns
floatUndocumented
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:strKey
value:intValue
Returns
intUndocumented
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:strKey
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:strKey
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:strKey
value:strValue
Returns
strUndocumented
def set_int(self, key: str, value: int):

Sets integer value, convert to string.

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

Sets a single 3D point, convert to string.

Parameters
key:strKey
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:strKey
value:np.ndarray | list[list[float]]List of 3D points
def set_str(self, key: str, value: str):

Writes a configuration value.

Parameters
key:strKey
value:strValue
DebugAccess: bool =

Undocumented

filename: str | None =

Undocumented

synced: bool =

Undocumented

_parser: configparser.ConfigParser | None =

Undocumented