class documentation
class CompositeConfigParser(ConfigFileParser): (source)
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 |
Undocumented |
Method | parse |
Undocumented |
Instance Variable | parsers |
Undocumented |