ws.config module

class ws.config.ConfigFileParser(top_level_arg, subname=None)

Bases: object

parse(stream, context=None)

Parses a config file and returns a dictionary of settings


Does the inverse of config parsing by taking parsed values and converting them back to a string representing config file contents.

Parameters:items – an OrderedDict with items to be written to the config file
Returns:contents of config file as a string
ws.config.getArgParser(subname=None, *args, **kwargs)
ws.config.object_from_argparser(klass, subname=None, *args, **kwargs)

Create an instance of klass using its klass.from_argparser() factory and a clean instance of argparse.ArgumentParser. On top of that, logging interface is set up using the ws.logging module.

  • klass – the class to instantiate
  • subname – The name of the subsection to be read from the configuration file (usually the name of the script). By default sys.argv[0] is taken.
  • args – passed to argparse.ArgumentParser() constructor
  • kwargs – passed to argparse.ArgumentParser() constructor

an instance of klass