class documentation

Create a TOML parser bounded to the list of provided sections.

Example:

# this is a comment
[tool.my-software] # TOML section table.
# how to specify a key-value pair
format-string = "restructuredtext" # strings must be quoted
# how to set an arg which has action="store_true"
warnings-as-errors = true
# how to set an arg which has action="count" or type=int
verbosity = 1
# how to specify a list arg (eg. arg which has action="append")
repeatable-option = ["https://docs.python.org/3/objects.inv",
                     "https://twistedmatrix.com/documents/current/api/objects.inv"]
# how to specify a multiline text:
multi-line-text = '''
    Lorem ipsum dolor sit amet, consectetur adipiscing elit.
    Vivamus tortor odio, dignissim non ornare non, laoreet quis nunc.
    Maecenas quis dapibus leo, a pellentesque leo.
    '''

Note that the config file fragment above is also valid for the IniConfigParser class and would be parsed the same manner. Thought, any valid TOML config file will not be necessarly parsable with IniConfigParser (INI files must be rigorously indented whereas TOML files).

See the TOML specification for details.

Method __call__ Undocumented
Method __init__ No summary
Method get_syntax_description Returns a string describing the config file syntax.
Method parse Parses the keys and values from a TOML config file.
Method serialize Serialize items to TOML format with section support.
Instance Variable sections Undocumented
def __call__(self): (source)

Undocumented

def __init__(self, sections): (source)
Parameters
sectionsThe section names bounded to the new parser.
def get_syntax_description(self): (source)

Returns a string describing the config file syntax.

def parse(self, stream): (source)

Parses the keys and values from a TOML config file.

def serialize(self, items): (source)

Serialize items to TOML format with section support.

Note: Requires the 'toml' package for serialization (pip install toml). Python 3.11's tomllib only supports reading, not writing.

sections = (source)

Undocumented