devctrl.data.data.DataAttributes#
- class DataAttributes(writer: str, write_version: str, measurement_type: str, data_version: str, time_created: float = <factory>, time_modified: float = <factory>)[source]#
Bases:
SettingsClassMethods
Convenience wrapper for dataclasses.asdict(self)
Convenience method for copy.deepcopy(self)
Return a tuple describing the fields of this dataclass.
Recursively construct a
SettingsClassfrom a dictionary.Return the settings as a dictionary.
Attributes
Name of the software which wrote this data.
Version of the software.
Type of the data that is saved.
Version string of the format that is saved.
Unix timestamp from when this data was initially written
Unix timestamp from when this data was last modified
- __annotations__ = {'data_version': <class 'str'>, 'measurement_type': <class 'str'>, 'time_created': <class 'float'>, 'time_modified': <class 'float'>, 'write_version': <class 'str'>, 'writer': <class 'str'>}#
- __dataclass_fields__ = {'data_version': Field(name='data_version',type=<class 'str'>,default=<dataclasses._MISSING_TYPE object>,default_factory=<dataclasses._MISSING_TYPE object>,init=True,repr=True,hash=None,compare=True,metadata=mappingproxy({}),kw_only=False,_field_type=_FIELD), 'measurement_type': Field(name='measurement_type',type=<class 'str'>,default=<dataclasses._MISSING_TYPE object>,default_factory=<dataclasses._MISSING_TYPE object>,init=True,repr=True,hash=None,compare=True,metadata=mappingproxy({}),kw_only=False,_field_type=_FIELD), 'time_created': Field(name='time_created',type=<class 'float'>,default=<dataclasses._MISSING_TYPE object>,default_factory=<built-in function time>,init=True,repr=True,hash=None,compare=True,metadata=mappingproxy({}),kw_only=False,_field_type=_FIELD), 'time_modified': Field(name='time_modified',type=<class 'float'>,default=<dataclasses._MISSING_TYPE object>,default_factory=<built-in function time>,init=True,repr=True,hash=None,compare=True,metadata=mappingproxy({}),kw_only=False,_field_type=_FIELD), 'write_version': Field(name='write_version',type=<class 'str'>,default=<dataclasses._MISSING_TYPE object>,default_factory=<dataclasses._MISSING_TYPE object>,init=True,repr=True,hash=None,compare=True,metadata=mappingproxy({}),kw_only=False,_field_type=_FIELD), 'writer': Field(name='writer',type=<class 'str'>,default=<dataclasses._MISSING_TYPE object>,default_factory=<dataclasses._MISSING_TYPE object>,init=True,repr=True,hash=None,compare=True,metadata=mappingproxy({}),kw_only=False,_field_type=_FIELD)}#
- __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.data.data', '__firstlineno__': 30, '__annotations__': {'writer': <class 'str'>, 'write_version': <class 'str'>, 'measurement_type': <class 'str'>, 'data_version': <class 'str'>, 'time_created': <class 'float'>, 'time_modified': <class 'float'>}, '__static_attributes__': (), '__doc__': 'DataAttributes(writer: str, write_version: str, measurement_type: str, data_version: str, time_created: float = <factory>, time_modified: float = <factory>)', '__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__': {'writer': Field(name='writer',type=<class 'str'>,default=<dataclasses._MISSING_TYPE object>,default_factory=<dataclasses._MISSING_TYPE object>,init=True,repr=True,hash=None,compare=True,metadata=mappingproxy({}),kw_only=False,_field_type=_FIELD), 'write_version': Field(name='write_version',type=<class 'str'>,default=<dataclasses._MISSING_TYPE object>,default_factory=<dataclasses._MISSING_TYPE object>,init=True,repr=True,hash=None,compare=True,metadata=mappingproxy({}),kw_only=False,_field_type=_FIELD), 'measurement_type': Field(name='measurement_type',type=<class 'str'>,default=<dataclasses._MISSING_TYPE object>,default_factory=<dataclasses._MISSING_TYPE object>,init=True,repr=True,hash=None,compare=True,metadata=mappingproxy({}),kw_only=False,_field_type=_FIELD), 'data_version': Field(name='data_version',type=<class 'str'>,default=<dataclasses._MISSING_TYPE object>,default_factory=<dataclasses._MISSING_TYPE object>,init=True,repr=True,hash=None,compare=True,metadata=mappingproxy({}),kw_only=False,_field_type=_FIELD), 'time_created': Field(name='time_created',type=<class 'float'>,default=<dataclasses._MISSING_TYPE object>,default_factory=<built-in function time>,init=True,repr=True,hash=None,compare=True,metadata=mappingproxy({}),kw_only=False,_field_type=_FIELD), 'time_modified': Field(name='time_modified',type=<class 'float'>,default=<dataclasses._MISSING_TYPE object>,default_factory=<built-in function time>,init=True,repr=True,hash=None,compare=True,metadata=mappingproxy({}),kw_only=False,_field_type=_FIELD)}, '__replace__': <function _replace>, '__hash__': None, '__init__': <function DataAttributes.__init__>, '__repr__': <function DataAttributes.__repr__>, '__eq__': <function DataAttributes.__eq__>, '__match_args__': ('writer', 'write_version', 'measurement_type', 'data_version', 'time_created', 'time_modified')})#
- __eq__(other)#
Return self==value.
- __firstlineno__ = 30#
- __hash__ = None#
- __init__(writer: str, write_version: str, measurement_type: str, data_version: str, time_created: float = <factory>, time_modified: float = <factory>) None#
- __match_args__ = ('writer', 'write_version', 'measurement_type', 'data_version', 'time_created', 'time_modified')#
- __module__ = 'devctrl.data.data'#
- __or__(other)#
Merge with another settings class or a dictionary. Unknown keys in a dictionary are ignored.
- __replace__(**changes)#
- __repr__()#
Return repr(self).
- __static_attributes__ = ()#
- __weakref__#
list of weak references to the object
- _get_dict(remove_empty_containers: bool = False, remove_None: bool = False, remove_if_None: list[str] | None = None) dict#
Return the settings as a dictionary, optionally cleaning up the output.
Base implementation for
get_dict(). Subclasses may call it with different arguments to configure the output.- Parameters:
remove_empty_containers – If True, remove empty
dict,list,tupleorsetvalues.remove_None – If True, remove all keys with a
Nonevalue.remove_if_None – If given, remove these keys only if their value is
None(absent keys are ignored).
- Returns:
Instance converted to dictionary, see
as_dict().
- as_dict() dict#
Convenience wrapper for dataclasses.asdict(self)
Returns all fields of the settings class. For a dictionary where certain fields may be skipped, see
get_dict().
- copy() Self#
Convenience method for copy.deepcopy(self)
- data_version: str#
Version string of the format that is saved.
- fields()#
Return a tuple describing the fields of this dataclass.
Adapted version of dataclass.fields that applies additional sorting of the fields according to the field’s metadata[“order”] parameter.
Accepts a dataclass or an instance of one. Tuple elements are of type Field.
- classmethod from_dict(data: dict, strict: bool = False) Self#
Recursively construct a
SettingsClassfrom 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 (Union with
None)a Union with any handled types
- Parameters:
strict – If True, raise a KeyError on keys in
datathat are not field names ofcls. Unknown keys are ignored otherwise.- Raises:
- get_dict() dict#
Return the settings as a dictionary.
as_dict()returns the settings class with all fields, whileget_dict()may be configured by subclasses to skip certain fields in the output. The default implementation returns all fields, likeas_dict(). :return: Instance converted to dictionary.
- classmethod load_yaml(yaml_path: str, loader=<class 'yaml.loader.Loader'>)#
- measurement_type: str#
Type of the data that is saved.
- save_yaml(yaml_path: str)#
- time_created: float#
Unix timestamp from when this data was initially written
- time_modified: float#
Unix timestamp from when this data was last modified
- write_version: str#
Version of the software.
- writer: str#
Name of the software which wrote this data.