read_config
- opthandler.read_config(conf_file='hpcssrc.ini')[source]
Search and read options from a Configuration File.
- Parameters:
conf_file (
str
, optional) – The name of the Configuration File. The config file must be written in INI language as supported by the built-inconfigparser
Python module.- Returns:
config (
configparser.ConfigParser
) – AConfigParser
instance containing the configuration read from the first found config file. If no config file was found, an emptyConfigParser
is returned.
Notes
This function searches for the config file in the following order at the following locations:
At the location given by conf_file. If this is a relative path, it is interpreted relative to the current working directory.
At
$HOME/.hpcss/hpcssrc.ini
(where$HOME
is the user’s home directory).In the root directory of the hpc_submit_scripts repository.
As soon as a config file is found, this config file is read and other locations are not scanned anymore. If no config file is found at all, this function returns an empty
ConfigParser
.Note that
ConfigParser
instances always store options and their values as strings. However, unlike the defaultConfigParser
, the returnedConfigParser
reads option names case-sensitively. Moreover, section names are case-insensitive and leading and trailing spaces are removed.