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)
| 19 | |
| 20 | |
| 21 | def 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 | |
| 40 | def _default_pptx_path() -> str: |
searching dependent graphs…