hvl_ccb.configuration
digraph inheritance2bdefda9ca { bgcolor=transparent; rankdir=TB; size=""; "ABC" [fillcolor=white,fontname="Vera Sans, DejaVu Sans, Liberation Sans, Arial, Helvetica, sans",fontsize=10,height=0.25,shape=box,style="setlinewidth(0.5),filled",tooltip="Helper class that provides a standard way to create an ABC using"]; "ConfigurationMixin" [URL="../hvl_ccb.configuration.html#hvl_ccb.configuration.ConfigurationMixin",fillcolor=white,fontname="Vera Sans, DejaVu Sans, Liberation Sans, Arial, Helvetica, sans",fontsize=10,height=0.25,shape=box,style="setlinewidth(0.5),filled",target="_top",tooltip="Mixin providing configuration to a class."]; "ABC" -> "ConfigurationMixin" [arrowsize=0.5,style="setlinewidth(0.5)"]; "ConfigurationValueWarning" [URL="../hvl_ccb.configuration.html#hvl_ccb.configuration.ConfigurationValueWarning",fillcolor=white,fontname="Vera Sans, DejaVu Sans, Liberation Sans, Arial, Helvetica, sans",fontsize=10,height=0.25,shape=box,style="setlinewidth(0.5),filled",target="_top",tooltip="User warnings category for values of `@configdataclass` fields."]; "EmptyConfig" [URL="../hvl_ccb.configuration.html#hvl_ccb.configuration.EmptyConfig",fillcolor=white,fontname="Vera Sans, DejaVu Sans, Liberation Sans, Arial, Helvetica, sans",fontsize=10,height=0.25,shape=box,style="setlinewidth(0.5),filled",target="_top",tooltip="Empty configuration dataclass."]; }Facilities providing classes for handling configuration for communication protocols and devices.
- class ConfigurationMixin(configuration)[source]
Bases:
ABC
Mixin providing configuration to a class.
- property config
ConfigDataclass property.
- Returns:
the configuration
- abstract static config_cls()[source]
Return the default configdataclass class.
- Returns:
a reference to the default configdataclass class
- exception ConfigurationValueWarning[source]
Bases:
UserWarning
User warnings category for values of @configdataclass fields.
- class EmptyConfig[source]
Bases:
object
Empty configuration dataclass.
- clean_values()
Cleans and enforces configuration values. Does nothing by default, but may be overridden to add custom configuration value checks.
- force_value(fieldname, value)
Forces a value to a dataclass field despite the class being frozen.
NOTE: you can define post_force_value method with same signature as this method to do extra processing after value has been forced on fieldname.
- Parameters:
fieldname – name of the field
value – value to assign
- is_configdataclass = True
- classmethod keys() Sequence[str]
Returns a list of all configdataclass fields key-names.
- Returns:
a list of strings containing all keys.
- classmethod optional_defaults() dict[str, object]
Returns a list of all configdataclass fields, that have a default value assigned and may be optionally specified on instantiation.
- Returns:
a list of strings containing all optional keys.
- classmethod required_keys() Sequence[str]
Returns a list of all configdataclass fields, that have no default value assigned and need to be specified on instantiation.
- Returns:
a list of strings containing all required keys.
- configdataclass(direct_decoration=None, frozen=True)[source]
Decorator to make a class a configdataclass. Types in these dataclasses are enforced. Implement a function clean_values(self) to do additional checking on value ranges etc.
It is possible to inherit from a configdataclass and re-decorate it with @configdataclass. In a subclass, default values can be added to existing fields. Note: adding additional non-default fields is prone to errors, since the order has to be respected through the whole chain (first non-default fields, only then default-fields).
- Parameters:
frozen – defaults to True. False allows to later change configuration values. Attention: if configdataclass is not frozen and a value is changed, typing is not enforced anymore!