diff options
author | S. Solomon Darnell | 2025-03-28 21:52:21 -0500 |
---|---|---|
committer | S. Solomon Darnell | 2025-03-28 21:52:21 -0500 |
commit | 4a52a71956a8d46fcb7294ac71734504bb09bcc2 (patch) | |
tree | ee3dc5af3b6313e921cd920906356f5d4febc4ed /.venv/lib/python3.12/site-packages/PyPDF2/_protocols.py | |
parent | cc961e04ba734dd72309fb548a2f97d67d578813 (diff) | |
download | gn-ai-4a52a71956a8d46fcb7294ac71734504bb09bcc2.tar.gz |
Diffstat (limited to '.venv/lib/python3.12/site-packages/PyPDF2/_protocols.py')
-rw-r--r-- | .venv/lib/python3.12/site-packages/PyPDF2/_protocols.py | 62 |
1 files changed, 62 insertions, 0 deletions
diff --git a/.venv/lib/python3.12/site-packages/PyPDF2/_protocols.py b/.venv/lib/python3.12/site-packages/PyPDF2/_protocols.py new file mode 100644 index 00000000..89c80f9a --- /dev/null +++ b/.venv/lib/python3.12/site-packages/PyPDF2/_protocols.py @@ -0,0 +1,62 @@ +"""Helpers for working with PDF types.""" + +from pathlib import Path +from typing import IO, Any, Dict, List, Optional, Tuple, Union + +try: + # Python 3.8+: https://peps.python.org/pep-0586 + from typing import Protocol # type: ignore[attr-defined] +except ImportError: + from typing_extensions import Protocol # type: ignore[misc] + +from ._utils import StrByteType + + +class PdfObjectProtocol(Protocol): + indirect_reference: Any + + def clone( + self, + pdf_dest: Any, + force_duplicate: bool = False, + ignore_fields: Union[Tuple[str, ...], List[str], None] = (), + ) -> Any: + ... + + def _reference_clone(self, clone: Any, pdf_dest: Any) -> Any: + ... + + def get_object(self) -> Optional["PdfObjectProtocol"]: + ... + + +class PdfReaderProtocol(Protocol): # pragma: no cover + @property + def pdf_header(self) -> str: + ... + + @property + def strict(self) -> bool: + ... + + @property + def xref(self) -> Dict[int, Dict[int, Any]]: + ... + + @property + def pages(self) -> List[Any]: + ... + + def get_object(self, indirect_reference: Any) -> Optional[PdfObjectProtocol]: + ... + + +class PdfWriterProtocol(Protocol): # pragma: no cover + _objects: List[Any] + _id_translated: Dict[int, Dict[int, int]] + + def get_object(self, indirect_reference: Any) -> Optional[PdfObjectProtocol]: + ... + + def write(self, stream: Union[Path, StrByteType]) -> Tuple[bool, IO]: + ... |