Converts inner OrderedDict to bare dict
321325
def ordered_dict_to_dict(d):
    
    ret = {}
    new_d = deepcopy(d)
    for k, v in new_d.items():
        if isinstance(v, OrderedDict):
            v = dict(v)
        if isinstance(v, dict):
            v = ordered_dict_to_dict(v)
        ret[k] = v
    return ret
192769
def is_ordered_dict(d):
    
    py3_ordered_dicts = (sys.version_info.major == 3) and (sys.version_info.minor >= 6)
    vanilla_odicts = (sys.version_info.major > 3) or py3_ordered_dicts
    return isinstance(d, (OrderedDict))or (vanilla_odicts and isinstance(d, dict))
854720
def pretty(self):
        ""
        pretty_obj = OrderedDict()
        for key, value in sorted(iteritems(self.__dict__)):
            if value is None:
                pretty_obj[key] = None
            elif is_str_or_unicode(value):
                pretty_obj[key] = self.__dict__.get(key)
            elif isinstance(value, list):
                pretty_obj[key] = []
            elif isinstance(value, dict):
                pretty_obj[key] = {}
            else:
                pretty_obj[key] = unicode_value(value)
        return pretty_obj
843569
def tag_dict(obj, *args, **kwargs):
    """"""

    if isinstance(obj, OrderedDict):
        return _TaggedOrderedDict(obj, *args, **kwargs)
    else:
        return _TaggedPlainDict(obj, *args, **kwargs)
959227
def primitive(self):
        """"""
        dict = {}
        for key, value in self.__dict__.items():
            if not key.startswith('_'):
                dict[key] = copy(value)

        for key in dict:
            if isinstance(dict[key], (set)):
                dict[key] = sorted(list(dict[key]))

        return dict
614254
def str2dict_keys(str_in):
    '''
    
    '''
    tmp_dict = str2dict(str_in)
    if tmp_dict is None:
        return None
    return sorted([k for k in tmp_dict])
1333856
def __clean_dict(dictionary):
        
        key_dict = {}
        value_dict = {}
        final_list = []
        for key in dictionary.keys():
            key_dict[key] = "seq"

        for value in dictionary.values():
            value_dict[value] = "text"

        for (key1, value1), (key2, value2) in zip(key_dict.items(), value_dict.items()):
            final_list.append({value1: int(key1), value2: key2})

        return final_list
706548
def to_dict(self, remove_nones=False):
        

        if remove_nones:
            return {k: v for k, v in self.to_dict().items() if v is not None}
        else:
            raise NotImplementedError()
357198
def dictfetchone(cursor: Cursor) -> Optional[Dict[str, Any]]:
    
    columns = get_fieldnames_from_cursor(cursor)
    row = cursor.fetchone()
    if not row:
        return None
    return OrderedDict(zip(columns, row))
1028599
def convert_to_nested_dict(dotted_dict):
    """"""
    nested_dict = {}
    for k, v in iterate_flattened(dotted_dict):
        set_by_dotted_path(nested_dict, k, v)
    return nested_dict
1057868
def to_param_dict(self):
        
        param_dict = {}
        for index, dictionary in enumerate(self.value):
            for key, value in dictionary.items():
                param_name = '{param_name}[{index}][{key}]'.format(
                                                    param_name=self.param_name,
                                                    index=index,
                                                    key=key)
                param_dict[param_name] = value
        return OrderedDict(sorted(param_dict.items()))
1294438
def to_dict(self, get_value=None):
        """"""
        self.trim()
        result = {}
        for key, value in iteritems(self.counters):
            if get_value is not None:
                value = getattr(value, get_value)
            r = result
            for _key in key[:-1]:
                r = r.setdefault(_key, {})
            r[key[-1]] = value
        return result
174503
def get_inner_data(dictionary):
    

    out = {}

    for key in dictionary.keys():
        inner_keys = dictionary[key].keys()
        for inner_key in inner_keys:
            new_key = key + " " + inner_key  # concatenate
            out[new_key] = dictionary[key][inner_key]

    return out
183557
def to_dict(self, remove_nones=False):
        

        if remove_nones:
            return super().to_dict(remove_nones=True)

        return {
            'id': self.id,
            'name': self.name,
            'type': self.type
        }
289925
def iterdict(self):
        """"""
        from collections import OrderedDict

        headers = None

        for row in self:

            if headers is None:
                headers = row
                continue

            yield OrderedDict(zip(headers, row))
699704
def to_dict(self, minimal=False):

        """"""

        data = collections.OrderedDict()

        if minimal:

            # In the minimal representation we just output the value

            data['value'] = self._to_python_type(self.value)

        else:

            # In the complete representation we output everything is needed to re-build the object

            data['value'] = self._to_python_type(self.value)
            data['desc'] = str(self.description)
            data['min_value'] = self._to_python_type(self.min_value)
            data['max_value'] = self._to_python_type(self.max_value)
            # We use our own thread-safe format for the unit
            data['unit'] = self.unit.to_string(format='threadsafe')

        return data
762605
def _get_dict(lines, start_index, indentation, deep):
    """"""

    info = {}
    current_item = None

    i = start_index
    while i < len(lines):

        current_line = lines[i]
        current_line_indentation = _get_indentation(current_line)

        # Check for multi-level returns
        if current_line_indentation < indentation:
            return info, i-1

        if current_line_indentation == indentation:
            current_item = current_line.lstrip(' ')
            info[current_item] = {}
            i = i + 1
            continue

        if i < len(lines) - 1:
            next_line_indentation = _get_indentation(lines[i+1])
        else:
            next_line_indentation = current_line_indentation

        if next_line_indentation > current_line_indentation:
            ret_dict, i = _get_dict(lines, i, current_line_indentation, deep+1)
            for key in ret_dict.keys():
                if key in info[current_item]:
                    info[current_item][key].update(ret_dict[key])
                else:
                    info[current_item][key] = ret_dict[key]
        else:
            key, value = _get_key_value(current_line)
            if key:
                info[current_item][key] = value

        # Do not return if it's the top level of recursion
        if next_line_indentation < current_line_indentation and deep > 0:
            return info, i

        i = i + 1

    return info, i