configparser_check_options

opthandler.configparser_check_options(config, known_options, sections=None, skip_missing_sec=False, case_sensitive=True, hyphens_are_underscores=False)[source]

Check if the options of a ConfigParser are contained in a list of known options.

Parameters:
  • config (configparser.ConfigParser) – The ConfigParser instance whose options should be checked.

  • known_options (iterable) – The list of known options. Note that the options of all given sections are checked against this list of known options.

  • sections (iterable or str or None, optional) – The sections of config whose options should be checked. If None, check all sections.

  • skip_missing_sec (bool, optional) – If True, don’t raise an exception if a given section is not contained in config but instead simply skip this section.

  • case_sensitive (bool, optional) – If True, respect the case (upper, lower, mixed) when comparing the options in config with the options in known_options.

  • hyphens_are_underscores (bool, optional) – If True, don’t distinguish between hyphens ('-') and underscores ('_').

Raises:

KeyError – If any section of config contains options that are not contained in known_options.