Helper for pulling a keyed value off various types of objects
186389
def get_value(key, obj, default=missing):
    """"""
    if isinstance(key, int):
        return _get_value_for_key(key, obj, default)
    return _get_value_for_keys(key.split('.'), obj, default)
723365
function coerceAll(obj) {
    var type = Array.isArray(obj) ? 'array' : typeof obj;

    switch(type) {
        case 'string':
            return coerce(obj);
            break;
        case 'object':
            if(obj) {
                Object.keys(obj).forEach(function (key) {
                    obj[key] = coerceAll(obj[key]);
                });
            }
            break;
        case 'array':
            obj.map(function (o) {
                return coerceAll(o);
            });
            break;
    }

    return obj;
}
701816
function __objectValues(o) {
    var k,
        a = [];

    for (k in o)
      a.push(o[k]);

    return a;
  }
1036141
def value(cls, obj, keystr):
        
        if "#{" in keystr:
            # it's a template with keys vars
            keys = cls.from_template(keystr)
            for k in keys:
                v = cls.fetch(obj, cls.extract(k))
                keystr = keystr.replace(k, str(v))

            value = keystr
        else:
            # plain keys str
            value = cls.fetch(obj, keystr)

        return value
929631
function keyOf(obj, value){
		for(var key in obj)
			if(Object.prototype.hasOwnProperty.call(obj, key) && obj[key] === value)
				return key;

		return null;
	}
8613
function extractKeyValue (line) {
  var kv = {
    key: undefined,
    value: undefined,
  };

  var matches = kvRE.exec(line);
  if (matches !== null && matches.length === 3) {
    kv.key = matches[1];
    kv.value = matches[2];
  }

  return kv;
}
1182296
function getItemValues(item, key) {
  if (typeof key === 'object') {
    key = key.key
  }
  let value
  if (typeof key === 'function') {
    value = key(item)
    // eslint-disable-next-line no-negated-condition
  } else if (key.indexOf('.') !== -1) {
    // handle nested keys
    value = key
      .split('.')
      .reduce(
        (itemObj, nestedKey) => (itemObj ? itemObj[nestedKey] : null),
        item,
      )
  } else {
    value = item[key]
  }
  // concat because `value` can be a string or an array
  // eslint-disable-next-line
  return value != null ? [].concat(value) : null
}
78595
def _get_object_key(self, p_object):
        """"""
        matched_key = None
        matched_index = None

        if hasattr(p_object, self._searchNames[0]):
            return getattr(p_object, self._searchNames[0])

        for x in xrange(len(self._searchNames)):
            key = self._searchNames[x]
            if hasattr(p_object, key):
                matched_key = key
                matched_index = x

        if matched_key is None:
            raise KeyError()

        if matched_index != 0 and self._searchOptimize:
            self._searchNames.insert(0, self._searchNames.pop(matched_index))

        return getattr(p_object, matched_key)
917327
def extract_key_values(array_value, separators=(';', ',', ':'), **kwargs):
    
    items_sep, fields_sep, keys_sep = separators
    return items_sep.join(fields_sep.join(keys_sep.join(x) for x in sorted(it.items()))
                          for it in array_value)
871173
def _extract_key_val(kv, delimiter='='):
    '''
    '''
    pieces = kv.split(delimiter)
    key = pieces[0]
    val = delimiter.join(pieces[1:])
    return key, val
157870
def fetch(self, value_obj=None):
        '''  '''
        val = None
        try:
            val = next(self.__iterable)
        except StopIteration:
            return None
        if value_obj is None:
            value_obj = Value(value=val)
        else:
            value_obj.value = val
        return value_obj
1294311
function _extract(keyStr, dataObj) {
	var altkey,
		_subKey,
		_splitPoint,
		_found = false,
		dataValue = null,
		_queryParts = [];

	if (dataObj && typeof dataObj === 'object') {
		dataValue = Object.create(dataObj);
		_queryParts = keyStr.split(/[\-\_\.]/);

		//console.warn("INIT:", keyStr, _queryParts);

		// test whole query first
		if (keyStr in dataValue) {
			dataValue = dataValue[keyStr];
			_queryParts.length = 0;
			_found = true;
		}

		// search from smallest to largest possible keys
 		while(_queryParts.length) {
			_splitPoint = _queryParts.shift();
			_subKey = keyStr.split(new RegExp('('+_splitPoint+')')).slice(0,2).join("");
			if (_subKey in dataValue) {
				dataValue = dataValue[_subKey];
				keyStr = keyStr.split(new RegExp('('+_subKey+'[\-\_\.])')).slice(2).join("");
				_found = true;
			} else {
				_found = false;
			}
			//console.warn(_found, _subKey, dataValue);
		}

		if (!_found) {
			// alternate support for delimiters in place of spaces as a key
			altkey = keyStr.replace(/[\-\_\.]/,' ');
			if (altkey in dataObj) {
				dataValue = dataObj[altkey];
				_found = true;
			}
		}
	}

	return _found ? dataValue : NaN;
}
660801
def object_deserializer(obj):
    
    for key, val in obj.items():
        if isinstance(val, six.string_types) and DATETIME_REGEX.search(val):
            try:
                obj[key] = dates.localize_datetime(parser.parse(val))
            except ValueError:
                obj[key] = val
    return obj
802961
def parser_helper(key, val):
    '''
    
    '''
    start_bracket = key.find("[")
    end_bracket = key.find("]")
    pdict = {}
    if has_variable_name(key):  # var['key'][3]
        pdict[key[:key.find("[")]] = parser_helper(key[start_bracket:], val)
    elif more_than_one_index(key):  # ['key'][3]
        newkey = get_key(key)
        newkey = int(newkey) if is_number(newkey) else newkey
        pdict[newkey] = parser_helper(key[end_bracket + 1:], val)
    else:  # key = val or ['key']
        newkey = key
        if start_bracket != -1:  # ['key']
            newkey = get_key(key)
            if newkey is None:
                raise MalformedQueryStringError
        newkey = int(newkey) if is_number(newkey) else newkey
        if key == u'[]':  # val is the array key
            val = int(val) if is_number(val) else val
        pdict[newkey] = val
    return pdict
486656
def collections(record, key, value):
    """"""
    return {
        'primary': value.get('a'),
        'secondary': value.get('b'),
        'deleted': value.get('c'),
    }
683800
function parseKeyValue(/**string*/keyValue) {
  var obj = {}, key_value, key;
  forEach((keyValue || "").split('&'), function(keyValue){
    if (keyValue) {
      key_value = keyValue.split('=');
      key = decodeURIComponent(key_value[0]);
      obj[key] = isDefined(key_value[1]) ? decodeURIComponent(key_value[1]) : true;
    }
  });
  return obj;
}
598065
def fromkeys (cls, iterable, value=None):
        """"""
        d = cls()
        for k in iterable:
            dict.__setitem__(d, k.lower(), value)
        return d