Skip to content

Core - Config Module

anvil.lib.config

Config

A class used to read and write to the config.ini file.

__init__()

Initializes a Config object.

add_option(section, option, value)

Sets a value in the anvilconfig.json file.

Parameters:

Name Type Description Default
section str

The section to set the value in.

required
option str

The option to set the value in.

required
value Any

The value to set.

required

add_section(section)

Adds a section to the anvilconfig.json file.

Parameters:

Name Type Description Default
section str

The section to add.

required

get_option(section, option)

Gets a value from the anvilconfig.json file.

Parameters:

Name Type Description Default
section str

The section to get the value from.

required
option str

The option to get the value from.

required

Returns:

Name Type Description
str str

The value of the option.

has_option(section, option)

Checks if an option exists in the anvilconfig.json file.

Parameters:

Name Type Description Default
section str

The section to check the option in.

required
option str

The option to check.

required

Returns:

Name Type Description
bool bool

True if the option exists, False otherwise.

has_section(section)

Checks if a section exists in the anvilconfig.json file.

Parameters:

Name Type Description Default
section str

The section to check.

required

Returns:

Name Type Description
bool bool

True if the section exists, False otherwise.

save()

Saves the anvilconfig.json file.

ConfigOption

Bases: StrEnum

Configuration options available in the anvil config file.

Defines all the configuration keys that can be set in various sections of the configuration file.

ConfigPackageTarget

Bases: StrEnum

Package target types for anvil projects.

Defines the types of packages that can be created.

ConfigSection

Bases: StrEnum

Configuration sections for the anvil config file.

Defines the main sections that can be present in the configuration file.