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-in configparser Python module.

Returns:

config (configparser.ConfigParser) – A ConfigParser instance containing the configuration read from the first found config file. If no config file was found, an empty ConfigParser is returned.

Notes

This function searches for the config file in the following order at the following locations:

  1. At the location given by conf_file. If this is a relative path, it is interpreted relative to the current working directory.

  2. At $HOME/.hpcss/hpcssrc.ini (where $HOME is the user’s home directory).

  3. 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 default ConfigParser, the returned ConfigParser reads option names case-sensitively. Moreover, section names are case-insensitive and leading and trailing spaces are removed.