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.configure_logging(level='WARNING', fname=None, overwrite=None, output_format=None, 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”).
- fname
strorpathlib.Path, optional Filename of the log to print to. If None, stdout is used (default None).
- overwritebool, optional
Overwrite the log file (if it exists). Otherwise, statements will be appended to the log (default). None is the same as False, but additionally raises a warning to notify the user that log entries will be appended (default None).
- output_format
str, optional Format of the output messages. See the following for examples: https://docs.python.org/dev/howto/logging.html e.g.,
"%(asctime)s - %(levelname)s - %(message)s". If None, default string format is used (default"%(asctime)s - %(name)s - %(levelname)s - %(message)s").- 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.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)¶
Run external command via subprocess.
- Parameters:
- Raises:
RuntimeErrorIf command fails.