def from_protobuf(cls, pb, dataset=None): """Factory method for creating an entity based on a protobuf. The protobuf should be one returned from the Cloud Datastore Protobuf API. :type key: :class:`gcloud.datastore.datastore_v1_pb2.Entity` :param key: The Protobuf representing the entity. :returns: The :class:`Entity` derived from the :class:`gcloud.datastore.datastore_v1_pb2.Entity`. """ # This is here to avoid circular imports. from gcloud.datastore import helpers key = Key.from_protobuf(pb.key, dataset=dataset) entity = cls.from_key(key) for property_pb in pb.property: value = helpers.get_value_from_protobuf(property_pb) entity[property_pb.name] = value return entity
def _callFUT(self, pb): from gcloud.datastore.helpers import get_value_from_protobuf return get_value_from_protobuf(pb)