8.4.5. pymodaq_utils.config module
- class pymodaq_utils.config.BaseConfig(*args, **kwargs)[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_path
Get the user config path
- system_config_path
Get 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 configuration toml file
load()Load a configuration file from both system-wide and user file check also if missing entries in the configuration file compared to the template
save()Save the current Config object into the user toml file and reload it
Convert this object to a xml string representing it as a Parameter Tree
get
to_dict
- get_children(*path)[source]
Get the list of config entries at a given path within the configuration toml file
new in 4.3.0
- load()[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
- to_xml_string()[source]
Convert this object to a xml string representing it as a Parameter Tree
pymodaq_gui is necessary for this purpose
- Return type:
- property config_path
Get the user config path
- property system_config_path
Get the system_wide config path
- class pymodaq_utils.config.CacheConfig(*args, **kwargs)[source]
Bases:
BaseConfig
- class pymodaq_utils.config.Config(*args, **kwargs)[source]
Bases:
BaseConfigMain class to deal with configuration values for PyMoDAQ
Methods
__call__(*args)To subclass
- class pymodaq_utils.config.ConfigSingleton[source]
Bases:
SingletonMethods
__call__(*args, **kwargs)
- class pymodaq_utils.config.GlobalConfig(*args, **kwargs)[source]
Bases:
object- Attributes:
- config_path
Get the user config path
- system_config_path
Get the system_wide config path
Methods
__call__(*args)register()To be used as a decorator
add_config
get
save
to_dict
- classmethod register()[source]
To be used as a decorator
Register in the config registry a new config class using its name
- Return type:
- property config_path
Get the user config path
- property system_config_path
Get the system_wide config path
- 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