yaml

YAML I/O module.

Classes

YAMLReader

Safe YAML reader.

YAMLWriter

Safe YAML writer.

class YAMLReader[source]

Bases: object

Safe YAML reader.

static check(path)[source]

Checks that a file has the correct extension and exists.

Parameters:

path (Union[str, Path]) – Path to the file.

Returns:

static read(path, verbose=True)[source]

Reads and parses a YAML file.

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

  • verbose (Union[bool, int]) – Verbosity of the method.

Return type:

Union[List, Dict]

Returns:

Deserialized data.

class YAMLWriter[source]

Bases: object

Safe YAML writer.

static check(path, overwrite=False)[source]

Checks that a file has the correct extension and verifies that we can overwrite it if it exists.

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

  • overwrite (bool) – Whether to overwrite, in case of an existing file.

Returns:

static write(data, path, overwrite=False, verbose=True)[source]

Writes serializable data into a YAML file.

Parameters:
  • data (Union[List, Dict]) – Serializable data.

  • path (Union[str, Path]) – Path to the file.

  • overwrite (bool) – Whether to overwrite, in case of an existing file.

  • verbose (Union[bool, int]) – Verbosity of the method.

Returns: