Create a dict whose keys are the members of the iterable and values
        are the number of times the key appears in the iterable.
778235
def fromrepetitions(cls, iterable):
        
        d = cls()
        for key in iterable:
            d[key] = d[key] + 1 if key in d else 1
        return d
703962
def valuestodict(key):
    """"""
    dict = {}
    size = winreg.QueryInfoKey(key)[1]
    for i in range(size):
        data = winreg.EnumValue(key, i)
        dict[data[0]] = data[1]
    return dict
209609
def dict_of_lists(self):
        
        result = {}
        for key, value in self._items:
            if key in result:
                result[key].append(value)
            else:
                result[key] = [value]
        return result
1294438
def to_dict(self, get_value=None):
        """"""
        self.trim()
        result = {}
        for key, value in iteritems(self.counters):
            if get_value is not None:
                value = getattr(value, get_value)
            r = result
            for _key in key[:-1]:
                r = r.setdefault(_key, {})
            r[key[-1]] = value
        return result
499724
def _count(dicts):
    
    counts = defaultdict(int)
    for d in dicts:
        for k, v in d.items():
            counts[k] += v
    return counts
113285
def keys(self):
        
        keys = list()
        for n in range(len(self)):

            # only append the valid keys
            key = self.get_value()
            if not key in ['', None]: keys.append(key)

        return keys
32514
def keys_values(data, *keys):
    """"""
    values = []
    if is_mapping(data):
        for key in keys:
            if key in data:
                values.extend(ensure_list(data[key]))
    return values
935799
def values(self, values):
        
        if isinstance(values, dict):
            l = []
            for column in self._columns:
                l.append(values[column])
            self._values.append(tuple(l))
        else:
            self._values.append(values)
        return self
855996
def to_dict(self, get_value=None):
        """"""
        result = {}
        for key, value in iteritems(self):
            if isinstance(value, BaseCounter):
                if get_value is not None:
                    value = getattr(value, get_value)
                result[key] = value
            else:
                result[key] = value.to_dict(get_value)
        return result
1176123
def iteritems(self):
        
        for (key, val) in six.iteritems(self.__dict__):
            if key in self._printable_exclude:
                continue
            yield (key, val)
683065
def iterallvalues(self, key=_absent):
        '''
        
        '''
        if key is not _absent:
            if key in self:
                return iter(self.getlist(key))
            raise KeyError(key)
        return self._items.itervalues()
340762
def dict(self):
        
        d = {p.key: getattr(self, p.key) for p in self.__mapper__.attrs
             if p.key not in ('table', 'stats', '_codes', 'data')}

        if not d:
            raise Exception(self.__dict__)

        d['schema_type'] = self.schema_type

        if self.data:
            # Copy data fields into top level dict, but don't overwrite existind values.
            for k, v in six.iteritems(self.data):
                if k not in d and k not in ('table', 'stats', '_codes', 'data'):
                    d[k] = v

        return d
1141117
def dict_values(src):
    
    for v in src.values():
        if isinstance(v, dict):
            for v in dict_values(v):
                yield v
        else:
            yield v
757279
def key_occurrence(self, key, update=True):
        
        if update:
            self.update()
        result = {}
        for k, v in self.database.items():
            if key in v:
                result[str(v[key])] = k
        return result
137870
def stringify_values(data):
    
    if not isinstance(data, dict):
        raise ValueError('Data must be dict. %r is passed' % data)

    values_dict = {}
    for key, value in data.items():
        items = []
        if isinstance(value, six.string_types):
            items.append(value)
        elif isinstance(value, Iterable):
            for v in value:
                # Convert to str int values
                if isinstance(v, int):
                    v = str(v)
                try:
                    item = six.u(v)
                except TypeError:
                    item = v
                items.append(item)
            value = ','.join(items)
        values_dict[key] = value
    return values_dict
1110358
def _dict_subset(keys, master_dict):
    '''
    
    '''
    return dict([(k, v) for k, v in six.iteritems(master_dict) if k in keys])
139817
def valid_dict(d, keys=None):
    

    if keys is None:
        d_ = d
    else:
        d_ = itemfilter(lambda item: item[0] in keys, d)
        if len(d_) != len(keys):
            return False
    values = list(itervalues(d_))
    return False if None in values else True