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

Method from_shape

utils/src/presentation.py:208–267  ·  view source on GitHub ↗

Create a ShapeElement from a BaseShape. Args: slide_idx (int): The index of the slide. shape_idx (int): The index of the shape. shape (BaseShape): The shape object. config (Config): The configuration object. slide_area (fl

(
        cls,
        slide_idx: int,
        shape_idx: int,
        shape: BaseShape,
        config: Config,
        slide_area: float,
        level: int = 0,
    )

Source from the content-addressed store, hash-verified

206
207 @classmethod
208 def from_shape(
209 cls,
210 slide_idx: int,
211 shape_idx: int,
212 shape: BaseShape,
213 config: Config,
214 slide_area: float,
215 level: int = 0,
216 ):
217 """
218 Create a ShapeElement from a BaseShape.
219
220 Args:
221 slide_idx (int): The index of the slide.
222 shape_idx (int): The index of the shape.
223 shape (BaseShape): The shape object.
224 config (Config): The configuration object.
225 slide_area (float): The area of the slide.
226 level (int): The indentation level.
227
228 Returns:
229 ShapeElement: The created ShapeElement.
230 """
231 if shape_idx > 100 and isinstance(shape, PPTXGroupShape):
232 raise ValueError(f"nested group shapes are not allowed")
233 line = None
234 if "line" in dir(shape) and shape.line._ln is not None:
235 line = {
236 "fill": extract_fill(shape.line),
237 "width": shape.line.width,
238 "dash_style": shape.line.dash_style,
239 }
240 fill = extract_fill(shape)
241 style = {
242 "shape_bounds": {
243 "width": shape.width,
244 "height": shape.height,
245 "left": shape.left,
246 "top": shape.top,
247 },
248 "shape_type": str(shape.shape_type).split("(")[0].lower(),
249 "rotation": shape.rotation,
250 "fill": fill,
251 "line": line,
252 }
253 text_frame = TextFrame(shape, level + 1)
254 obj = SHAPECAST.get(shape.shape_type, UnsupportedShape).from_shape(
255 slide_idx,
256 shape_idx,
257 shape,
258 style,
259 text_frame,
260 config,
261 slide_area,
262 level,
263 )
264 obj.xml = shape._element.xml
265 # ? for debug, mask to enable pickling

Callers

nothing calls this directly

Calls 3

extract_fillFunction · 0.90
TextFrameClass · 0.70
from_shapeMethod · 0.45

Tested by

no test coverage detected