TomlkitLoader#

class TomlkitLoader(app, filename, *args, **kwargs)#

Bases: FileLoader, DictLikeLoaderMixin

Load config from TOML files using tomlkit library.

The tomlkit library is the default for neba, as it allows precise creation of toml files (including comments) which is useful for creating fully documented config files.

Parameters:
load_config()#

Populate the config attribute from TOML file.

Return type:

Iterator[ConfigValue]

serialize_section(t, section, fullpath, comment='full', comment_default=False)#

Serialize a Section and its subsections recursively.

We allow to write without the subsections initialized. The config attribute will have the instances’ values when possible so we don’t need to access the sections instances here.

We use the extented capabilities of tomlkit.

Parameters:
Return type:

T

wrap_comment(item, text)#

Wrap text correctly and add it to a toml container as comment lines.

Parameters:
Return type:

None

write(fp, comment='full', comment_default=False)#

Return lines of configuration file corresponding to the app config tree.

Parameters:
Return type:

None