dival.config module¶
Configuration of the library.
The module variable CONFIG
holds the current configuration.
The library configuration is stored in the file ~/.dival/config.json
.
If the config file does not exist when the library is imported, it is created
using default values.
Changes made in config.json
are loaded when the library is (re-)imported.
-
dival.config.
CONFIG
= {'lodopab_dataset': {'data_path': '/localdata/low_dose_dataset'}, 'reference_params': {'data_path': '~/.dival/reference_params'}}¶ Global configuration dict.
Holds the current configuration of the library. On
import dival
, the configuration is loaded from~/.dival/config.json
.
-
dival.config.
CONFIG_FILENAME
= '/home/jleuschn/.dival/config.json'¶ Path of the configuration file. The value is given by
'~/.dival/config.json'
, expanded and normalized.
-
dival.config.
get_config
(key_path='/')[source]¶ Return (sub-)configuration stored in config file. Note that values may differ from the current
CONFIG
variable if it was manipulated directly.- Parameters
key_path (str, optional) –
'/'
-separated path to sub-configuration. Default is'/'
, which returns the full configuration dict.- Returns
(sub-)configuration, either a dict or a value
- Return type
sub_config
-
dival.config.
set_config
(key_path, value, verbose=True)[source]¶ Updates (sub-)configuration both in
CONFIG
variable and in config file.- Parameters
key_path (str, optional) –
'/'
-separated path to sub-configuration. Pass'/'
to replace the full configuration dict.value (object) – (sub-)configuration value. Either a dict, which is copied, or a value.