def reconstitute_from_bytes(descriptor_proto_bytes): """ Reconstitutes a Python protobuf class from the serialized form of a descriptor proto. """ descriptor_proto = DescriptorProto() descriptor_proto.ParseFromString(descriptor_proto_bytes) return reconstitute(descriptor_proto)
def reconstitute_from_bytes(self, descriptor_proto_bytes): """ Reconstitutes a Python protobuf class from a byte stream. The intended purpose of this function is to create a Protobuf Python class from a byte stream sent from another service. This way, services can define arbitrary data types and send schemas for those types to other services. Args: descriptor_proto_bytes: Serialized protocol buffer describing a single class Returns: A Python class for the message encoded in descriptor_proto_bytes. """ descriptor_proto = DescriptorProto() descriptor_proto.ParseFromString(descriptor_proto_bytes) return self.reconstitute(descriptor_proto)