API¶
The hydraters API.
hydraters.dehydrate ¶
dehydrate(base: dict[str, Any], item: dict[str, Any]) -> dict[str, Any]
Dehydrates an item using a base.
Parameters:
-
base(dict[str, Any]) –The base item to use for dehydration. Any values that are equal on the base and the item will be removed from the item.
-
item(dict[str, Any]) –The item to be dehydrated. The item is mutated in-place, and also returned.
Returns:
-
dict[str, Any]–The dehydrated item.
hydraters.hydrate ¶
hydrate(
base: dict[str, Any],
item: dict[str, Any],
strip_unmatched_markers: bool = False,
) -> dict[str, Any]
Hydrates an item using a base.
Parameters:
-
base(dict[str, Any]) –The base item to use for hydration. Any values on the base that are not on the item will be added back to the item.
-
item(dict[str, Any]) –The item to hydrate. The item is mutated in-place and also returned.
-
strip_unmatched_markers(bool, default:False) –When
Truethe hydrated item is passed through strip_unmatched_markers before being returned, emitting the same warning and removing any lingering markers.
Returns:
-
dict[str, Any]–The hydrated item.
hydraters.DO_NOT_MERGE_MARKER
module-attribute
¶
DO_NOT_MERGE_MARKER: str
The magic marker that is used to indicate that a field should not be merged.
hydraters.strip_unmatched_markers ¶
strip_unmatched_markers(item: dict[str, Any]) -> dict[str, Any]
Remove DO_NOT_MERGE_MARKER entries and warn with their paths.
The removal applies recursively. Paths are emitted using JSONPath dot
notation like $.a.b or $.assets[0].href.
Parameters:
-
item(dict[str, Any]) –The dictionary to mutate in-place.
Returns:
-
dict[str, Any]–The same dictionary object with marker entries removed.