module documentation

yamlutil.py - Utility helpers for YAML.

Provides dump, parse helper functions for general-purpose ZMS utilities and shared helper functions. It provides common patterns like type checking, data transformation, and error handling.

License: GNU General Public License v2 or later, Organization: ZMS Publishing

Function dump Serializes a Python object to a YAML-formatted string.
Function parse Deserializes a YAML-formatted string to a Python object.
Constant IMPORT_ERROR_MSG Message returned when `ruamel.yaml` cannot be imported.
Function __cleanup Recursively cleans up a dictionary by removing keys with falsy values.
Function _load_yaml Helper function to load the YAML library and handle import errors.
def dump(data): (source)

Serializes a Python object to a YAML-formatted string.

Parameters
data:objectThe Python object to serialize.
Returns
strYAML-formatted string or error message if YAML library is not available.
def parse(data): (source)

Deserializes a YAML-formatted string to a Python object.

Parameters
data:strThe YAML-formatted string to deserialize.
Returns
objectThe deserialized Python object or error message if YAML library is not available.
IMPORT_ERROR_MSG: str = (source)

Message returned when `ruamel.yaml` cannot be imported.

Value
'Import Error: ruamel.yaml not installed'
def __cleanup(v): (source)

Recursively cleans up a dictionary by removing keys with falsy values.

Parameters
v:objectInput value, typically a dictionary, list, or scalar.
Returns
objectCleaned value with empty entries removed while preserving numeric zero and boolean false semantics used by the repository format.
def _load_yaml(): (source)

Helper function to load the YAML library and handle import errors.

Returns
tupleTuple containing the YAML class and an error message if import fails.