class documentation

class CompositeConfigParser(ConfigFileParser): (source)

View In Hierarchy

A config parser that understands multiple formats.

This parser will successively try to parse the file with each compisite parser, until it succeeds, else it fails showing all encountered error messages.

The following code will make configargparse understand both TOML and INI formats. Making it easy to integrate in both pyproject.toml and setup.cfg.

>>> import configargparse
>>> my_tool_sections = ['tool.my_super_tool', 'tool:my_super_tool', 'my_super_tool']
...                     # pyproject.toml like section, setup.cfg like section, custom section
>>> parser = configargparse.ArgParser(
...             default_config_files=['setup.cfg', 'my_super_tool.ini'],
...             config_file_parser_class=configargparse.CompositeConfigParser(
...             [configargparse.TomlConfigParser(my_tool_sections), 
...                 configargparse.IniConfigParser(my_tool_sections, split_ml_text_to_list=True)]
...             ),
...          )
Method __call__ Undocumented
Method __init__ Undocumented
Method get_syntax_description Undocumented
Method parse Undocumented
Instance Variable parsers Undocumented
def __call__(self): (source)

Undocumented

Returns
ConfigFileParserUndocumented
def __init__(self, config_parser_types): (source)

Undocumented

Parameters
config_parser_types:List[Callable[[], ConfigFileParser]]Undocumented
def get_syntax_description(self): (source)

Undocumented

Returns
strUndocumented
def parse(self, stream): (source)

Undocumented

Parameters
stream:TextIOUndocumented
Returns
Dict[str, Any]Undocumented

Undocumented