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

Method from_file

utils/src/presentation.py:1192–1233  ·  view source on GitHub ↗

Parse a Presentation from a file.

(cls, file_path: str, config: Config)

Source from the content-addressed store, hash-verified

1190
1191 @classmethod
1192 def from_file(cls, file_path: str, config: Config):
1193 """
1194 Parse a Presentation from a file.
1195 """
1196 prs = PPTXPre(file_path)
1197 slide_width = prs.slide_width
1198 slide_height = prs.slide_height
1199 slides = []
1200 error_history = []
1201 slide_idx = 0
1202 layouts = [layout.name for layout in prs.slide_layouts]
1203 num_pages = len(prs.slides)
1204 for slide in prs.slides:
1205 if slide._element.get("show") == "0":
1206 continue # will not be printed to pdf
1207
1208 slide_idx += 1
1209 try:
1210 if slide.slide_layout.name not in layouts:
1211 raise ValueError(
1212 f"slide layout {slide.slide_layout.name} not found"
1213 )
1214 slides.append(
1215 SlidePage.from_slide(
1216 slide,
1217 slide_idx - len(error_history),
1218 slide_idx,
1219 slide_width.pt,
1220 slide_height.pt,
1221 config,
1222 )
1223 )
1224 except Exception as e:
1225 error_history.append((slide_idx, str(e)))
1226 if config.DEBUG:
1227 print(
1228 f"Warning in slide {slide_idx} of {file_path}: {traceback.format_exc()}"
1229 )
1230
1231 return cls(
1232 slides, error_history, slide_width, slide_height, file_path, num_pages
1233 )
1234
1235 def save(self, file_path, layout_only=False):
1236 """

Callers 12

presentation.pyFile · 0.45
ppt_validateFunction · 0.45
dataset_statFunction · 0.45
pres_scoreFunction · 0.45
eval_experimentFunction · 0.45
eval_baselineFunction · 0.45
rebuild_allFunction · 0.45
rebuild.pyFile · 0.45
prepare_ppt_folderFunction · 0.45
do_inductFunction · 0.45
do_generateFunction · 0.45
_split_audioMethod · 0.45

Calls 1

from_slideMethod · 0.45

Tested by

no test coverage detected