Class reference

Models

ConfigMixin

class easyconfig.ConfigMixin
property config_file_path: Path

Path to the loaded configuration file

subscribe_for_changes(func)

When a value in this container changes the passed function will be called.

Parameters:

func (Callable[[], Any]) – function which will be called

Return type:

ConfigObjSubscription

Returns:

object which can be used to cancel the subscription

subscribe_set_options(*, propagate=None, on_next_value=None)

Set options for the subscription of this object.

Parameters:
  • propagate (Optional[bool]) – Propagate the change event to the parent object

  • on_next_value (Optional[bool]) – Call the function the next time when values get loaded even if there is no value change

Return type:

Self

AppConfigMixin

class easyconfig.AppConfigMixin
property config_file_path: Path

Path to the loaded configuration file

generate_default_yaml()

Generate the default YAML structure

Return type:

str

Returns:

YAML structure as a string

load_config_dict(cfg, *, expansion=True)

Load the configuration from a dictionary

Parameters:
  • cfg (dict) – config dict which will be loaded

  • expansion (bool) – Expand ${…} in strings

Return type:

Self

load_config_file(path=None, *, expansion=True)

Load configuration from a yaml file. If the file does not exist a default file will be created

Parameters:
  • path (Union[Path, str, None]) – Path to file

  • expansion (bool) – Expand ${…} in strings

Return type:

Self

property load_preprocess: PreProcess

A preprocessor which can be used to preprocess the configuration data before it is loaded

set_file_path(path)

Set the path to the configuration file. If no file extension is specified .yml will be automatically appended.

Parameters:

path (Path | str) – Path obj or str

Return type:

Self

subscribe_for_changes(func)

When a value in this container changes the passed function will be called.

Parameters:

func (Callable[[], Any]) – function which will be called

Return type:

ConfigObjSubscription

Returns:

object which can be used to cancel the subscription

subscribe_set_options(*, propagate=None, on_next_value=None)

Set options for the subscription of this object.

Parameters:
  • propagate (Optional[bool]) – Propagate the change event to the parent object

  • on_next_value (Optional[bool]) – Call the function the next time when values get loaded even if there is no value change

Return type:

Self

Subscription

class easyconfig.config_objs.ConfigObjSubscription(sub_obj, location)
cancel()

Cancel the subscription so that the function will no longer be called on changes

Return type:

None

property name: str

Location of the subscription target in the configuration

PreProcess

class easyconfig.pre_process.PreProcess(default=None)
delete_entry(path)

Delete an entry in the configuration

Parameters:

path (tuple[str | int, ...] | list[str | int]) – path to the entry

Return type:

Self

move_entry(src, dst)

Move an entry to a different location in the configuration

Parameters:
  • src (tuple[str | int, ...] | list[str | int]) – current path to the entry

  • dst (tuple[str | int, ...] | list[str | int]) – new path to the entry

Return type:

Self

Returns:

rename_entry(src, name)

Rename an entry in the configuration

Parameters:
  • src (tuple[str | int, ...] | list[str | int]) – path to the entry

  • name (str) – new name

Return type:

Self

set_log_func(log_func)

Set a log function that will be called for each operation that is executed

Return type:

Self