yaml_dump

Contents

yaml_dump#

tollan.utils.yaml.yaml_dump(data: object, output: None = None, **kwargs: object) str[source]#
tollan.utils.yaml.yaml_dump(data: object, output: str | os.PathLike | TextIOBase, **kwargs: object) None

Serialize data as YAML and write to a file, stream, or return as string.

Parameters:
  • data (object) – The data to serialize.

  • output (str or os.PathLike or TextIOBase or None, optional) – Output destination: - None: return YAML as string - str or PathLike: write to file - TextIOBase: write to stream

  • **kwargs – Additional keyword arguments passed to yaml.dump.

Returns:

YAML string if output is None, otherwise None.

Return type:

str or None

Raises:

TypeError – If output is not a valid type.