'Sets the primitive used to encode an attribute.
This method allows to bypass the type checking afforded by the regular
semantic layer when assigning to the field. Using this method sets the
underlying primitive used to encode the field directly. This is a major hack
and should be used sparingly because it allows to create invalid protobufs.
Args:
attr: The name of the attribute to set.
value: A primitive (int, string etc) which will be set to this field.
Raises:
AttributeError: If the field is not known.'

def SetPrimitive(self, attr, value):

    type_info_obj = self.type_infos.get(attr)
    if (type_info_obj is None):
        raise AttributeError(('Field    %s    is    not    known.' % attr))
    value = type_info_obj.primitive_desc.ConvertToWireFormat(value)
    self._data[attr] = (None, value, type_info_obj)
    self.dirty = True
