spvctrl.spvctrl_interactive.SpvInteractiveSettings#
- class SpvInteractiveSettings(data_dir: str | list[str] = '~/Desktop/spvctrl-data', data_dir_cache: str = '~/.cache/spvctrl/data', data_dir_archive: str | list[str] = '~/.cache/spvctrl/archive', archive_file_count_threshold: int = 30, log_dir: str = '~/.cache/spvctrl', compress_data: bool = True, plugin_dir: str | list[str] = '~/.config/spvctrl/plugins', device_connection_infos_path: str = '~/.cache/spvctrl/devices.yaml', system_path_append: list[str] = <factory>, setup_info_db: str = '~/.config/spvctrl/setups.yaml', setup: str = 'default', sample_db: str = '~/.config/spvctrl/samples.yaml')[source]#
Bases:
SettingsClassSettings for the interactive shell, loaded from and saved to the config file.
Methods
Return all fields of the settings class as a dictionary.
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.
Write the settings to the config file.
Attributes
Minimum number of files in a data directory for it to be archived
Whether to gzip-compress the measurement data (with the byte-shuffle filter)
Output directory for data directories containing only the final important files (.tspv, plots, csv).
Directory for zip archives of the entire data directory.
Output directory for the partial files during the measurement
File storing which device type and name was last connected for each device key
Directory user plugins are loaded from.
Path to the sample database file (Sample entries)
Key of the setup-info entry used for measurements, changed via get_setup_info(key) or the setup_db
Path to the setup-info database file (TspvSetupInfo entries)
Paths to insert into the system path (for example for finding required DLLs)
- __annotations__ = {'archive_file_count_threshold': <class 'int'>, 'compress_data': <class 'bool'>, 'data_dir': str | list[str], 'data_dir_archive': str | list[str], 'data_dir_cache': <class 'str'>, 'device_connection_infos_path': <class 'str'>, 'log_dir': <class 'str'>, 'plugin_dir': str | list[str], 'sample_db': <class 'str'>, 'setup': <class 'str'>, 'setup_info_db': <class 'str'>, 'system_path_append': list[str]}#
- __dataclass_fields__ = {'archive_file_count_threshold': Field(name='archive_file_count_threshold',type=<class 'int'>,default=30,default_factory=<dataclasses._MISSING_TYPE object>,init=True,repr=True,hash=None,compare=True,metadata=mappingproxy({}),kw_only=False,_field_type=_FIELD), 'compress_data': Field(name='compress_data',type=<class 'bool'>,default=True,default_factory=<dataclasses._MISSING_TYPE object>,init=True,repr=True,hash=None,compare=True,metadata=mappingproxy({}),kw_only=False,_field_type=_FIELD), 'data_dir': Field(name='data_dir',type=str | list[str],default='~/Desktop/spvctrl-data',default_factory=<dataclasses._MISSING_TYPE object>,init=True,repr=True,hash=None,compare=True,metadata=mappingproxy({}),kw_only=False,_field_type=_FIELD), 'data_dir_archive': Field(name='data_dir_archive',type=str | list[str],default='~/.cache/spvctrl/archive',default_factory=<dataclasses._MISSING_TYPE object>,init=True,repr=True,hash=None,compare=True,metadata=mappingproxy({}),kw_only=False,_field_type=_FIELD), 'data_dir_cache': Field(name='data_dir_cache',type=<class 'str'>,default='~/.cache/spvctrl/data',default_factory=<dataclasses._MISSING_TYPE object>,init=True,repr=True,hash=None,compare=True,metadata=mappingproxy({}),kw_only=False,_field_type=_FIELD), 'device_connection_infos_path': Field(name='device_connection_infos_path',type=<class 'str'>,default='~/.cache/spvctrl/devices.yaml',default_factory=<dataclasses._MISSING_TYPE object>,init=True,repr=True,hash=None,compare=True,metadata=mappingproxy({}),kw_only=False,_field_type=_FIELD), 'log_dir': Field(name='log_dir',type=<class 'str'>,default='~/.cache/spvctrl',default_factory=<dataclasses._MISSING_TYPE object>,init=True,repr=True,hash=None,compare=True,metadata=mappingproxy({}),kw_only=False,_field_type=_FIELD), 'plugin_dir': Field(name='plugin_dir',type=str | list[str],default='~/.config/spvctrl/plugins',default_factory=<dataclasses._MISSING_TYPE object>,init=True,repr=True,hash=None,compare=True,metadata=mappingproxy({}),kw_only=False,_field_type=_FIELD), 'sample_db': Field(name='sample_db',type=<class 'str'>,default='~/.config/spvctrl/samples.yaml',default_factory=<dataclasses._MISSING_TYPE object>,init=True,repr=True,hash=None,compare=True,metadata=mappingproxy({}),kw_only=False,_field_type=_FIELD), 'setup': Field(name='setup',type=<class 'str'>,default='default',default_factory=<dataclasses._MISSING_TYPE object>,init=True,repr=True,hash=None,compare=True,metadata=mappingproxy({}),kw_only=False,_field_type=_FIELD), 'setup_info_db': Field(name='setup_info_db',type=<class 'str'>,default='~/.config/spvctrl/setups.yaml',default_factory=<dataclasses._MISSING_TYPE object>,init=True,repr=True,hash=None,compare=True,metadata=mappingproxy({}),kw_only=False,_field_type=_FIELD), 'system_path_append': Field(name='system_path_append',type=list[str],default=<dataclasses._MISSING_TYPE object>,default_factory=<class 'list'>,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__': 'spvctrl.spvctrl_interactive', '__firstlineno__': 76, '__annotations__': {'data_dir': str | list[str], 'data_dir_cache': <class 'str'>, 'data_dir_archive': str | list[str], 'archive_file_count_threshold': <class 'int'>, 'log_dir': <class 'str'>, 'compress_data': <class 'bool'>, 'plugin_dir': str | list[str], 'device_connection_infos_path': <class 'str'>, 'system_path_append': list[str], 'setup_info_db': <class 'str'>, 'setup': <class 'str'>, 'sample_db': <class 'str'>}, '__doc__': 'Settings for the interactive shell, loaded from and saved to the config file.', 'data_dir': '~/Desktop/spvctrl-data', 'data_dir_cache': '~/.cache/spvctrl/data', 'data_dir_archive': '~/.cache/spvctrl/archive', 'archive_file_count_threshold': 30, 'log_dir': '~/.cache/spvctrl', 'compress_data': True, 'plugin_dir': '~/.config/spvctrl/plugins', 'device_connection_infos_path': '~/.cache/spvctrl/devices.yaml', 'setup_info_db': '~/.config/spvctrl/setups.yaml', 'setup': 'default', 'sample_db': '~/.config/spvctrl/samples.yaml', 'save': <function SpvInteractiveSettings.save>, '__static_attributes__': (), '__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__': {'data_dir': Field(name='data_dir',type=str | list[str],default='~/Desktop/spvctrl-data',default_factory=<dataclasses._MISSING_TYPE object>,init=True,repr=True,hash=None,compare=True,metadata=mappingproxy({}),kw_only=False,_field_type=_FIELD), 'data_dir_cache': Field(name='data_dir_cache',type=<class 'str'>,default='~/.cache/spvctrl/data',default_factory=<dataclasses._MISSING_TYPE object>,init=True,repr=True,hash=None,compare=True,metadata=mappingproxy({}),kw_only=False,_field_type=_FIELD), 'data_dir_archive': Field(name='data_dir_archive',type=str | list[str],default='~/.cache/spvctrl/archive',default_factory=<dataclasses._MISSING_TYPE object>,init=True,repr=True,hash=None,compare=True,metadata=mappingproxy({}),kw_only=False,_field_type=_FIELD), 'archive_file_count_threshold': Field(name='archive_file_count_threshold',type=<class 'int'>,default=30,default_factory=<dataclasses._MISSING_TYPE object>,init=True,repr=True,hash=None,compare=True,metadata=mappingproxy({}),kw_only=False,_field_type=_FIELD), 'log_dir': Field(name='log_dir',type=<class 'str'>,default='~/.cache/spvctrl',default_factory=<dataclasses._MISSING_TYPE object>,init=True,repr=True,hash=None,compare=True,metadata=mappingproxy({}),kw_only=False,_field_type=_FIELD), 'compress_data': Field(name='compress_data',type=<class 'bool'>,default=True,default_factory=<dataclasses._MISSING_TYPE object>,init=True,repr=True,hash=None,compare=True,metadata=mappingproxy({}),kw_only=False,_field_type=_FIELD), 'plugin_dir': Field(name='plugin_dir',type=str | list[str],default='~/.config/spvctrl/plugins',default_factory=<dataclasses._MISSING_TYPE object>,init=True,repr=True,hash=None,compare=True,metadata=mappingproxy({}),kw_only=False,_field_type=_FIELD), 'device_connection_infos_path': Field(name='device_connection_infos_path',type=<class 'str'>,default='~/.cache/spvctrl/devices.yaml',default_factory=<dataclasses._MISSING_TYPE object>,init=True,repr=True,hash=None,compare=True,metadata=mappingproxy({}),kw_only=False,_field_type=_FIELD), 'system_path_append': Field(name='system_path_append',type=list[str],default=<dataclasses._MISSING_TYPE object>,default_factory=<class 'list'>,init=True,repr=True,hash=None,compare=True,metadata=mappingproxy({}),kw_only=False,_field_type=_FIELD), 'setup_info_db': Field(name='setup_info_db',type=<class 'str'>,default='~/.config/spvctrl/setups.yaml',default_factory=<dataclasses._MISSING_TYPE object>,init=True,repr=True,hash=None,compare=True,metadata=mappingproxy({}),kw_only=False,_field_type=_FIELD), 'setup': Field(name='setup',type=<class 'str'>,default='default',default_factory=<dataclasses._MISSING_TYPE object>,init=True,repr=True,hash=None,compare=True,metadata=mappingproxy({}),kw_only=False,_field_type=_FIELD), 'sample_db': Field(name='sample_db',type=<class 'str'>,default='~/.config/spvctrl/samples.yaml',default_factory=<dataclasses._MISSING_TYPE object>,init=True,repr=True,hash=None,compare=True,metadata=mappingproxy({}),kw_only=False,_field_type=_FIELD)}, '__replace__': <function _replace>, '__hash__': None, '__init__': <function SpvInteractiveSettings.__init__>, '__repr__': <function SpvInteractiveSettings.__repr__>, '__eq__': <function SpvInteractiveSettings.__eq__>, '__match_args__': ('data_dir', 'data_dir_cache', 'data_dir_archive', 'archive_file_count_threshold', 'log_dir', 'compress_data', 'plugin_dir', 'device_connection_infos_path', 'system_path_append', 'setup_info_db', 'setup', 'sample_db')})#
- __eq__(other)#
Return self==value.
- __firstlineno__ = 76#
- __hash__ = None#
- __init__(data_dir: str | list[str] = '~/Desktop/spvctrl-data', data_dir_cache: str = '~/.cache/spvctrl/data', data_dir_archive: str | list[str] = '~/.cache/spvctrl/archive', archive_file_count_threshold: int = 30, log_dir: str = '~/.cache/spvctrl', compress_data: bool = True, plugin_dir: str | list[str] = '~/.config/spvctrl/plugins', device_connection_infos_path: str = '~/.cache/spvctrl/devices.yaml', system_path_append: list[str] = <factory>, setup_info_db: str = '~/.config/spvctrl/setups.yaml', setup: str = 'default', sample_db: str = '~/.config/spvctrl/samples.yaml') None#
- __match_args__ = ('data_dir', 'data_dir_cache', 'data_dir_archive', 'archive_file_count_threshold', 'log_dir', 'compress_data', 'plugin_dir', 'device_connection_infos_path', 'system_path_append', 'setup_info_db', 'setup', 'sample_db')#
- __module__ = 'spvctrl.spvctrl_interactive'#
- __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().
- _reorder_dict(d: dict) dict#
Reorder the keys of a dictionary created by
dataclasses.asdict()to the order offields().Walks the fields of
selfin parallel todand recurses into nestedSettingsClassinstances. All other values are kept as-is.- Parameters:
d – Dictionary as returned by
dataclasses.asdict()for this instance.- Returns:
Dictionary with the same values, but keys ordered like
fields().
- archive_file_count_threshold: int = 30#
Minimum number of files in a data directory for it to be archived
- as_dict() dict#
Return all fields of the settings class as a dictionary.
Like
dataclasses.asdict(), but the keys are ordered likefields(): also the keys of nested SettingsClass instances (as field values and inside lists, tuples and dicts) are ordered by their fields. This waysave_yaml()and other YAML exports write the fields in the same order as they are defined in the class (or reordered bymetadata["order"], like in the GUI).- Returns:
Instance converted to dictionary.
- compress_data: bool = True#
Whether to gzip-compress the measurement data (with the byte-shuffle filter)
- copy() Self#
Convenience method for copy.deepcopy(self)
- data_dir: str | list[str] = '~/Desktop/spvctrl-data'#
Output directory for data directories containing only the final important files (.tspv, plots, csv). May be a list to copy to multiple directories.
- data_dir_archive: str | list[str] = '~/.cache/spvctrl/archive'#
Directory for zip archives of the entire data directory. May be a list to archive to multiple directories.
- data_dir_cache: str = '~/.cache/spvctrl/data'#
Output directory for the partial files during the measurement
- device_connection_infos_path: str = '~/.cache/spvctrl/devices.yaml'#
File storing which device type and name was last connected for each device key
- 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'>)#
- log_dir: str = '~/.cache/spvctrl'#
- plugin_dir: str | list[str] = '~/.config/spvctrl/plugins'#
Directory user plugins are loaded from. May be a list of directories.
- sample_db: str = '~/.config/spvctrl/samples.yaml'#
Path to the sample database file (Sample entries)
- save()[source]#
Write the settings to the config file. Does nothing if no config file is used, i.e. config_path is empty.
- save_yaml(yaml_path: str)#
- setup: str = 'default'#
Key of the setup-info entry used for measurements, changed via get_setup_info(key) or the setup_db
- setup_info_db: str = '~/.config/spvctrl/setups.yaml'#
Path to the setup-info database file (TspvSetupInfo entries)
- system_path_append: list[str]#
Paths to insert into the system path (for example for finding required DLLs)