code: def _assign_value_by_type(self, pbuf_obj, value, _bool=True, _float=True,
                                _integer=True, _string=True, error_prefix=''):
          
          # bool inherits int, so bool instance check must be executed prior to
          # checking for integer types
          if isinstance(value, bool) and _bool is True:
              pbuf_obj.value.boolValue = value
          elif isinstance(value, six.integer_types) and \
                  not isinstance(value, bool) and _integer is True:
              if value < INTEGER_MIN or value > INTEGER_MAX:
                  raise ValueError(
                      ('{}: {} exceeds signed 64 bit integer range '
                       'as defined by ProtocolBuffers ({} to {})')
                      .format(error_prefix, str(value),
                              str(INTEGER_MIN), str(INTEGER_MAX)))
              pbuf_obj.value.intValue = value
          elif isinstance(value, float) and _float is True:
              pbuf_obj.value.doubleValue = value
          elif isinstance(value, six.string_types) and _string is True:
              pbuf_obj.value.strValue = value
          else:
              raise ValueError(
                  '{}: {} is of invalid type {}'
                  .format(error_prefix, str(value), str(type(value))))
docs: Assigns the supplied value to the appropriate protobuf value type