Skip to content

settings

Settings store values to be used later in the build.

Setting names and types are declared and registered by Pajama toolsets or by Pajama itself. There are two setting types: single-value settings, and dictionary settings. Single-value settings consist of a setting name and a value. Dictionary settings consist of a setting name and a dictionary of key-value pairs.

contains

contains(setting_name)

Check if a setting with the specified name is in the current settings.

Parameters:

Name Type Description Default
setting_name str

The name of the setting to check.

required

Returns:

Type Description
bool

True if a setting with the specified name is in the current settings.

get

get(setting_name)

Get the value of the named setting.

Parameters:

Name Type Description Default
setting_name str

The name of the setting to get. Use of an unregistered setting name will raise an exception.

required

Returns:

Type Description
Artifact

The value of the setting.

Raises:

Type Description
UseOfUnregisteredSettingName

If the setting name is not registered.

set

set(setting_name, *args)

Set the value of the named setting.

Parameters:

Name Type Description Default
setting_name str

The name of the setting to set.

required
args

The value to set the setting to. For single-value settings, args is str | Artifact. str values will automatically be converted to StringArtifact. For dictionary settings, args is typically str key and str | Artifact value. Again, str values will automatically be converted to StringArtifact. Callers who need to set the entire dictionary at once can pass a DictOfArtifacts.

()

Raises:

Type Description
UseOfUnregisteredSettingName

If the setting name is not registered.

Example:

from pajama import settings, artifact

file_artifact = artifact.FileArtifact('foo.c')

# Set a single-value setting to an artifact value.
settings.set('some_toolset.some_file', file_artifact)

# Set a single-value setting to a string value.
settings.set('some_toolset.some_string', 'hello')

# Set dictionary settings to key-value pairs.
settings.set('some_toolset.some_dict', 'key_name', file_artifact)
settings.set('some_toolset.some_dict', 'another_key_name', 'a different value')