mpas_tools.config.MpasConfigParser

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).

Variables
  • 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

__init__()[source]

Make a new (empty) config parser

Methods

__init__()

Make a new (empty) config parser

add_from_file(filename)

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_user_config(filename)

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

combine()

Combine the config files into one.

copy()

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

has_section(section)

Whether the given section is part of the config

list_files()

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.