|
| 1 | +from collections.abc import Iterator, Mapping |
| 2 | +from typing import IO, Self |
| 3 | + |
| 4 | +from pptx.opc.oxml import CT_Relationship, CT_Relationships |
| 5 | +from pptx.opc.packuri import PackURI |
| 6 | +from pptx.oxml.xmlchemy import BaseOxmlElement |
| 7 | +from pptx.package import Package |
| 8 | +from pptx.parts.presentation import PresentationPart |
| 9 | +from pptx.util import lazyproperty |
| 10 | + |
| 11 | +class _RelatableMixin: |
| 12 | + def part_related_by(self, reltype: str) -> Part: ... |
| 13 | + def relate_to(self, target: Part | str, reltype: str, is_external: bool = ...) -> str: ... |
| 14 | + def related_part(self, rId: str) -> Part: ... |
| 15 | + def target_ref(self, rId: str) -> str: ... |
| 16 | + |
| 17 | +class OpcPackage(_RelatableMixin): |
| 18 | + def __init__(self, pkg_file: str | IO[bytes]) -> None: ... |
| 19 | + @classmethod |
| 20 | + def open(cls, pkg_file: str | IO[bytes]) -> Self: ... |
| 21 | + def drop_rel(self, rId: str) -> None: ... |
| 22 | + def iter_parts(self) -> Iterator[Part]: ... |
| 23 | + def iter_rels(self) -> Iterator[_Relationship]: ... |
| 24 | + @property |
| 25 | + def main_document_part(self) -> PresentationPart: ... |
| 26 | + def next_partname(self, tmpl: str) -> PackURI: ... |
| 27 | + def save(self, pkg_file: str | IO[bytes]) -> None: ... |
| 28 | + |
| 29 | +class _PackageLoader: |
| 30 | + def __init__(self, pkg_file: str | IO[bytes], package: Package) -> None: ... |
| 31 | + @classmethod |
| 32 | + def load(cls, pkg_file: str | IO[bytes], package: Package) -> tuple[CT_Relationships, dict[PackURI, Part]]: ... |
| 33 | + |
| 34 | +class Part(_RelatableMixin): |
| 35 | + def __init__(self, partname: PackURI, content_type: str, package: Package, blob: bytes | None = ...) -> None: ... |
| 36 | + @classmethod |
| 37 | + def load(cls, partname: PackURI, content_type: str, package: Package, blob: bytes) -> Self: ... |
| 38 | + @property |
| 39 | + def blob(self) -> bytes: ... |
| 40 | + @blob.setter |
| 41 | + def blob(self, blob: bytes) -> None: ... |
| 42 | + @lazyproperty |
| 43 | + def content_type(self) -> str: ... |
| 44 | + def load_rels_from_xml(self, xml_rels: CT_Relationships, parts: dict[PackURI, Part]) -> None: ... |
| 45 | + @lazyproperty |
| 46 | + def package(self) -> Package: ... |
| 47 | + @property |
| 48 | + def partname(self) -> PackURI: ... |
| 49 | + @partname.setter |
| 50 | + def partname(self, partname: PackURI) -> None: ... |
| 51 | + @lazyproperty |
| 52 | + def rels(self) -> _Relationships: ... |
| 53 | + |
| 54 | +class XmlPart(Part): |
| 55 | + def __init__(self, partname: PackURI, content_type: str, package: Package, element: BaseOxmlElement) -> None: ... |
| 56 | + @classmethod |
| 57 | + def load(cls, partname: PackURI, content_type: str, package: Package, blob: bytes) -> Self: ... |
| 58 | + @property |
| 59 | + def blob(self) -> bytes: ... |
| 60 | + def drop_rel(self, rId: str) -> None: ... |
| 61 | + @property |
| 62 | + def part(self) -> Self: ... |
| 63 | + |
| 64 | +class PartFactory: |
| 65 | + part_type_for: dict[str, type[Part]] = ... |
| 66 | + def __new__(cls, partname: PackURI, content_type: str, package: Package, blob: bytes) -> Part: ... |
| 67 | + |
| 68 | +class _ContentTypeMap: |
| 69 | + def __init__(self, overrides: dict[str, str], defaults: dict[str, str]) -> None: ... |
| 70 | + def __getitem__(self, partname: PackURI) -> str: ... |
| 71 | + @classmethod |
| 72 | + def from_xml(cls, content_types_xml: bytes) -> _ContentTypeMap: ... |
| 73 | + |
| 74 | +class _Relationships(Mapping[str, "_Relationship"]): |
| 75 | + def __init__(self, base_uri: str) -> None: ... |
| 76 | + def __contains__(self, rId: object) -> bool: ... |
| 77 | + def __getitem__(self, rId: str) -> _Relationship: ... |
| 78 | + def __iter__(self) -> Iterator[str]: ... |
| 79 | + def __len__(self) -> int: ... |
| 80 | + def get_or_add(self, reltype: str, target_part: Part) -> str: ... |
| 81 | + def get_or_add_ext_rel(self, reltype: str, target_ref: str) -> str: ... |
| 82 | + def load_from_xml(self, base_uri: str, xml_rels: CT_Relationships, parts: dict[PackURI, Part]) -> None: ... |
| 83 | + def part_with_reltype(self, reltype: str) -> Part: ... |
| 84 | + def pop(self, rId: str) -> _Relationship: ... |
| 85 | + @property |
| 86 | + def xml(self) -> bytes: ... |
| 87 | + |
| 88 | +class _Relationship: |
| 89 | + def __init__(self, base_uri: str, rId: str, reltype: str, target_mode: str, target: Part | str) -> None: ... |
| 90 | + @classmethod |
| 91 | + def from_xml(cls, base_uri: str, rel: CT_Relationship, parts: dict[PackURI, Part]) -> _Relationship: ... |
| 92 | + @lazyproperty |
| 93 | + def is_external(self) -> bool: ... |
| 94 | + @lazyproperty |
| 95 | + def reltype(self) -> str: ... |
| 96 | + @lazyproperty |
| 97 | + def rId(self) -> str: ... |
| 98 | + @lazyproperty |
| 99 | + def target_part(self) -> Part: ... |
| 100 | + @lazyproperty |
| 101 | + def target_partname(self) -> PackURI: ... |
| 102 | + @lazyproperty |
| 103 | + def target_ref(self) -> str: ... |
0 commit comments