ConfigArgumentParser#

class ConfigArgumentParser#

Bases: object

Wrapper combining ConfigParser and ArgumentParser.

config#

A ConfigParser.

parser#

An ArgumentParser.

defaults#

A dict contains the default arguments.

namespace#

An object returned by parse_args.

args#

A dict contains the parsed arguments.

help#

A dict contains the help messages.

Methods

parse_args

Add arguments to parser and parse arguments.

parse_obj

Parse arguments and update object attributes.

read

Read and parse a filename or an iterable of filenames.

read_py

Read and parse a filename of Python script.

read_string

Read configuration from a given string.

read(filenames)#

Read and parse a filename or an iterable of filenames.

Return list of successfully read files.

read_string(string)#

Read configuration from a given string.

read_py(filename)#

Read and parse a filename of Python script.

parse_args(args=None, *, shorts='')#

Add arguments to parser and parse arguments.

Parameters:
  • args – A list of strings to parse. The default is taken from sys.argv.

  • shorts – A sequence of short option letters for the leading options.

Returns:

A dict containing arguments.

parse_obj(obj, args=None, *, shorts='')#

Parse arguments and update object attributes.

Parameters:
  • obj – An object with attributes as default arguments.

  • args – A list of strings to parse. The default is taken from sys.argv.

  • shorts – A sequence of short option letters for the leading options.

Returns:

A dict containing updated arguments.