8.4.5. pymodaq_utils.config module
- class pymodaq_utils.config.BaseConfig[source]
Bases:
objectBase class to manage configuration files
Should be subclassed with proper class attributes for each configuration file you need with pymodaq
- config_template_path
The Path of the template from which the config is constructed
- Type:
Path
- Attributes:
- config_name
config_pathGet the user config path
- config_template_path
system_config_pathGet the system_wide config path
Methods
__call__(*args)To subclass
get_children(*path)Get the list of config entries at a given path within the configulation toml file
load_config(config_file_name, template_path)Load a configuration file from both system-wide and user file
save()Save the current Config object into the user toml file
get
to_dict
- get_children(*path)[source]
Get the list of config entries at a given path within the configulation toml file
new in 4.3.0
- load_config(config_file_name, template_path)[source]
Load a configuration file from both system-wide and user file
check also if missing entries in the configuration file compared to the template
- abstract property config_name
- property config_path
Get the user config path
- abstract property config_template_path
- property system_config_path
Get the system_wide config path
- class pymodaq_utils.config.Config[source]
Bases:
BaseConfigMain class to deal with configuration values for PyMoDAQ
Methods
__call__(*args)Patch in case of a mixup of configs from different version of pymodaq: v5.1 and v5.2
To subclass
- pymodaq_utils.config.check_config(config_base, config_local)[source]
Compare two configuration dictionaries. Adding missing keys
- pymodaq_utils.config.copy_template_config(config_file_name='config', source_path=None, dest_path=None)[source]
Get a toml file path and copy it
the destination is made of a given folder path (or the system-wide local path by default) and the config_file_name appended by the suffix ‘.toml’
The source file (or pymodaq config template path by default) is read and dumped in this destination file
- pymodaq_utils.config.create_toml_from_dict(mydict, dest_path)[source]
Create a Toml file at a given path from a dictionnary
- pymodaq_utils.config.deep_update(mapping, *updating_mappings)[source]
Make sure a dictionary is updated using another dict in any nested level Taken from Pydantic v1
- pymodaq_utils.config.get_set_config_dir(config_name='config', user=False)[source]
Creates a folder in the local config directory to store specific configuration files
- Parameters:
config_name (
(str) nameofthe configuration folder)user (
bool) – if False get the system-wide folder, otherwise the user folder
- Return type:
Path
See also
- pymodaq_utils.config.get_set_local_dir(user=False)[source]
Defines, creates and returns a local folder where configuration files will be saved
Depending on the os the configurations files will be stored in CONFIG_BASE_PATH, then each user will have another one created that could override the default and system-wide base folder
- pymodaq_utils.config.get_set_log_path()[source]
creates and return the config folder path for log files
- pymodaq_utils.config.getitem_recursive(dic, *args, ndepth=0, create_if_missing=False)[source]
Will scan recursively a dictionary in order to get the item defined by the iterable args
- Parameters:
dic (
dict) – the dictionary to scanargs (
an iterableofstr) – keys of the dictndepth (
int) – by default (0) get the last element defined by args. 1 would mean it get the parent dict, 2 the parent of the parent…create_if_missing (
bool) – if the entry is not present, create it assigning the ‘none’ default value (as a lower case string)
- Return type:
- pymodaq_utils.config.load_system_config_and_update_from_user(config_file_name)[source]
load from a system-wide config file, update it from the user config file
- Parameters:
config_file_name (
str) – The config file to be loaded- Returns:
dict
- Return type:
contains the toml system-wide file update with the user file