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

serialize(items)

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
get_syntax_description()
ws.config.argtype_dirname_must_exist(string)
ws.config.argtype_existing_dir(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.

Parameters:
  • 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
Returns:

an instance of klass