look for a certain key within a dictionary and nullify ti's contents, check within nested
    dictionaries and lists as well.  Certain attributes such as "generation" will change even
    when there were no changes made to the entity.
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
695149
def clear_filter(section, key)
      key = key.kind_of?(Symbol) ? key : key.to_sym
      self.current_filter[section][key] = []
      return nil
    end
261782
def dictlist_wipe_key(dict_list: Iterable[Dict], key: str) -> None:
    
    for d in dict_list:
        d.pop(key, None)
377069
def on_remove(self, widget, data=None):
        
        treeiter, path = self.get_selected_object()
        if not treeiter:
            return

        # check if an element is selected
        dict_path_as_list = self.tree_store[path][self.ID_STORAGE_ID]
        logger.debug("Deleting semantic data entry with name {}!".format(dict_path_as_list[-1]))
        self.model.state.remove_semantic_data(dict_path_as_list)
        self.reload_tree_store_data()

        # hold cursor position where the last element was removed
        try:
            self.select_entry(self.tree_store[path][self.ID_STORAGE_ID])
        except IndexError:
            if len(self.tree_store):
                if len(path) > 1:
                    possible_before_path = tuple(list(path[:-1]) + [path[-1] - 1])
                    if possible_before_path[-1] > -1:
                        self.select_entry(self.tree_store[possible_before_path][self.ID_STORAGE_ID])
                    else:
                        self.select_entry(self.tree_store[path[:-1]][self.ID_STORAGE_ID])
                else:
                    self.select_entry(self.tree_store[path[0] - 1][self.ID_STORAGE_ID])
        return True
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
434607
def set(self, key_or_attrs, value=None, unset=False):
        
        if isinstance(key_or_attrs, dict) and value is None:
            attrs = key_or_attrs
            keys = attrs.keys()
            for k in keys:
                if isinstance(attrs[k], LocalProxy):
                    attrs[k] = attrs[k]._get_current_object()
        else:
            key = key_or_attrs
            if isinstance(value, LocalProxy):
                value = value._get_current_object()
            attrs = {key: utils.decode(key, value)}

        if unset:
            for k in attrs.keys():
                attrs[k] = operation.Unset()

        self.validate(attrs)

        self._merge_metadata(attrs)

        keys = list(attrs.keys())
        for k in keys:
            v = attrs[k]
            # TODO: Relation

            if not isinstance(v, operation.BaseOp):
                v = operation.Set(v)

            self._attributes[k] = v._apply(self._attributes.get(k), self, k)
            if self._attributes[k] == operation._UNSET:
                del self._attributes[k]
            self._changes[k] = v._merge(self._changes.get(k))

        return self
