leads.config.template#

Module Contents#

Classes#

API#

class leads.config.template.ConfigTemplate(base: dict[str, leads.types.SupportedConfig])[source]#

Bases: leads.data.Serializable

Initialization

All custom attributes should be public (not named after β€œ_”). Writable attributes should start with β€œw_” such as β€œw_debug_level”. :param base: the base dictionary

fix_dict(d: dict[str, Any]) dict[str, leads.types.SupportedConfig][source]#

Fix the types of every element in the dictionary. :param d: the input dictionary :return: the fixed dictionary

fix_type(value: Any) leads.types.SupportedConfig[source]#

Replace lists with tuples and check for illegal types. :param value: the input value :return: the fixed value where :exception TypeError: the type of the value is illegal

__getitem__(name: str) leads.types.SupportedConfig | None[source]#
__setitem__(name: str, value: leads.types.SupportedConfig) None[source]#
__setattr__(name: str, value: leads.types.SupportedConfig) None[source]#
__str__() str[source]#

Convert to a JSON string. :return: the JSON string

to_dict() dict[str, leads.types.SupportedConfig][source]#
_writable(name: str) bool[source]#
Parameters:

name – the configuration name

Returns:

True: writable; False: readonly

set(name: str, value: leads.types.SupportedConfig) None[source]#

Set the value with the given name in the dictionary. :param name: the dictionary key :param value: the value to set

get(name: str, default: leads.types.SupportedConfig | None = None) leads.types.SupportedConfig | None[source]#

Get the value of a given name from the dictionary. :param name: the dictionary key :param default: the default value if the value does not exist :return: the value if it exists or else the default value

refresh() None[source]#

Write the dictionary into the instance attributes.