ws.config module

class ws.config.ConfigParser(configfile, **kwargs)

Bases: configparser.ConfigParser

Drop-in replacement for configparser.Configparser.

fetch_section(section=None, to_list=True)

Fetches a specific section from a config file.

Parameters
  • section (str) – section name for fetching.

  • to_list (bool) – defines the format of the returned value (see below).

Returns

The data from the fetched config file section. The format is a list of strings if to_list=True (default value) and a dictionary otherwise.

static set_argparser(argparser)
ws.config.argtype_bool(string)
ws.config.argtype_config(string)

Compute config filepath and check its existence.

ws.config.argtype_dirname_must_exist(string)
ws.config.argtype_existing_dir(string)
ws.config.getArgParser(**kwargs)

Create an instance of argparse.ArgumentParser and set the global arguments (e.g. for logging).

Parameters

kwargs – passed to argparse.ArgumentParser() constructor.

Returns

an instance of argparse.ArgumentParser.

ws.config.object_from_argparser(klass, section=None, **kwargs)

Create an instance of klass using its klass.from_argparser() factory and an instance of argparse.ArgumentParser.

Parameters
  • klass – the class to instantiate

  • section (str) – passed to parse_args()

  • kwargs – passed to getArgParser()

Returns

an instance of klass