MCPcopy Create free account
hub / github.com/Paper2Poster/Paper2Poster / element_index

Function element_index

utils/src/apis.py:159–176  ·  view source on GitHub ↗

Find the an element in a slide. Args: slide (SlidePage): The slide element_id (int): The ID of the element. Returns: ShapeElement: The shape corresponding to the element ID. Raises: IndexError: If the element is not found.

(slide: SlidePage, element_id: int)

Source from the content-addressed store, hash-verified

157
158# supporting functions
159def element_index(slide: SlidePage, element_id: int) -> ShapeElement:
160 """
161 Find the an element in a slide.
162
163 Args:
164 slide (SlidePage): The slide
165 element_id (int): The ID of the element.
166
167 Returns:
168 ShapeElement: The shape corresponding to the element ID.
169
170 Raises:
171 IndexError: If the element is not found.
172 """
173 for shape in slide:
174 if shape.shape_idx == element_id:
175 return shape
176 raise IndexError(f"Cannot find element {element_id}, is it deleted or not exist?")
177
178
179def replace_para(paragraph_id: int, new_text: str, shape: BaseShape):

Callers 5

del_paragraphFunction · 0.70
del_imageFunction · 0.70
replace_paragraphFunction · 0.70
replace_imageFunction · 0.70
clone_paragraphFunction · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected