'Requires:
nothing
Returns:
nothing
Logic:
The styles dictionary may contain a pair of key values such as
\'next-style\' => \'15\'. I want to change the 15 to the name of the
style. I accomplish this by simply looking up the value of 15 in
the styles table.
Use two loops. First, check all the paragraph styles. Then check
all the characer styles.
The inner loop: first check \'next-style\', then check \'based-on-style\'.
Make sure values exist for the keys to avoid the nasty keyerror message.'

def __fix_based_on(self):

    types = ['par', 'char']
    for type in types:
        keys = self.__styles_dict[type].keys()
        for key in keys:
            styles = ['next-style', 'based-on-style']
            for style in styles:
                value = self.__styles_dict[type][key].get(style)
                if (value is not None):
                    temp_dict = self.__styles_dict[type].get(value)
                    if temp_dict:
                        changed_value = self.__styles_dict[type][value].get('name')
                        if changed_value:
                            self.__styles_dict[type][key][style] = changed_value
                    else:
                        if ((value == 0) or (value == '0')):
                            pass
                        elif (self.__run_level > 4):
                            msg = ('%s    %s    is    based    on    %s\n' % (type, key, value))
                            msg = ('There    is    no    style    with    %s\n' % value)
                            raise self.__bug_handler, msg
                        del self.__styles_dict[type][key][style]
