module documentation

These functions return cattrs.Converter instances.

Each Converter has an unstructure method, which takes an object (usually a dict or YAML equivalent), and returns a new one whose elements have been traversed and transformed.

The purpose is usually to prepare data for export into a given format, with its particular type support.

Function mk_deep_converter Create a new recursively unstructuring cattrs.Converter.
Function mk_json_types_converter Create a Converter which unstructures into JSON-supported types.
Function mk_stringy_converter Create a Converter which unstructures into plain str/list/dict objects.
Function mk_toml_types_converter Create a Converter which unstructures into TOML-supported types.
Function mk_unyamlable_converter Create a recursive Converter which replaces marked strs with time instances.
Function mk_yaml_types_converter Create a Converter which unstructures into YAML-supported types.
Function _timestamp_to_datey Create a plain Python datetime.date or datetime.datetime.
def mk_deep_converter() -> Converter: (source)

Create a new recursively unstructuring cattrs.Converter.

It can traverse dicts, lists, and their ruamel.yaml equivalents. The other Converters here use this as a starting point, before adding more unstructuring hooks.

Returns
ConverterA new, recursively unstructuring cattrs.Converter.
def mk_json_types_converter() -> Converter: (source)

Create a Converter which unstructures into JSON-supported types.

Returns
Converter
A Converter whose unstructure method results in nested objects of type
str/int/float/bool/dict/list/None
def mk_stringy_converter() -> Converter: (source)

Create a Converter which unstructures into plain str/list/dict objects.

This might alternatively have been named mk_nestedtext_types_converter.

Returns
Converter
A Converter ready to unstructure nested data into only
dict/list/str types.
def mk_toml_types_converter() -> Converter: (source)

Create a Converter which unstructures into TOML-supported types.

Returns
Converter
A Converter whose unstructure method results in nested objects of type
str/int/float/bool/dict/list/datetime/date/time
def mk_unyamlable_converter(time_marker: str) -> Converter: (source)

Create a recursive Converter which replaces marked strs with time instances.

Parameters
time_marker:strAn arbitrary prefix (such as a UUID) which, when encountered, indicates the remainder of the containing str should be processed as ISO 8601 and the element replaced by a datetime.time instance.
Returns
Converter
A Converter whose unstructure method replaces marked strs with
datetime.time instances.
def mk_yaml_types_converter() -> Converter: (source)

Create a Converter which unstructures into YAML-supported types.

Returns
Converter
A Converter whose unstructure method results in nested objects of type
str/int/float/bool/dict/list/None/datetime/date
def _timestamp_to_datey(ts: TimeStamp) -> date | datetime: (source)

Create a plain Python datetime.date or datetime.datetime.

Parameters
ts:TimeStampa ruamel.yaml.timestamp.TimeStamp, which may correspond to a date or time.
Returns
date | datetime
A new datetime.date or datetime.datetime,
representing the value of ts.