devctrl.utility.settings.SettingsClass#

class SettingsClass[source]#

Bases: object

Base class for settings classes.

Use the @dataclass decorator on sub-classes as well. Data class with extra features: - __or__ operator - instantiate from dictionary - load/save from/to yaml

Methods

as_dict

Convenience wrapper for dataclasses.asdict(self)

from_dict

Recursively construct a SettingsClass from a dictionary.

load_yaml

save_yaml

__annotations__ = {}#
__dataclass_fields__ = {}#
__dataclass_params__ = _DataclassParams(init=True,repr=True,eq=True,order=False,unsafe_hash=False,frozen=False,match_args=True,kw_only=False,slots=False,weakref_slot=False)#
__dict__ = mappingproxy({'__module__': 'devctrl.utility.settings', '__firstlineno__': 29, '__doc__': 'Base class for settings classes.\n\nUse the @dataclass decorator on sub-classes as well.\nData class with extra features:\n- __or__ operator\n- instantiate from dictionary\n- load/save from/to yaml\n', '__or__': <function SettingsClass.__or__>, 'from_dict': <classmethod(<function SettingsClass.from_dict>)>, 'load_yaml': <classmethod(<function SettingsClass.load_yaml>)>, 'save_yaml': <function SettingsClass.save_yaml>, 'as_dict': <function SettingsClass.as_dict>, '__static_attributes__': (), '__dict__': <attribute '__dict__' of 'SettingsClass' objects>, '__weakref__': <attribute '__weakref__' of 'SettingsClass' objects>, '__dataclass_params__': _DataclassParams(init=True,repr=True,eq=True,order=False,unsafe_hash=False,frozen=False,match_args=True,kw_only=False,slots=False,weakref_slot=False), '__dataclass_fields__': {}, '__replace__': <function _replace>, '__hash__': None, '__init__': <function SettingsClass.__init__>, '__repr__': <function SettingsClass.__repr__>, '__eq__': <function SettingsClass.__eq__>, '__match_args__': (), '__annotations__': {}})#
__eq__(other)#

Return self==value.

__firstlineno__ = 29#
__hash__ = None#
__init__() None#
__match_args__ = ()#
__module__ = 'devctrl.utility.settings'#
__or__(other)[source]#

Merge with another settings class or a dictionary.

__replace__(**changes)#
__repr__()#

Return repr(self).

__static_attributes__ = ()#
__weakref__#

list of weak references to the object

as_dict() dict[source]#

Convenience wrapper for dataclasses.asdict(self)

classmethod from_dict(data: dict)[source]#

Recursively construct a SettingsClass from a dictionary. If the value of a field is another SettingsClass, from_dict will be called for that field as well. Handled are: - SettingsClass - list[SettingsClass] - dict[<any>, SettingsClass] - all of the above as Optional

Raises:
  • ValueError – If data contains a value that has the wrong type for the field of cls (ONLY if the type is a subclass of SettingsClass! Other types are not enforced)

  • KeyError – If data contains a key that is not a field name of cls

classmethod load_yaml(yaml_path: str, loader=<class 'yaml.loader.Loader'>)[source]#
save_yaml(yaml_path: str)[source]#