class mpas_tools.config.MpasConfigParser[source]

A “meta” config parser that keeps a dictionary of config parsers and their sources to combine when needed. The custom config parser allows provenance of the source of different config options and allows the “user” config options to always take precedence over other config options (even if they are added later).

  • combined ({None, configparser.ConfigParser}) – The combined config options

  • combined_comments ({None, dict}) – The combined comments associated with sections and options

  • sources ({None, dict}) – The source of each section or option


Make a new (empty) config parser



Make a new (empty) config parser


Add the contents of a config file to the parser.

add_from_package(package, config_filename[, ...])

Add the contents of a config file to the parser.


Add a the contents of a user config file to the parser.


Combine the config files into one.


Get a deep copy of the config parser

get(section, option)

Get an option value for a given section.

getboolean(section, option)

Get an option boolean value for a given section.

getexpression(section, option[, dtype, ...])

Get an option as an expression (typically a list, though tuples and dicts are also available).

getfloat(section, option)

Get an option float value for a given section.

getint(section, option)

Get an option integer value for a given section.

getlist(section, option[, dtype])

Get an option value as a list for a given section.

has_option(section, option)

Whether the given section has the given option


Whether the given section is part of the config


Get a list of files contributing to the combined config options

set(section, option[, value, comment, user])

Set the value of the given option in the given section. The file from

write(fp[, include_sources, include_comments])

Write the config options to the given file pointer.