auto_process_ngs.config
Classes to support handling configuration files within the ‘auto_process_ngs’ library.
The following classes are provided:
Config: modified application-specific version of ConfigParser
NullValue: represents a null (unset) configuration parameter
- class auto_process_ngs.config.Config
Modified application-specific version of ConfigParser
Implements a wrapper for ConfigParser:
‘get’ and ‘getint’ methods take a ‘default’ argument, which is returned if the specified option is missing from the file
implements a ‘getrunner’ method that returns a JobRunner instance based on a specification string.
Example usage (read in a file and get a parameter value from a section):
>>> c = Config() >>> c.read(conf_file) >>> c.get('section1','parameter2')
See also the configparser documentation at https://docs.python.org/3/library/configparser.html
- get(section, option, **kwargs)
Fetch value of option from config file
Wrapper for ‘get’ method of superclass
- Parameters:
section (str) – section name in config file
option (str) – name of option
default (object) – value to return if option is to set to empty string or to string ‘None’ in config file (default: None)
kwargs (mapping) – additional keyword arguments to pass directly to ‘get’ method of superclass
- Returns:
- value of specified option (or default),
or ‘NullValue’ instance (if section or option are not found and not default specified).
- Return type:
String
- getboolean(section, option, **kwargs)
Fetch boolean value option from config file
Wrapper for ‘getboolean’ method of superclass
- Parameters:
section (str) – section name in config file
option (str) – name of option
default (object) – value to return if option is to set to empty string or to string ‘None’ in config file (default: None)
- Returns:
- value of specified option (or default),
or ‘NullValue’ instance (if section or option are not found and not default specified).
- Return type:
Booelan
- getfloat(section, option, **kwargs)
Fetch float value option from config file
Wrapper for ‘getfloat’ method of superclass
- Parameters:
section (str) – section name in config file
option (str) – name of option
default (object) – value to return if option is to set to empty string or to string ‘None’ in config file (default: None)
- Returns:
- value of specified option (or default),
or ‘NullValue’ instance (if section or option are not found and not default specified).
- Return type:
Float
- getint(section, option, **kwargs)
Fetch integer value option from config file
Wrapper for ‘getint’ method of superclass
- Parameters:
section (str) – section name in config file
option (str) – name of option
default (object) – value to return if option is to set to empty string or to string ‘None’ in config file (default: None)
- Returns:
- value of specified option (or default),
or ‘NullValue’ instance (if section or option are not found and not default specified).
- Return type:
Integer
- getrunner(section, option, **kwargs)
Return job runner instance from option in config file
Fetches string representation of runner from config file and returns a runner instance.
- Parameters:
section (str) – section name in config file
option (str) – name of option
default (object) – value to return if option is to set to empty string or to string ‘None’ in config file (default: None)
- Returns:
- value of specified option (or default),
or ‘NullValue’ instance (if section or option are not found and not default specified).
- Return type:
String
- class auto_process_ngs.config.NullValue
Represents a null (i.e. unset) value for a config setting