def entity_to_protobuf(entity):
 entity_pb = _entity_pb2.Entity()
 if (entity.key is not None):
  key_pb = entity.key.to_protobuf()
  entity_pb.key.CopyFrom(key_pb)
 for (name, value) in entity.items():
  value_is_list = isinstance(value, list)
  if (value_is_list and (len(value) == 0)):
   continue
  value_pb = _new_value_pb(entity_pb, name)
  _set_protobuf_value(value_pb, value)
  if (name in entity.exclude_from_indexes):
   if (not value_is_list):
    value_pb.exclude_from_indexes = True
   for sub_value in value_pb.array_value.values:
    sub_value.exclude_from_indexes = True
  _set_pb_meaning_from_entity(entity, name, value, value_pb, is_list=value_is_list)
 return entity_pb

def entity_to_protobuf ( entity ) : entity_pb = _entity_pb2 . Entity ( ) if ( entity . key is not None ) : key_pb = entity . key . to_protobuf ( ) entity_pb . key . CopyFrom ( key_pb ) for ( name , value ) in entity . items ( ) : value_is_list = isinstance ( value , list ) if ( value_is_list and ( len ( value ) == 0 ) ) : continue value_pb = _new_value_pb ( entity_pb , name ) _set_protobuf_value ( value_pb , value ) if ( name in entity . exclude_from_indexes ) : if ( not value_is_list ) : value_pb . exclude_from_indexes = True for sub_value in value_pb . array_value . values : sub_value . exclude_from_indexes = True _set_pb_meaning_from_entity ( entity , name , value , value_pb , is_list = value_is_list ) return entity_pb
converts an entity into a protobuf .