504519
def _check_targ(targ, keys):
    """
    if not targ:  # If None
        targ = {}
    elif not isinstance(targ, (list, tuple, dict)):  # If only one value
        targ = [targ, ]
    if isinstance(targ, (list, tuple)):  # Put list into dict
        targ = {keys[i]: targ[i] for i in range(min(len(targ), len(keys)))}
    return targ
869558
def _check_diff(changes):
    '''
    
    '''
    for conf_dict in changes:
        if conf_dict == 'Networks':
            continue
        for item in changes[conf_dict]:
            if changes[conf_dict][item]['new'] is None:
                old = changes[conf_dict][item]['old']
                if old == '':
                    return True
                else:
                    try:
                        if all(x == '' for x in old):
                            return True
                    except TypeError:
                        # Old value is not an iterable type
                        pass
    return False
1125627
def compare_dicts(old_full, new_full, old_data, new_data, depth=0):
    
    depth = depth + 1
    indent = "  "*depth

    # Print with an indentation matching the nested-dictionary depth
    def my_print(str):
        print("{}{}".format(indent, str))

    old_keys = list(old_data.keys())
    # Compare data key by key, in *this* dictionary level
    # Note: since we're comparing by keys explicity, order doesnt matter
    for key in old_keys:
        # Remove elements as we go
        old_vals = old_data.pop(key)
        # Current key
        my_print("{}".format(key))
        # If `new_data` doesnt also have this key, return False
        if key not in new_data:
            my_print("Key '{}' not in new_data.".format(key))
            my_print("Old:")
            my_print(pprint(new_data))
            my_print("New:")
            my_print(pprint(new_data))
            return False

        # If it does have the key, extract the values (remove as we go)
        new_vals = new_data.pop(key)
        # If these values are a sub-dictionary, compare those
        if isinstance(old_vals, dict) and isinstance(new_vals, dict):
            # If the sub-dictionary are not the same, return False
            if not compare_dicts(old_full, new_full, old_vals, new_vals, depth=depth):
                return False
        # If these values are a list of sub-dictionaries, compare each of those
        elif (isinstance(old_vals, list) and isinstance(old_vals[0], dict) and
              isinstance(old_vals, list) and isinstance(old_vals[0], dict)):
            for old_elem, new_elem in zip_longest(old_vals, new_vals):
                # If one or the other has extra elements, print message, but
                # continue on
                if old_elem is None or new_elem is None:
                    my_print("Missing element!")
                    my_print("\tOld: '{}'".format(old_elem))
                    my_print("\tNew: '{}'".format(new_elem))
                else:
                    if not compare_dicts(old_full, new_full, old_elem, new_elem, depth=depth):
                        return False

        # At the lowest-dictionary level, compare the values themselves
        else:
            # Turn everything into a list for convenience (most things should be
            # already)
            if  (not isinstance(old_vals, list) and
                 not isinstance(new_vals, list)):
                old_vals = [old_vals]
                new_vals = [new_vals]

            # Sort both lists
            old_vals = sorted(old_vals)
            new_vals = sorted(new_vals)

            for oldv, newv in zip_longest(old_vals, new_vals):
                # If one or the other has extra elements, print message, but
                # continue on
                if oldv is None or newv is None:
                    my_print("Missing element!")
                    my_print("\tOld: '{}'".format(oldv))
                    my_print("\tNew: '{}'".format(newv))
                # If values match, continue
                elif oldv == newv:
                    my_print("Good Match: '{}'".format(key))
                # If values dont match, return False
                else:
                    my_print("Bad  Match: '{}'".format(key))
                    my_print("\tOld: '{}'".format(oldv))
                    my_print("\tNew: '{}'".format(newv))
                    return False

    return True
733969
def content_check(self, result):
        '''
        
        '''
        if not isinstance(result, dict):
            err_msg = 'Malformed state return. Data must be a dictionary type.'
        elif not isinstance(result.get('changes'), dict):
            err_msg = "'Changes' should be a dictionary."
        else:
            missing = []
            for val in ['name', 'result', 'changes', 'comment']:
                if val not in result:
                    missing.append(val)
            if missing:
                err_msg = 'The following keys were not present in the state return: {0}.'.format(', '.join(missing))
            else:
                err_msg = None

        if err_msg:
            raise SaltException(err_msg)

        return result
966709
def absent(name, keys=None, **connection_args):
    '''
    
    '''
    ret = {'name': name,
           'changes': {},
           'result': True,
           'comment': 'Key(s) specified already absent'}

    if keys:
        if not isinstance(keys, list):
            ret['result'] = False
            ret['comment'] = '`keys` not formed as a list type'
            return ret
        delete_list = [key for key in keys
                       if __salt__['redis.exists'](key, **connection_args)]
        if not delete_list:
            return ret
        __salt__['redis.delete'](*delete_list, **connection_args)
        ret['changes']['deleted'] = delete_list
        ret['comment'] = 'Keys deleted'
        return ret

    if __salt__['redis.exists'](name, **connection_args):
        __salt__['redis.delete'](name, **connection_args)
        ret['comment'] = 'Key deleted'
        ret['changes']['deleted'] = [name]
    return ret
631842
function(key) {
    if (arguments.length === 0) {
      // reset all values, including non-enumerable and readonly properties
      this.key_list.forEach(function(key) {
        this._reset(key);
      }, this);

    } else {
      this._reset(key);
    }
  }
888560
def compare_changes(obj, **kwargs):
    '''
    
    '''
    changes = {}
    for key, value in obj.items():
        if key in kwargs:
            if value != kwargs[key]:
                changes[key] = kwargs[key]
    return changes
20646
def remove_empty_from_dict(dictionary):
    
    if isinstance(dictionary, dict):
        return dict(
            (k,
             remove_empty_from_dict(v)) for k, v in iteritems(
                 dictionary) if v and remove_empty_from_dict(v))
    elif isinstance(dictionary, list):
        return [remove_empty_from_dict(v) for v in dictionary if v and remove_empty_from_dict(v)]
    return dictionary
133791
function cleanup(key) {
    callbackQueue[key] = null;
    if (++nulls > nullThreshold) {
        callbackQueue = omit(callbackQueue, function removeNulls(datum) {
            return datum === null;
        });
    }
}
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
959585
def merge_dictionaries(current, new, only_defaults=False, template_special_case=False):
    '''
    

    '''
    changes = 0
    for key, value in new.items():
        if key not in current:
            if hasattr(global_settings, key):
                current[key] = getattr(global_settings, key)
                LOGGER.debug("Set %r to global default %r.", key, current[key])
            else:
                current[key] = copy.copy(value)
                LOGGER.debug("Set %r to %r.", key, current[key])
                changes += 1
                continue
        elif only_defaults:
            continue
        current_value = current[key]
        if hasattr(current_value, 'items'):
            changes += merge_dictionaries(current_value, value)
        elif isinstance(current_value, (list, tuple)):
            for element in value:
                if element not in current_value:
                    if template_special_case and key == 'TEMPLATES':
                        existing_matches = [
                            template for template in current_value if template['BACKEND'] == element['BACKEND']
                        ]
                        if existing_matches:
                            changes += merge_dictionaries(existing_matches[0], element)
                        else:
                            current[key] = list(current_value) + [element]
                            LOGGER.debug("Added %r to %r.", element, key)
                            changes += 1
                    else:
                        current[key] = list(current_value) + [element]
                        LOGGER.debug("Added %r to %r.", element, key)
                        changes += 1
        elif isinstance(current_value, Promise) or isinstance(value, Promise):
            # If we don't know what to do with it, replace it.
            if current_value is not value:
                current[key] = value
                LOGGER.debug("Set %r to %r.", key, current[key])
                changes += 1
        else:
            # If we don't know what to do with it, replace it.
            if current_value != value:
                current[key] = value
                LOGGER.debug("Set %r to %r.", key, current[key])
                changes += 1
    return changes