Finds attribute value in the JSON response by looking at the given locations.
963779
def find_value(context)
      locations.each do |location|
        begin
          value = context.instance_exec(&location)
          next if value.nil?
          return value
        rescue
        end
      end

      nil
    end
924243
def for_json(self):
        """"""

        if self.multiselect:
            return super(MultiSelectField, self).for_json()

        value = self.get_python()
        if hasattr(value, 'for_json'):
            return value.for_json()

        return value
800960
def _get_attributes(schema, location):
        """"""
        schema = DottedNameResolver(__name__).maybe_resolve(schema)

        def _filter(attr):
            if not hasattr(attr, "location"):
                valid_location = 'body' in location
            else:
                valid_location = attr.location in to_list(location)
            return valid_location

        return list(filter(_filter, schema().children))
12503
def json_val(path, *, ignore_bad_path=False):
  """"""
  return lambda source: get_json_val(source, path, ignore_bad_path=ignore_bad_path)
1104718
def find_value(self, key):
        """"""
        values = self.values
        if key not in values:
            raise AttributeError("Config has no value for {}".format(key))

        val = values[key]
        if isinstance(val, Default):
            return val.val
        else:
            return val
763504
def update_attrs(self):
        
        for key, value in self._response_json.items():
            if key != 'results' and type(value) not in (list, dict):
                setattr(self, key, value)
293072
def findElementByAttributeValue( elements, attribute_name, attribute_value )
      element = nil
      if elements
          if elements.is_a?( REXML::Element )
            elements.each_element_with_attribute( attribute_name, attribute_value ) { |e|  element = e }
          elsif elements.is_a?( Array )
            elements.each{ |e|
              if e.is_a?( REXML::Element ) and e.attributes[ attribute_name ] == attribute_value
                element = e
              end
            }
          end
      end
      element
   end
1197769
def findattr(self,attr,connector='parent'):
		""""""
		if (not hasattr(self,attr)):
			if (not hasattr(self,connector)):
				return None
			else:
				con=getattr(self,connector)
				if not con:
					return None
				if type(con)==type([]):
					return [x.findattr(attr,connector) for x in con]
				else:
					return con.findattr(attr,connector)
		else:
			return getattr(self,attr)
416874
def attribute_response(resource, name, value):
    
    if _get_acceptable_response_type() == JSON:
        return _single_attribute_json_response(name, value)
    else:
        return _single_attribute_html_response(resource, name, value)
1020913
def handle_attribute_value(self, value):
        """"""
        if self.re_js.match(value) or self.re_vb.match(value):
            return ''
        return value
96652
def visit_Attribute(self, node: ast.Attribute) -> None:
        """"""
        if node in self._recomputed_values:
            value = self._recomputed_values[node]

            if _representable(value=value):
                text = self._atok.get_text(node)
                self.reprs[text] = value

        self.generic_visit(node=node)
1016546
def _parse_properties(response, result_class):
    '''
    
    '''

    if response is None or response.headers is None:
        return None

    props = result_class()
    for key, value in response.headers:
        info = GET_PROPERTIES_ATTRIBUTE_MAP.get(key)
        if info:
            if info[0] is None:
                setattr(props, info[1], info[2](value))
            else:
                attr = getattr(props, info[0])
                setattr(attr, info[1], info[2](value))

    return props
1133951
def find_value_in_object(attr, obj):
    

    # Carry on inspecting inside the list or tuple
    if isinstance(obj, (collections.Iterator, list)):
        for item in obj:
            yield from find_value_in_object(attr, item)

    # Final object (dict or entity) inspect inside
    elif isinstance(obj, collections.Mapping):

        # If result is found, inspect inside and return inner results
        if attr in obj:

            # If it is iterable, just return the inner elements (avoid nested
            # lists)
            if isinstance(obj[attr], (collections.Iterator, list)):
                for item in obj[attr]:
                    yield item

            # If not, return just the objects
            else:
                yield obj[attr]

        # Carry on inspecting inside the object
        for item in obj.values():
            if item:
                yield from find_value_in_object(attr, item)
979009
private static Map<String, String> getAttributeMap(String source) {

		if (!StringUtils.hasText(source)) {
			return Collections.emptyMap();
		}

		Map<String, String> attributes = new HashMap<>();
		Matcher matcher = KEY_AND_VALUE_PATTERN.matcher(source);

		while (matcher.find()) {
			attributes.put(matcher.group(1), matcher.group(2));
		}

		return attributes;
	}
1246434
function getAttribute(element, name) {
  assertType(element, Node, false, 'Invalid element specified');

  if (!element.getAttribute) return null;

  let value = element.getAttribute(name);
  if (value === '') return true;
  if (value === undefined || value === null) return null;
  try {
    return JSON.parse(value);
  }
  catch (err) {
    return value;
  }
}
1328697
function (attr) {
            var value = typeof attr === 'string' && !! ~attr.indexOf('.') && this.__get(attr);
            if (value) {
                return value;
            }

            // break up the attr (`"foo.bar"`) into `["foo","bar"]`
            var parts = attrParts(attr),
                // get the value of the first attr name (`"foo"`)
                current = this.__get(parts.shift());
            // if there are other attributes to read
            return parts.length ?
            // and current has a value
            current ?
            // lookup the remaining attrs on current
            current._get(parts) :
            // or if there's no current, return undefined
            undefined :
            // if there are no more parts, return current
            current;
        }
1080076
def find_json(raw):
    '''
    
    '''
    ret = {}
    lines = __split(raw)
    for ind, _ in enumerate(lines):
        try:
            working = '\n'.join(lines[ind:])
        except UnicodeDecodeError:
            working = '\n'.join(salt.utils.data.decode(lines[ind:]))

        try:
            ret = json.loads(working)  # future lint: blacklisted-function
        except ValueError:
            continue
        if ret:
            return ret
    if not ret:
        # Not json, raise an error
        raise ValueError