Set values in the knowledge base based on responses.
427040
def UpdateKnowledgeBase(self, response, provides):
    """"""

    if isinstance(response, rdf_anomaly.Anomaly):
      return

    if isinstance(response, rdf_client.User):
      self.knowledge_base.MergeOrAddUser(response)
      return

    if isinstance(response, rdf_protodict.Dict):
      response_dict = response.ToDict()
      for attribute, value in iteritems(response_dict):
        if attribute in provides:
          self.SetKnowledgeBaseValue(attribute, value)
      return

    # If its not a dict we only support a single value.
    if len(provides) == 1:
      self.SetKnowledgeBaseValue(provides[0], response)
964761
def update(self, **kwargs):
    """"""
    for key, value in kwargs.items():
      setattr(self, key, value)
1095931
def set(self, key, value):
        """"""
        self.store[key]=value
        return self.store
676226
def __set_values(self, values):
        
        array = tuple((self._clean_value(v),) for v in values)
        self._get_target().setDataArray(array)
579424
def _setDatasets(self, metadata):
        """"""
        # Pull the lot into a list
        cols = list(self.getCSVReader(metadata))

        # sort the cols by view name and ordinal (they come sorted, but lets be sure)
        cols.sort(key=lambda x: [x['viewname'], int(x['ordinal'])])

        # Now group them by their viewname
        for key, grp in groupby(cols, key=lambda x: x["viewname"]):
            self.datasets[key] = list(grp)
501110
def _set_hyperparameters(self, parameters):
        """"""
        for name, value in parameters.iteritems():
            try:
                getattr(self, name)
            except AttributeError:
                raise ValueError(
                    'Each parameter in parameters must be an attribute. '
                    '{} is not.'.format(name))
            setattr(self, name, value)
756576
def set_attributes(self, **kwargs):
        
        if not self.Meta.related_resources:
            # Just do what the normal BaseResource does
            super(HypermediaResource, self).set_attributes(**kwargs)
            return

        # Extract all the values that are URLs
        url_values = {}
        for k, v in kwargs.items():
            try:
                if isinstance(v, list):
                    [self._parse_url_and_validate(i) for i in v]
                else:
                    self._parse_url_and_validate(v)
                url_values[k] = v
            except BadURLException:
                # This is a badly formed URL or not a URL at all, so skip
                pass
        # Assign the valid method values and then remove them from the kwargs
        assigned_values = self.match_urls_to_resources(url_values)
        for k in assigned_values.keys():
            kwargs.pop(k, None)
        # Assign the rest as attributes.
        for field, value in kwargs.items():
            if field in self.Meta.attributes:
                setattr(self, field, value)
1310921
def _set_attrs(self, attrs, allow_ro=False, from_json=True):
    
    for k, v in attrs.iteritems():
      attr = self._check_attr(k, allow_ro)
      if attr and from_json:
        v = attr.from_json(self._get_resource_root(), v)
      object.__setattr__(self, k, v)
269848
def Parse(self, stat, knowledge_base):
    """"""
    value = stat.registry_data.GetValue()
    if not value:
      raise parser.ParseError("Invalid value for key %s" % stat.pathspec.path)
    value = artifact_utils.ExpandWindowsEnvironmentVariables(
        value, knowledge_base)
    if value:
      yield rdfvalue.RDFString(value)
113991
def set(self, value, parse=False):
        
        self.value = self.parse(value) if parse else value
1026753
def Validate(self, value, **_):
    """"""
    if value is None:
      return

    return rdfvalue.RDFBool(super(ProtoBoolean, self).Validate(value))
413703
def set_value(self, key, field, value):
        """"""
        self._db.hset(key, field, value)
97609
public void setValues(List<ProposedValue> values)
		throws InferenceException
	{
		m_resettingRules.clear();
        m_assignedFields.clear();
        m_readOnlyFields.clear();
        m_activateFields.clear();
        m_requiredFields.clear();
		m_excludes.clear();
		@SuppressWarnings("unused")
		int count=0;
		m_indenter.clear();
		s_log.debug("{}Setting values...",m_indenter);
		m_indenter.increment();
		for (ProposedValue pv: values)
		{
			RuleProxyField rpf = null;
			count++;
			try
			{
			    rpf = pv.getRuleProxyField();
		        addToAgenda(rpf);
				rpf.reset();
				rpf.setValue(pv.getValue());
			}
			catch (InferenceException e)
			{
                clearAgenda();
				throw e;
			}
	        finally
	        {
	        	removeUnknownField(rpf.getProxyField());
	            m_resettingRules.clear();
	            clearReviewList();
	        }
		}
		try
		{
			forwardChain();
		}
        catch (InferenceException e)
        {
            s_log.error(e.getMessage(),e);
            throw e;
        }
        catch (ConstraintViolationException e)
        {
            s_log.error(e.getMessage(),e);
            throw e;
        }
        catch (ValidationException e)
        {
            s_log.error(e.getMessage(),e);
            throw e;
        }
		finally
		{
            clearAgenda();
			m_resettingRules.clear();
            clearReviewList();
		}
		m_indenter.clear();
		// This effectively commits the changes to the exposed data
		boolean enabled = m_session.isEnabled();
		m_session.setEnabled(false);
        for (ProxyField proxyField: m_assignedFields)
        {
            proxyField.updateValue();
        }
        for (ProxyField proxyField: m_unknownFields)
        {
            proxyField.getFieldMetadata().setUnknown(true);
        }
        m_unknownFields.clear();
        for (ProxyField proxyField: m_activateFields)
        {
            proxyField.setInActive(false);
        }
        for (ProxyField proxyField: m_readOnlyFields)
        {
            proxyField.setReadOnly(true);
        }
        for (ProxyField proxyField: m_requiredFields)
        {
            proxyField.setRequired(true);
        }
        for (Exclude exclude: m_excludes)
        {
            ProxyField proxyField = exclude.getProxyField();
            proxyField.exclude(exclude.getKey());
            exclude.getRuleContext().addExclude(exclude);

        }
		m_session.setEnabled(enabled);
		s_log.debug("Finished Setting values");
	}
119902
def _set_attributes(self):
        """"""
        for parameter, data in self._data.items():
            if isinstance(data, dict) or isinstance(data, OrderedDict):
                field_names, field_values = zip(*data.items())
                sorted_indices = np.argsort(field_names)
                attr = namedtuple(
                    parameter, [field_names[i] for i in sorted_indices]
                )
                setattr(
                    self, parameter,
                    attr(*[field_values[i] for i in sorted_indices])
                )
            else:
                setattr(self, parameter, data)
378890
def force_set(self, state):
    """"""
    translator = self._meta['translator']
    state = translator.translate(state)
    attr = self._meta['state_attribute_name']
    setattr(self, attr, state)
1300341
def set_response_defaults(self, response, request=None):
        """"""
        for header_name, header_value in self.response_headers:
            response.set_header(header_name, header_value)
        if self.set_status:
            response.status = self.set_status
        response.content_type = self.content_type(request, response)
497616
def setnx(self, key, value):
        """"""
        return self.set(key, value, nx=True)