(self)
Removes the items that are not supposed to be shown according to
        section settings
Removes the items that are not supposed to be shown according to
        section settings
Removes the items that are not supposed to be shown according to section settings
def _clean_book_items(self):
        """
        Removes the items that are not supposed to be shown according to
        section settings
        """

        output_name = self.convert.name
        settings = get_sections_settings(self.original_book)

        count = 1

        # mark chapters and sections to be removed (if any)
        for toc_item in parse_toc_nav(self.original_book):
            if isinstance(toc_item[1], list):
                section_title, chapters = toc_item

                key = self.build_section_key(section_title, count)
                section_settings = json.loads(settings.get(key, '{}'))
                show_in_outputs = section_settings.get('show_in_outputs', {})

                # means to remove the chapters that belongs to this section
                if not show_in_outputs.get(output_name, True):
                    self.chapters_to_remove += [x[1] for x in chapters]
                    self.sections_to_remove.append(key)

                # increment if a section is found
                count += 1

        # now let's loop over all the book items and exclude the ones are marked to be removed
        new_items = []
        for i, item in enumerate(list(self.original_book.items)):
            if item.get_name() not in self.chapters_to_remove:
                new_items.append(item)

        self.original_book.items = new_items
def _clean_book_items ( self ) : output_name = self . convert . name settings = get_sections_settings ( self . original_book ) count = 1 # mark chapters and sections to be removed (if any) for toc_item in parse_toc_nav ( self . original_book ) : if isinstance ( toc_item [ 1 ] , list ) : section_title , chapters = toc_item key = self . build_section_key ( section_title , count ) section_settings = json . loads ( settings . get ( key , '{}' ) ) show_in_outputs = section_settings . get ( 'show_in_outputs' , { } ) # means to remove the chapters that belongs to this section if not show_in_outputs . get ( output_name , True ) : self . chapters_to_remove += [ x [ 1 ] for x in chapters ] self . sections_to_remove . append ( key ) # increment if a section is found count += 1 # now let's loop over all the book items and exclude the ones are marked to be removed new_items = [ ] for i , item in enumerate ( list ( self . original_book . items ) ) : if item . get_name ( ) not in self . chapters_to_remove : new_items . append ( item ) self . original_book . items = new_items