Logo Search packages:      
Sourcecode: calibre version File versions

def calibre::ebooks::rtf2xml::make_lists::MakeLists::__write_start_list (   self,
  id 
) [private]

Required:
    id -- the id of the current list.
Return:
    Nothing
Logic:
    Write the start of a list and add the id and left-indent to the
    self.__all_lists list.
    Write cues of when a list starts for later processing.
    In order to determine the type of list, you have to iterate through
    the self.__list_of lists. This list looks like:
[[{list-id: [1, 2], [{}], [{}]] [{list-id: [3, 4], [{}]]]
    I need to get the inside lists of the main lists. Then I need to get
    the first item of what I just got. This is a dictionary. Get the list-id.
    This is  a list. Check to see if the current id is in this list. If
    so, then get the list-type from the dictionary.

Definition at line 256 of file make_lists.py.

00256                                     :
        """
        Required:
            id -- the id of the current list.
        Return:
            Nothing
        Logic:
            Write the start of a list and add the id and left-indent to the
            self.__all_lists list.
            Write cues of when a list starts for later processing.
            In order to determine the type of list, you have to iterate through
            the self.__list_of lists. This list looks like:
                [[{list-id: [1, 2], [{}], [{}]] [{list-id: [3, 4], [{}]]]
            I need to get the inside lists of the main lists. Then I need to get
            the first item of what I just got. This is a dictionary. Get the list-id.
            This is  a list. Check to see if the current id is in this list. If
            so, then get the list-type from the dictionary.
        """
        the_dict = {}
        the_dict['left-indent'] = self.__left_indent
        the_dict['id'] = id
        self.__all_lists.append(the_dict)
        self.__write_obj.write(
            'mi<mk<list_start\n'
                )
        # bogus levels are sometimes written for empty paragraphs
        if str(self.__level) not in self.__allow_levels:
            lev_num = '0'
        else:
            lev_num = self.__level
        self.__write_obj.write(
            'mi<tg<open-att__<list<list-id>%s<level>%s'
            % (id, lev_num)
                )
        list_dict = {}
        if self.__list_of_lists: # older RTF won't generate a list_of_lists
            index_of_list = self.__get_index_of_list(id)
            if index_of_list != None:# found a matching id
                list_dict = self.__list_of_lists[index_of_list][0]
                level = int(self.__level) + 1
                level_dict = self.__list_of_lists[index_of_list][level][0]
                list_type = level_dict.get('numbering-type')
                if list_type == 'bullet':
                    list_type = 'unordered'
                else:
                    list_type = 'ordered'
                self.__write_obj.write(
                    '<list-type>%s' % (list_type))
            else: #  no matching id
                self.__write_obj.write(
                    '<list-type>%s' % (self.__list_type))
        else:# older RTF
            self.__write_obj.write(
                '<list-type>%s' % (self.__list_type))
        # if you want to dump all the info to the list, rather than
        # keeping it in the table above, change self.__write_list_info
        # to true.
        if self.__list_of_lists and self.__write_list_info and list_dict:
            not_allow = ['list-id',]
            the_keys_list = list_dict.keys()
            for the_key in the_keys_list:
                if the_key in not_allow:
                    continue
                self.__write_obj.write('<%s>%s' % (the_key, list_dict[the_key]))
            the_keys_level = level_dict.keys()
            for the_key in the_keys_level:
                self.__write_obj.write('<%s>%s' % (the_key, level_dict[the_key]))
        self.__write_obj.write('\n')
        self.__write_obj.write(
            'mi<mk<liststart_\n'
                )
        self.__write_start_item()
    def __get_index_of_list(self, id):


Generated by  Doxygen 1.6.0   Back to index