aea.helpers.yaml_utils

Helper functions related to YAML loading/dumping.

_AEAYamlLoader Objects

class _AEAYamlLoader(yaml.SafeLoader)

Custom yaml.SafeLoader for the AEA framework.

It extends the default SafeLoader in two ways: - loads YAML configurations while remembering the order of the fields; - resolves the environment variables at loading time.

This class is for internal usage only; please use the public functions of the module 'yaml_load' and 'yaml_load_all'.

__init__

 | __init__(*args, **kwargs)

Initialize the AEAYamlLoader.

It adds a YAML Loader constructor to use 'OderedDict' to load the files.

_AEAYamlDumper Objects

class _AEAYamlDumper(yaml.SafeDumper)

Custom yaml.SafeDumper for the AEA framework.

It extends the default SafeDumper so to dump YAML configurations while following the order of the fields.

This class is for internal usage only; please use the public functions of the module 'yaml_dump' and 'yaml_dump_all'.

__init__

 | __init__(*args, **kwargs)

Initialize the AEAYamlDumper.

It adds a YAML Dumper representer to use 'OderedDict' to dump the files.

yaml_load

yaml_load(stream: TextIO) -> Dict[str, Any]

Load a yaml from a file pointer in an ordered way.

Arguments:

  • stream: file pointer to the input file.

Returns:

the dictionary object with the YAML file content.

yaml_load_all

yaml_load_all(stream: TextIO) -> List[Dict[str, Any]]

Load a multi-paged yaml from a file pointer in an ordered way.

Arguments:

  • stream: file pointer to the input file.

Returns:

the list of dictionary objects with the (multi-paged) YAML file content.

yaml_dump

yaml_dump(data: Dict, stream: Optional[TextIO] = None) -> None

Dump YAML data to a yaml file in an ordered way.

Arguments:

  • data: the data to write.
  • stream: (optional) the file to write on.

Returns:

None

yaml_dump_all

yaml_dump_all(data: Sequence[Dict], stream: Optional[TextIO] = None) -> None

Dump YAML data to a yaml file in an ordered way.

Arguments:

  • data: the data to write.
  • stream: (optional) the file to write on.

Returns:

None