A Python module for updating data within TOML files without messing up their nice formating. This is achieved by preserving the parsed/constructed TOML data structures as lexical tokens internally and having the data manipulations performed directly on the tokens.
pip install --upgrade contoml
>>> import contoml
>>> toml_file = contoml.load('sample.toml')
# The anonymous table is accessible using the empty string key on the TOML file
>>> toml_file['']['title']
'TOML Example'
# You can modify table values in-place
>>> toml_file['fruit'][1]['variety'][0]['points'][0]['y'] = 42
>>> toml_file['servers']['alpha']['ip'] = '192.168.0.111'
>>> toml_file['environment'] = {'OS': 'Arch Linux', 'Type': 'GNU/Linux'}