def _serialize_as_wxf(self, data, shape, wl_type, constructor): payload = concatenate_bytes( chain((WXF_VERSION, WXF_HEADER_SEPARATOR), constructor(data, shape, wl_type)) ) return self.serialize_function( self.serialize_symbol(b"BinaryDeserialize"), (self.serialize_bytes(payload, as_byte_array=True),), )
def serialize_numeric_array(self, data, shape, wl_type): payload = concatenate_bytes( chain((WXF_VERSION, WXF_HEADER_SEPARATOR), numeric_array_to_wxf(data, shape, wl_type))) return self.serialize_function( self.serialize_symbol(b'BinaryDeserialize'), (self.serialize_bytes(payload, as_byte_array=True), ))
def export(self, data, stream=None): if stream: if isinstance(stream, six.string_types): with open(stream, "wb") as file: for token in self.generate_bytes(data): file.write(token) return stream for token in self.generate_bytes(data): stream.write(token) return stream return concatenate_bytes(self.generate_bytes(data))