MCPcopy Create free account
hub / github.com/scanny/python-pptx / Presentation

Function Presentation

src/pptx/api.py:21–37  ·  view source on GitHub ↗

Return a |Presentation| object loaded from *pptx*, where *pptx* can be either a path to a ``.pptx`` file (a string) or a file-like object. If *pptx* is missing or ``None``, the built-in default presentation "template" is loaded.

(pptx: str | IO[bytes] | None = None)

Source from the content-addressed store, hash-verified

19
20
21def Presentation(pptx: str | IO[bytes] | None = None) -> presentation.Presentation:
22 """
23 Return a |Presentation| object loaded from *pptx*, where *pptx* can be
24 either a path to a ``.pptx`` file (a string) or a file-like object. If
25 *pptx* is missing or ``None``, the built-in default presentation
26 "template" is loaded.
27 """
28 if pptx is None:
29 pptx = _default_pptx_path()
30
31 presentation_part = Package.open(pptx).main_document_part
32
33 if not _is_pptx_package(presentation_part):
34 tmpl = "file '%s' is not a PowerPoint file, content type is '%s'"
35 raise ValueError(tmpl % (pptx, presentation_part.content_type))
36
37 return presentation_part.presentation
38
39
40def _default_pptx_path() -> str:

Calls 3

_default_pptx_pathFunction · 0.85
_is_pptx_packageFunction · 0.85
openMethod · 0.45

Used in the wild real call sites across dependent graphs

searching dependent graphs…