in pyignite/client.py [0:0]
def unwrap_binary(self, value: Any) -> Any:
"""
Detects and recursively unwraps Binary Object or collections of BinaryObject.
:param value: anything that could be a Binary Object or collection of BinaryObject,
:return: the result of the Binary Object unwrapping with all other data
left intact.
"""
if isinstance(value, tuple) and len(value) == 2:
if type(value[0]) is bytes and type(value[1]) is int:
blob, offset = value
with BinaryStream(self, blob) as stream:
data_class = BinaryObject.parse(stream)
return BinaryObject.to_python(stream.read_ctype(data_class, direction=READ_BACKWARD), client=self)
if isinstance(value[0], int):
col_type, collection = value
if isinstance(collection, list):
return col_type, [self.unwrap_binary(v) for v in collection]
if isinstance(collection, dict):
return col_type, {self.unwrap_binary(k): self.unwrap_binary(v) for k, v in collection.items()}
return value