Remove keys from target_dict that are not available in src_dict

    :param src_dict: source dictionary to search for
    :param target_dict: target dictionary where keys should be removed
547797
def remove_missing_keys(src_dict, target_dict):
    
    for key in list(target_dict.keys()):
        if key not in src_dict:
            target_dict.pop(key)
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
1163087
def delete(*keys, **connection_args):
    '''
    
    '''
    # Get connection args from keywords if set
    conn_args = {}
    for arg in ['host', 'port', 'db', 'password']:
        if arg in connection_args:
            conn_args[arg] = connection_args[arg]

    server = _connect(**conn_args)
    return server.delete(*keys)
216491
def filter_dict(iterable, keys):
  
  if type(keys) is not list:
    keys = [keys]
  for i in iterable:
    try:
      d = {}
      for a in keys:
        try:
          d[a] = i[a]
        except KeyError:
          pass
      if d != {}:
        yield d
    except Exception:
      pass
136552
def replace(self, target):
        
        if sys.version_info < (3, 3):
            raise NotImplementedError("replace() is only available "
                                      "with Python 3.3 and later")
        self._accessor.replace(self, target)
924574
def remove_targets(self, type, kept=None):
        ''''''
        if kept is None:
            kept = [
                i for i, x in enumerate(self._targets)
                if not isinstance(x, type)
            ]
        if len(kept) == len(self._targets):
            return self
        self._targets = [self._targets[x] for x in kept]
        self._labels = [self._labels[x] for x in kept]
        if not self._groups:
            return self
        index_map = {
            o_idx: n_idx
            for n_idx, o_idx in zip(range(len(self._targets)), kept)
        }
        kept = set(kept)
        for idx, grp in enumerate(self._groups):
            self._groups[idx] = _sos_group(
                [index_map[x] for x in grp._indexes if x in kept],
                [y for x, y in zip(grp._indexes, grp._labels) if x in kept
                ]).set(**grp._dict)
        return self
137149
def recursive_update(target, update):
    
    for key in update:
        value = update[key]
        if value is None:
            del target[key]
        elif isinstance(value, dict):
            target[key] = recursive_update(target.get(key, {}), value)
        else:
            target[key] = value
    return target
809959
def delete_value(self, key):
        
        response = {}
        response['status'] = False
        response['msg'] = "key does not exist"

        file_cache = self.read_file()
        if key in file_cache:
            del file_cache[key]
            self.update_file(file_cache)
            response['status'] = True
            response['msg'] = "success"
        return response
81843
def remove(self, *args):
        

        key = self.get_storage_key(*args)
        pk = self.instance.pk.get()
        logger.debug("removing %s from index %s" % (pk, key))
        self.connection.srem(key, pk)
        self._deindexed_values.add(tuple(args))
1161292
def _filter_dicts(self):
        ''''''
        keys_to_remove = set()

        for ref_name in self.report:
            for ctg_name in self.report[ref_name]:
                self.report[ref_name][ctg_name] = self._filter_list_of_dicts(self.report[ref_name][ctg_name])
                if len(self.report[ref_name][ctg_name]) == 0:
                    keys_to_remove.add((ref_name, ctg_name))

        refs_to_remove = set()

        for ref_name, ctg_name in keys_to_remove:
            del self.report[ref_name][ctg_name]
            if len(self.report[ref_name]) == 0:
                refs_to_remove.add(ref_name)

        for ref_name in refs_to_remove:
            del self.report[ref_name]
9248
def _strip_key(dictionary, keyword):
    '''
    
    '''

    for key, value in six.iteritems(dictionary):
        if key == keyword:
            dictionary[key] = None
        elif isinstance(value, dict):
            _strip_key(value, keyword)
        elif isinstance(value, list):
            for item in value:
                if isinstance(item, dict):
                    _strip_key(item, keyword)

    return dictionary
1230553
def _clean_dic(self, dic):
        
        aux_dic = dic.copy()
        for key, value in iter(dic.items()):

            if value is None or value == '':
                del aux_dic[key]
            elif type(value) is dict:
                cleaned_dict = self._clean_dic(value)
                if not cleaned_dict:
                    del aux_dic[key]
                    continue
                aux_dic[key] = cleaned_dict
        return aux_dic
442908
def remove_member(row, key):
    '''  '''
    (target, tkey, tvalue) = dict_crawl(row, key)
    if target:
        del target[tkey]
    return row
396981
def replace(self, target):
        
        if sys.version_info < (3, 3):
            raise NotImplementedError("replace() is only available "
                                      "with Python 3.3 and later")
        if self._closed:
            self._raise_closed()
        self._accessor.replace(self, target)
270764
def _list_merge(src, dest):
    
    for k in src:
        if type(src[k]) != dict:
            dest[k] = src[k]
        else:
            # ---
            # src could have a key whose value is a list
            # and does not yet exist on dest
            if k not in dest:
                dest[k] = {}
            _list_merge(src[k], dest[k])
224660
def del_key(self, ref):
        
        if ref not in self.keys:
            response = self.request("client_del_key %s" % (ref))
            self.keys.remove(ref)
            if "success" in response:
                return None
            else:
                return response
212701
def get_items(self, source=None, target=None):
        
        self._groups = self.shared_dict()
        self._target_coll = target.collection
        self._src = source
        return source.query()