itacart.serialization.data_tree_blob.decode_data_tree
- itacart.serialization.data_tree_blob.decode_data_tree(blob)[source]
Every cell of a DataTreeBlob with its values, every invariant checked.
Internal nodes are there with their own values, so a parent and its daughter both come back. A prefix that names no cell – the stem a border cell’s surplus children hang from – is a node of the blob and is not returned.
- Parameters:
blob (
Union[bytes,bytearray,memoryview]) – The bytes.- Return type:
- Returns:
A mapping of spellings to
{name: value}, coarsest level first and in canonical order within a level. Each node carries the variables that have values at its resolution; an unknown value isNone.- Raises:
MalformedBlobError – If the bytes break the format anywhere, including an aggregate that is not its daughters’ or a leaf naming no cell.
IncompatibleProfileError – If the blob is of a version this build does not read.
Example
>>> n = DataVariable("n", "u32", op="sum", leaf_max=1) >>> blob = encode_data_tree({"NE(0625/0451(3))": {"n": 1}}, [n]) >>> decode_data_tree(blob) {'NE': {'n': 1}, 'NE(0625/0451)': {'n': 1}, 'NE(0625/0451(3))': {'n': 1}}