Utility method

    :param dict_of_dict_of_list:
    :param first_key:
    :param second_key:
    :param parser:
    :return:
337093
def insert_element_to_dict_of_dicts_of_list(dict_of_dict_of_list, first_key, second_key, parser):
    
    list_to_insert = parser if isinstance(parser, list) else [parser]

    if first_key not in dict_of_dict_of_list.keys():
        dict_of_dict_of_list[first_key] = {second_key: list_to_insert}
    else:
        if second_key not in dict_of_dict_of_list[first_key].keys():
            dict_of_dict_of_list[first_key][second_key] = list_to_insert
        else:
            dict_of_dict_of_list[first_key][second_key] += list_to_insert
832376
def config_parser_to_dict(config_parser):
    
    response = {}

    for section in config_parser.sections():
        for option in config_parser.options(section):
            response.setdefault(section, {})[option] = config_parser.get(section, option)

    return response
817131
def column_headers_from_list_of_dicts(self, json_input):
        
        if not json_input \
        or not hasattr(json_input, '__getitem__') \
        or not hasattr(json_input[0], 'keys'):
            return None
        column_headers = json_input[0].keys()
        for entry in json_input:
            if not hasattr(entry, 'keys') \
            or not hasattr(entry, '__iter__') \
            or len(entry.keys()) != len(column_headers):
                return None
            for header in column_headers:
                if header not in entry:
                    return None
        return column_headers
263297
def first_key(res):
    
    if not isinstance(res, dict):
        raise ValueError('Value should be of dict type')

    if len(res.keys()) != 1:
        raise RedisClusterException("More then 1 result from command")

    return list(res.values())[0]
1077764
def dict_to_table(dictionary, list_of_keys=None):
    

    # assert len(dictionary.values()) > 0, "Dictionary cannot be empty"

    # Create an empty table

    table = Table()

    # If the dictionary is not empty, fill the table

    if len(dictionary) > 0:

        # Add the names as first column

        table['name'] = dictionary.keys()

        # Now add all other properties

        # Use the first parameter as prototype

        prototype = dictionary.values()[0]

        column_names = prototype.keys()

        # If we have a white list for the columns, use it

        if list_of_keys is not None:

            column_names = filter(lambda key: key in list_of_keys, column_names)

        # Fill the table

        for column_name in column_names:

            table[column_name] = map(lambda x: x[column_name], dictionary.values())

    return table
482292
def _iter_list_for_dicts(self, check_list):
        """"""

        list_copy = copy.deepcopy(check_list)
        for index, elem in enumerate(check_list):
            if isinstance(elem, dict):
                list_copy[index] = self._check_for_python_keywords(elem)
            elif isinstance(elem, list):
                list_copy[index] = self._iter_list_for_dicts(elem)
            else:
                list_copy[index] = elem
        return list_copy
1194994
def list_of_lists_to_dict(l):
    
    d = {}
    for key, val in l:
        d.setdefault(key, []).append(val)
    return d
1357528
def _expand_one_key_dictionary(_dict):
    '''
    
    '''
    key = next(six.iterkeys(_dict))
    value = _dict[key]
    return key, value
1176823
def cast_pars_dict(pars_dict):
    

    o = {}

    for pname, pdict in pars_dict.items():

        o[pname] = {}

        for k, v in pdict.items():

            if k == 'free':
                o[pname][k] = bool(int(v))
            elif k == 'name':
                o[pname][k] = v
            else:
                o[pname][k] = float(v)

    return o
610972
def dictlist_replace(dict_list: Iterable[Dict], key: str, value: Any) -> None:
    
    for d in dict_list:
        d[key] = value
802961
def parser_helper(key, val):
    '''
    
    '''
    start_bracket = key.find("[")
    end_bracket = key.find("]")
    pdict = {}
    if has_variable_name(key):  # var['key'][3]
        pdict[key[:key.find("[")]] = parser_helper(key[start_bracket:], val)
    elif more_than_one_index(key):  # ['key'][3]
        newkey = get_key(key)
        newkey = int(newkey) if is_number(newkey) else newkey
        pdict[newkey] = parser_helper(key[end_bracket + 1:], val)
    else:  # key = val or ['key']
        newkey = key
        if start_bracket != -1:  # ['key']
            newkey = get_key(key)
            if newkey is None:
                raise MalformedQueryStringError
        newkey = int(newkey) if is_number(newkey) else newkey
        if key == u'[]':  # val is the array key
            val = int(val) if is_number(val) else val
        pdict[newkey] = val
    return pdict
556357
def deep_update(dict1, dict2):
    
    def flatten(v):
        if isinstance(v, ModifyList):
            return v.apply([])
        elif isinstance(v, dict):
            return dict((k, flatten(v_)) for k, v_ in v.iteritems())
        else:
            return v

    def merge(v1, v2):
        if isinstance(v1, dict) and isinstance(v2, dict):
            deep_update(v1, v2)
            return v1
        elif isinstance(v2, ModifyList):
            v1 = flatten(v1)
            return v2.apply(v1)
        else:
            return flatten(v2)

    for k1, v1 in dict1.iteritems():
        if k1 not in dict2:
            dict1[k1] = flatten(v1)

    for k2, v2 in dict2.iteritems():
        v1 = dict1.get(k2)

        if v1 is KeyError:
            dict1[k2] = flatten(v2)
        else:
            dict1[k2] = merge(v1, v2)
1176362
def dfilter(self, **kwds):
        
        starting_list = self[:]
        filtered_list = []
        for key, value in six.iteritems(kwds):
            for item in starting_list:
                if self._match(item, key, value):
                    filtered_list.append(item)
            starting_list = filtered_list
            filtered_list = []
        return DictRegister(starting_list)
431534
def sumMerge(dict1, dict2):
    
    for key in dict2:
        dict1[key] = list(map(lambda a,b: a + b, dict1.get(key, [0,0,0,0]), dict2[key]))
    return dict1
646982
def from_jsondict(cls, dict_):
        
        fields = [ofproto.oxm_from_jsondict(f) for f
                  in dict_['oxm_fields']]
        return OFPMatch(_ordered_fields=fields)
609708
def _dict_compose(dict1, dict2):
    
    return {k: dict2.get(v) for k, v in dict1.items() if v in dict2}
1199584
def dict2tlist(this_dict,**kwargs):
    '''
        
    '''
    if('check' in kwargs):
        check = kwargs['check']
    else:
        check = 1
    if(check):
        if(isinstance(this_dict,dict)):
            pass
        else:
            return(None)
    else:
        pass
    if('deepcopy' in kwargs):
        deepcopy = kwargs['deepcopy']
    else:
        deepcopy = 1
    tuple_list = []
    if(deepcopy):
        new = copy.deepcopy(this_dict)
    else:
        new = this_dict
    i = 0
    for key in this_dict:
        value = this_dict[key]
        tuple_list.append((key,value))
    return(tuple_list)