xoa.cfgm.cfgargparse

xoa.cfgm.cfgargparse(cfgspecfile, parser, parse=True, cfgfileopt='--cfgfile', cfgfile='config.cfg', exc=[], extraopts=None, args=None, getparser=False, getargs=True, **kwargs)[source]

Merge configuration and commandline arguments

Parameters:
  • cfgspecfile – Config specification file (.ini).

  • parserArgumentParser instance.

  • cfgfileopt (optional) – Name of the option used to specify the user config file. Example: 'cfgfile' creates the option --cfgfile=<config file>.

  • cfgfile (optional) – Default name for the loaded config file.

  • exc (optional) – Config option name that must not be used to generated a commandline option.

  • **kwargs – Extra params are passed to ConfigManager initialization.

Returns:

  • ConfigObj

  • args

  • Tasks

    1. Initialize a default configuration (ConfigManager) from the specification file given by cfgspecfile.

    2. Generate associated commandline options.

    3. Load a user configuration file (specified with the option whose name is given by cfgfileopt).

    4. Patch this configuration with user supplied options retrieved using the ArgumentParser parser parser.

    Technically it combines ConfigManager and ConfigManager.arg_parse()