Sets the dictionary of the Vividict

        The method is able to handle nested dictionaries, by calling the method recursively.

        :param new_dict: The dict that will be added to the own dict
423565
def set_dict(self, new_dict):
        
        for key, value in new_dict.items():
            if isinstance(value, dict):
                self[str(key)] = Vividict(value)
            else:
                self[str(key)] = value
1006492
def dict_update_newkeys(dict_, dict2):
    
    for key, val in six.iteritems(dict2):
        if key not in dict_:
            dict_[key] = val
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
80454
def copy(self):
        
        new = self.__class__()
        new.__dict__ = dict(self.__dict__)
        return new
1298343
def fill_tree(self, tree, input_dict):
        

        def add_element(item, key, value):
            child_name = QtGui.QStandardItem(key)
            child_name.setDragEnabled(False)
            child_name.setSelectable(False)
            child_name.setEditable(False)

            if isinstance(value, dict):
                for ket_child, value_child in value.items():
                    add_element(child_name, ket_child, value_child)
                child_value = QtGui.QStandardItem('')
            else:
                child_value = QtGui.QStandardItem(str(value))
                child_value.setData(value)

            child_value.setDragEnabled(False)
            child_value.setSelectable(False)
            child_value.setEditable(False)
            item.appendRow([child_name, child_value])

        for index, (loaded_item, loaded_item_settings) in enumerate(input_dict.items()):
            # print(index, loaded_item, loaded_item_settings)
            item = QtGui.QStandardItem(loaded_item)

            for key, value in loaded_item_settings['settings'].items():
                add_element(item, key, value)

            value = QtGui.QStandardItem('')
            tree.model().appendRow([item, value])

            if tree == self.tree_loaded:
                item.setEditable(False)
            tree.setFirstColumnSpanned(index, self.tree_infile.rootIndex(), True)
873113
def merge_dicts(dicts, deepcopy=False):
    
    assert isinstance(dicts, list) and all(isinstance(d, dict) for d in dicts)
    return dict(chain(*[copy.deepcopy(d).items() if deepcopy else d.items()
                        for d in dicts]))
344261
def _dict_set(self, key, val):
        '''
        
        '''
        if key != None and self.stringify_keys:
            key = str(key)
        db = self._keyed_db[self.split_func(key)]
        db._dict_set(key, val)
76625
def update(self, dict_):
        
        for key, value in dict_.items():
            index = self.column_index.get(key, None)
            if index is not None:
                list.__setitem__(self, index, value)
174885
def revise(self, data, ignore_none=True):
        
        if not isinstance(data, dict):
            raise TypeError("`data` has to be a dict!")

        if ignore_none:
            for key, value in data.items():
                if value is not None:
                    setattr(self, key, deepcopy(value))
        else:
            for key, value in data.items():
                setattr(self, key, deepcopy(value))

        return self
1293349
def _add_cat_dict(self,
                      cat_dict_class,
                      key_in_self,
                      check_for_dupes=True,
                      **kwargs):
        
        # Try to create a new instance of this subclass of `CatDict`
        new_entry = self._init_cat_dict(cat_dict_class, key_in_self, **kwargs)
        if new_entry is None:
            return False

        # Compare this new entry with all previous entries to make sure is new
        if cat_dict_class != Error:
            for item in self.get(key_in_self, []):
                if new_entry.is_duplicate_of(item):
                    item.append_sources_from(new_entry)
                    # Return the entry in case we want to use any additional
                    # tags to augment the old entry
                    return new_entry

        self.setdefault(key_in_self, []).append(new_entry)

        return True
1007225
def _set_fields(self, json_dict):
        
        for key, value in json_dict.items():
            if not key.startswith("_"):
                setattr(self, key, value)
1023397
function setDictionary($messages_tree)
    {
        if ($messages_tree){
            self::loadGlobalDictionary();
            $this->local_dictionary = array_merge_recursive(self::$global_dictionary, $messages_tree);
        }
    }
1115010
def deep_copy(numpy_dict):
  
  out = {}
  for key in numpy_dict:
    out[key] = numpy_dict[key].copy()
  return out
62154
def insert_element_to_dict_of_dicts(dict_of_dicts: Dict[str, Dict[str, str]], first_key: str, second_key: str, contents):
    

    if first_key not in dict_of_dicts.keys():
        dict_of_dicts[first_key] = {second_key: contents}
    else:
        if second_key not in dict_of_dicts[first_key].keys():
            dict_of_dicts[first_key][second_key] = contents
        else:
            warn('Overriding contents for ' + first_key + '/' + second_key)
            dict_of_dicts[first_key][second_key] = contents
1279764
def combine_dicts(*args, **kwargs):
    
    dicts = [arg for arg in args if isinstance(arg, dict)]
    dicts.append(kwargs)
    super_dict = collections.defaultdict(dict)

    for d in dicts:
        for k, v in iteritems(d):
            if k:
                super_dict[k] = v
    return dict(super_dict)
706922
def assign_dict(self, node, xml_dict):
        
        new_node = etree.Element(node.tag)

        # Replaces the previous node with the new one
        self._xml.replace(node, new_node)

        # Copies #text and @attrs from the xml_dict
        helpers.dict_to_etree(xml_dict, new_node)
210836
def todict_using_struct(self, dict_struct=None, dict_post_processors=None):
        
        # It is important to assign the passed kwarg to a differently named variable.
        # A dict is passed by reference and using the same kwarg here results in it
        # getting mutated - causing unforeseen side effects
        dict_struct_to_use = (
            self._dict_struct_ if dict_struct is None
            else dict_struct)
        if dict_struct_to_use is None and self._autogenerate_dict_struct_if_none_:
            dict_struct_to_use = self.autogenerated_dict_structure()
        elif dict_struct.get("attrs") is None:
            dict_struct_to_use = {}
            dict_struct_to_use["attrs"] = self.autogenerated_dict_structure()["attrs"]
            if "rels" in dict_struct:
                dict_struct_to_use["rels"] = dict_struct.get("rels")
        result = self.serialize_attrs(*dict_struct_to_use.get('attrs', []))
        for rel, rel_dict_struct in dict_struct_to_use.get('rels', {}).items():
            rel_obj = getattr(self, rel) if hasattr(self, rel) else None
            if rel_obj is not None:
                if is_list_like(rel_obj):
                    result[rel] = [i.todict_using_struct(dict_struct=rel_dict_struct)
                                   if hasattr(i, 'todict_using_struct') else i
                                   for i in rel_obj]
                elif is_dict_like(rel_obj):
                    result[rel] = {k: v.todict_using_struct(dict_struct=rel_dict_struct)
                                   if hasattr(v, 'todict_using_struct') else v
                                   for k, v in rel_obj.iteritems()}
                else:
                    result[rel] = rel_obj.todict_using_struct(
                        dict_struct=rel_dict_struct) if hasattr(
                        rel_obj, 'todict_using_struct') else rel_obj
            else:
                result[rel] = None
        if isinstance(dict_post_processors, list):
            for dict_post_processor in dict_post_processors:
                if callable(dict_post_processor):
                    result = dict_post_processor(result, self)
        return result