Remove unset values from a dict.

    :param dict d: A dict to strip.
    :return dict: A dict with unset values removed.
160322
def of(d):
    
    return {k: v for k, v in iteritems(d) if v != unset}
1152543
def _clean_dict(row):
    
    row_cleaned = {}
    for key, val in row.items():
        if val is None or val == '':
            row_cleaned[key] = None
        else:
            row_cleaned[key] = val
    return row_cleaned
414673
def clean_dict(d0, clean_item_fn=None):
    
    clean_item_fn = clean_item_fn if clean_item_fn else clean_item
    d = dict()
    for key in d0:
        cleaned_item = clean_item_fn(d0[key])
        if cleaned_item is not None:
            d[key] = cleaned_item
    return d
1124845
def unwrap(self, d, item):
        
        nopt = ( lambda x: x )
        try:
            md = d.__metadata__
            pmd = getattr(md, '__print__', None)
            if pmd is None:
                return item
            wrappers = getattr(pmd, 'wrappers', {})
            fn = wrappers.get(item[0], nopt)
            return (item[0], fn(item[1]))
        except:
            pass
        return item
1185901
def unflatten(flat_dict: Dict[str, Any]) -> Dict[str, Any]:
    
    unflat: Dict[str, Any] = {}

    for compound_key, value in flat_dict.items():
        curr_dict = unflat
        parts = compound_key.split(".")
        for key in parts[:-1]:
            curr_value = curr_dict.get(key)
            if key not in curr_dict:
                curr_dict[key] = {}
                curr_dict = curr_dict[key]
            elif isinstance(curr_value, dict):
                curr_dict = curr_value
            else:
                raise ConfigurationError("flattened dictionary is invalid")
        if not isinstance(curr_dict, dict) or parts[-1] in curr_dict:
            raise ConfigurationError("flattened dictionary is invalid")
        else:
            curr_dict[parts[-1]] = value

    return unflat
1355522
def uncache(self, key, value):
        
        try:
            assert self.get(key) is value
            del self.data[key]
        except KeyError:
            # If the entry has already been removed from the cache, this will
            # result in KeyError which we ignore. If the entry is still in the
            # cache, but the weakref has been broken, this will result in
            # CacheFault (a KeyError subclass) which we also ignore. See the
            # comment in get() for an explanation of why this might happen.
            pass
1233287
def normalize_dictionary(data_dict):
    
    for key, value in data_dict.items():
        if not isinstance(key, str):
            del data_dict[key]
            data_dict[str(key)] = value
    return data_dict
988476
def get_unset_inputs(self):
        
        return set([k for k, v in self._inputs.items() if v.is_empty(False)])
584962
def unflatten(flat_dict, separator='_'):
    
    _unflatten_asserts(flat_dict, separator)

    # This global dictionary is mutated and returned
    unflattened_dict = dict()

    def _unflatten(dic, keys, value):
        for key in keys[:-1]:
            dic = dic.setdefault(key, {})

        dic[keys[-1]] = value

    for item in flat_dict:
        _unflatten(unflattened_dict, item.split(separator), flat_dict[item])

    return unflattened_dict
229041
def _filter_keys(d: dict, keys: set) -> dict:
        
        return {key: d[key] for key in keys if key in d}
962412
def clean_dictkeys(ddict, exclusions=None):
    
    exclusions = [] if exclusions is None else exclusions

    if not isinstance(ddict, dict):
        return {}

    for key in list(ddict.keys()):
        if [incl for incl in exclusions if incl in key]:
            data = ddict.pop(key)
            clean_key = exclude_chars(key, exclusions)

            if clean_key:
                if clean_key in ddict:
                    ddict[clean_key] = force_list(ddict[clean_key])
                    add_element(ddict, clean_key, data)
                else:
                    ddict[clean_key] = data

        # dict case
        if isinstance(ddict.get(key), dict):
            ddict[key] = clean_dictkeys(ddict[key], exclusions)

        # list case
        elif isinstance(ddict.get(key), list):
            for row in ddict[key]:
                if isinstance(row, dict):
                    row = clean_dictkeys(row, exclusions)

    return ddict
1230944
def remove_reserved_keys(self, op):
        
        sanitized = {}
        reserved = {}
        
        for k in op.keys():
            if str(k) not in RESERVED_KEYS:
                sanitized[str(k)] = copy.deepcopy(op[k])
            else:
                reserved[str(k)] = copy.deepcopy(op[k])
                
        return sanitized, reserved
217064
def _drop_none_values(dictionary: Dict) -> Dict:
    
    return {key: value for key, value in dictionary.items() if value is not None}
1050028
def unpickle_dict(items):
    ''''''
    pickled_keys = items.pop('_pickled', '').split(',')
    ret = {}
    for key, val in items.items():
        if key in pickled_keys:
            ret[key] = pickle.loads(val)
        else:
            ret[key] = val
    return ret
1015918
def unbind(self):
        
        args_dispatchers = set()
        f = self._wf()
        if f is not None:
            for ad_list in self.bound_to.values():
                args_dispatchers.update(ad_list)
                for argspec, dispatcher in ad_list:
                    dispatcher.unbind(self.f, argspec)
            del f.__dict__['__mnd__']
        self.bound_to = {}
        return args_dispatchers
864937
def unset(self, key):
        
        params = {
            'key': key
        }
        return self.client.delete(self._url(), params=params)
781325
def _remove_unicode_keys(dictobj):
    
    if sys.version_info[:2] >= (3, 0): return dictobj

    assert isinstance(dictobj, dict)

    newdict = {}
    for key, value in dictobj.items():
        if type(key) is unicode:
            key = key.encode('utf-8')
        newdict[key] = value
    return newdict