def _decode_one(buf): self = node_t() self.num_children = struct.unpack(">i", buf.read(4))[0] self.children = [] for i0 in range(self.num_children): self.children.append(node_t._decode_one(buf)) return self
def decode(data): if hasattr(data, 'read'): buf = data else: buf = BytesIO(data) if buf.read(8) != node_t._get_packed_fingerprint(): raise ValueError("Decode error") return node_t._decode_one(buf)