Extract value or values from dicts.

    Covers the case of a single key or multiple keys. If not found,
    return placeholders instead.
513872
def _getitem(item, i):
    
    if not isinstance(i, (tuple, list)):
        return item.get(i, _none)
    type_ = list if isinstance(item, list) else tuple
    return type_(item.get(j, _none) for j in i)
679169
def get_value(self, key, args, kwargs):
        """"""
        if (self.tolerant and
                not isinstance(key, basestring) and
                key not in kwargs):
            key = str(key)

        return kwargs[key]
443040
def get_values_of_matching_keys(pattern_dict, user_name):
    '''
    
    '''
    ret = []
    for expr in pattern_dict:
        if salt.utils.stringutils.expr_match(user_name, expr):
            ret.extend(pattern_dict[expr])
    return ret
56097
def _get_value(obj, key, default=missing):
    
    if "." in key:
        return _get_value_for_keys(obj, key.split("."), default)
    else:
        return _get_value_for_key(obj, key, default)
665304
def get_single_value(d):
    """"""
    assert len(d) == 1, 'Single-item dict must have just one item, not %d.' % len(d)
    return next(six.itervalues(d))
1309071
def extract_variables(content):
    
    if isinstance(content, (list, set, tuple)):
        variables = set()
        for item in content:
            variables = variables | extract_variables(item)
        return variables

    elif isinstance(content, dict):
        variables = set()
        for key, value in content.items():
            variables = variables | extract_variables(value)
        return variables

    elif isinstance(content, LazyString):
        return set(regex_findall_variables(content.raw_string))

    return set()
705484
def _get_val(record, keys):
    '''
    
    '''
    data = record
    for key in keys:
        if key in data:
            data = data[key]
        else:
            return None
    return data
16988
def extract_value(self, data):
        
        if self.name not in data and not self.allow_missing:
            raise exceptions.FieldNotFound('Field {} is missing from request'.format(self.name))
        
        if self.multiple_inputs:
            self.value = []
            for value in data.getlist(self.name):
                if self.strip_value:
                    value = value.strip()
                if value == '' and self.convert_empty_to_none:
                    value = None

                self.value.append(value)
        else:
            self.value = data.get(self.name)
            if self.value is not None:
                if self.strip_value:
                    self.value = self.value.strip()
                if self.value == '' and self.convert_empty_to_none:
                    self.value = None

        # Convert the value to the correct data type
        self.convert_value()
751485
function extract(bag, key, def) {
    var keys,
        cur  = bag,
        i;
    if (!key) {
        return bag || {};
    }
    keys = key.split('.');
    for (i = 0; i < keys.length; i += 1) {
        if (cur && cur.hasOwnProperty(keys[i])) {
            cur = cur[keys[i]];
        } else {
            return def;
        }
    }
    return cur;
}
51851
def _parse_dict(cls, value):
        
        separator = '='
        result = {}
        for line in cls._parse_list(value):
            key, sep, val = line.partition(separator)
            if sep != separator:
                raise DistutilsOptionError(
                    'Unable to parse option value to dict: %s' % value)
            result[key.strip()] = val.strip()

        return result
163588
def extract(query_dict, prefix=""):
    

    strs = ['order_by']
    ints = ['per_page', 'page']

    extracted = { }

    for key in (strs + ints):
        if (prefix + key) in query_dict:
            val = query_dict.get(prefix + key)

            extracted[key] = (val
                if not key in ints
                else int(val))

    return extracted
328474
def extract_options_dict(template, options):
    """"""
    for option, val in template.items():
        if options and option in options:
            yield option, options[option]
        else:
            yield option, Default(template[option]['default'](os.environ))
1190704
function parsePlaceholders (source) {
  return source.match(/\([^\)]+\)/g).reduce(function (result, placeholder) {
    placeholder = placeholder.replace(/^\(([^\)]+)\)$/, '$1');
    var keyValue = placeholder.split(':');
    result[keyValue[0]] = {
      content: keyValue[1]
    };
    return result;
  }, {});
}
275458
def get_value(kv, key, value = None):
    """"""
    res = []
    for k, v in kv:
        if k == key:
            value = v
        else:
            res.append([k, v])
    return value, res
1129385
def pluck(self, value, key=None):
        
        if key:
            return dict(map(lambda x: (data_get(x, key), data_get(x, value)), self.items))
        else:
            results = list(map(lambda x: data_get(x, value), self.items))

        return self.__class__(results)
226308
def extract_keys(self,key_list):
        
        if isinstance(key_list,basestring):
            key_list = key_list.split(',')
        return type(self)([ (k,self[k]) for k in key_list if k in self ])
879351
def parse_value(key, value):
    """"""
    default = OPTIONS.get(key)
    if isinstance(default, collections.Iterable):
        if not isinstance(default, six.string_types):
            return [item.strip()
                    for item in value.split(',')]
    return value