generate a dict keyed by value
438685
def _todict(cls):
        
        return dict((getattr(cls, attr), attr) for attr in dir(cls) if not attr.startswith('_'))
949117
def flatten_dict(d,
                 parent_key='', sep='.',
                 ignore_under_prefixed=True,
                 mark_value=True):
    '''
    
    '''
    items = {}
    for k in d:
        if ignore_under_prefixed and k.startswith('__'): continue
        v = d[k]
        if mark_value and k.startswith('_') and not k.startswith('__'):
            v = MarkValue(repr(v))

        new_key = sep.join((parent_key, k)) if parent_key else k
        if isinstance(v, collections.MutableMapping):
            items.update(flatten_dict(v, new_key, sep=sep,
                                        ignore_under_prefixed=True,
                                        mark_value=True)
                            )
        else:
            items[new_key] = v

    return items
371266
def keys_to_values(self, keys):
        ""
        return dict((k, v) for k, v in self.data.items() if k in keys)
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
394247
def translate_dict(cls, val):
        """"""
        escaped = ', '.join(
            ["{} -> {}".format(cls.translate_str(k), cls.translate(v)) for k, v in val.items()]
        )
        return 'Map({})'.format(escaped)
1287589
def make_dict(obj):
    """"""

    # Recursion base case
    if is_builtin(obj) or isinstance(obj, OrderedDict):
        return obj

    output_dict = {}
    for key in dir(obj):
        if not key.startswith('__') and not callable(getattr(obj, key)):
            attr = getattr(obj, key)
            if isinstance(attr, list):
                output_dict[key] = []
                for item in attr:
                    output_dict[key].append(make_dict(item))
            else:
                output_dict[key] = make_dict(attr)

    # All done
    return output_dict
283750
def _dict_to_string(dictionary):
    '''
    
    '''
    ret = ''
    for key, val in sorted(dictionary.items()):
        if isinstance(val, dict):
            for line in _dict_to_string(val):
                ret += six.text_type(key) + '-' + line + '\n'
        elif isinstance(val, list):
            text = ' '.join([six.text_type(item) for item in val])
            ret += six.text_type(key) + ': ' + text + '\n'
        else:
            ret += six.text_type(key) + ': ' + six.text_type(val) + '\n'
    return ret.splitlines()
1101032
def _flatten_dict(self, dict_):
        
        flattened_dict = {}
        for (key, value) in dict_.iteritems():
            if isinstance(value, dict):
                flattened_dict.update(self._flatten_dict(value))
            else:
                flattened_dict[key] = value
        return flattened_dict
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
462718
def keys_in_dict(d, parent_key, keys):
    
    for key, value in d.iteritems():
        if isinstance(value, dict):
            keys_in_dict(value, key, keys)
        else:
            if parent_key:
                prefix = parent_key + "."
            else:
                prefix = ""

            keys.append(prefix + key)

    return keys
1082234
def _from_dict_dict(cls, dic):
        
        return cls({_convert_id(i): v for i, v in dic.items()})
1357528
def _expand_one_key_dictionary(_dict):
    '''
    
    '''
    key = next(six.iterkeys(_dict))
    value = _dict[key]
    return key, value
594495
def values(self):
    
    if self._data:
      for key in xrange(self.order + 1):
        yield self[key]
261718
def _to_key(d):
        """"""
        as_str = json.dumps(d, sort_keys=True)
        return as_str.replace('"{{', '{{').replace('}}"', '}}')
275548
def generate_getter(value):
    """"""
    @property
    @wraps(is_)
    def getter(self):
        return self.is_(value)

    return getter
1135071
def from_dict(self, value):
        
        for key in self.keys():
            setattr(self, key, value.get(key, None))
719226
def map_values(f, D):
    ''''''
    return { key:f(val) for key,val in D.iteritems() }