Delete a paragraph from a slide. Args: slide (SlidePage): The slide containing the paragraph. div_id (int): The ID of the division containing the paragraph. paragraph_id (int): The ID of the paragraph to delete. Raises: IndexError: If the paragraph is n
(slide: SlidePage, div_id: int, paragraph_id: int)
| 202 | |
| 203 | # api functions |
| 204 | def del_paragraph(slide: SlidePage, div_id: int, paragraph_id: int): |
| 205 | """ |
| 206 | Delete a paragraph from a slide. |
| 207 | |
| 208 | Args: |
| 209 | slide (SlidePage): The slide containing the paragraph. |
| 210 | div_id (int): The ID of the division containing the paragraph. |
| 211 | paragraph_id (int): The ID of the paragraph to delete. |
| 212 | |
| 213 | Raises: |
| 214 | IndexError: If the paragraph is not found. |
| 215 | """ |
| 216 | shape = element_index(slide, div_id) |
| 217 | assert ( |
| 218 | shape.text_frame.is_textframe |
| 219 | ), "The element does not have a text frame, please check the element id and type of element." |
| 220 | for para in shape.text_frame.paragraphs: |
| 221 | if para.idx == paragraph_id: |
| 222 | shape.text_frame.paragraphs.remove(para) |
| 223 | shape._closures["delete"].append( |
| 224 | Closure(partial(del_para, para.real_idx), para.real_idx) |
| 225 | ) |
| 226 | return |
| 227 | else: |
| 228 | raise IndexError( |
| 229 | f"Cannot find the paragraph {paragraph_id} of the element {div_id}," |
| 230 | "may refer to a non-existed paragraph or you haven't cloned enough paragraphs beforehand." |
| 231 | ) |
| 232 | |
| 233 | |
| 234 | def del_image(slide: SlidePage, figure_id: int): |
nothing calls this directly
no test coverage detected