9.2.6. Utils¶
General utilities and helpers.
- class junifer.utils.ConfigManager(*args, **kwargs)¶
Manage configuration parameters.
- Attributes:
- _config
dict Configuration parameters.
- _config
Initialize the class.
- get(key, default=None)¶
Get configuration parameter.
- junifer.utils.check_standardize(value)¶
Check the value of a
standardizeparameter.Booleans were replaced by the strategy names used by nilearn, so they raise an error explaining the change instead of a generic validation error.
- Parameters:
- value
Any The value of the parameter.
- value
- Returns:
AnyThe value of the parameter.
- Raises:
ValueErrorIf
valueis a boolean.
- junifer.utils.configure_logging(level='WARNING', level_datalad=None)¶
Configure the logging functionality.
- Parameters:
- level
intor {“DEBUG”, “INFO”, “WARNING”, “ERROR”} The level of the messages to print. If string, it will be interpreted as elements of logging (default “WARNING”).
- level_datalad
intor {“DEBUG”, “INFO”, “WARNING”, “ERROR”}, optional The level of the messages to print for datalad. If string, it will be interpreted as elements of logging. If None, it will be set as the
levelparameter (default None).
- level
- junifer.utils.deep_update(d, u)¶
Deep update d with u.
From: “https://stackoverflow.com/questions/3232943/update-value-of-a-nested -dictionary-of-varying-depth”
- junifer.utils.ensure_list(value)¶
Ensure list.
- junifer.utils.ensure_list_or_none(value)¶
Ensure list or None.
- junifer.utils.make_executable(path)¶
Make
pathexecutable.- Parameters:
- path
pathlib.Path The path to make executable.
- path
- junifer.utils.raise_error(msg, klass=<class 'ValueError'>, exception=None)¶
Raise error, but first log it.
- junifer.utils.run_ext_cmd(name, cmd, cwd=None)¶
Run external command via subprocess.
- Parameters:
- name
str The name of the command.
- cmd
listofstr The command to run as list of string.
- cwd
pathlib.PathorNone, optional The directory to run the command in, e.g., for commands that write extra files in the current directory. If None, the current directory is used (default None).
- name
- Raises:
RuntimeErrorIf command fails.