| 1 | from typing import BinaryIO, Optional, Dict, Any, Sequence, overload, Literal |
| 2 | from ..typing import ImageResource |
| 3 | import enum |
| 4 | |
| 5 | EXAMPLE_IMAGES: Dict[str, str] |
| 6 | RETURN_BYTES = "<bytes>" |
| 7 | URI_BYTES = 1 |
| 8 | URI_FILE = 2 |
| 9 | URI_FILENAME = 3 |
| 10 | URI_ZIPPED = 4 |
| 11 | URI_HTTP = 5 |
| 12 | URI_FTP = 6 |
| 13 | |
| 14 | class IOMode(str, enum.Enum): |
| 15 | read = "r" |
| 16 | write = "w" |
| 17 | |
| 18 | class ImageMode(str, enum.Enum): |
| 19 | single_image = "i" |
| 20 | multi_image = "I" |
| 21 | single_volume = "v" |
| 22 | multi_volume = "V" |
| 23 | any_mode = "?" |
| 24 | |
| 25 | @enum.unique |
| 26 | class Mode(str, enum.Enum): |
| 27 | read_single_image = "ri" |
| 28 | read_multi_image = "rI" |
| 29 | read_single_volume = "rv" |
| 30 | read_multi_volume = "rV" |
| 31 | read_any = "r?" |
| 32 | write_single_image = "wi" |
| 33 | write_multi_image = "wI" |
| 34 | write_single_volume = "wv" |
| 35 | write_multi_volume = "wV" |
| 36 | write_any = "w?" |
| 37 | |
| 38 | @classmethod |
| 39 | def _missing_(cls, value: Any) -> Mode: ... |
| 40 | @property |
| 41 | def io_mode(self) -> IOMode: ... |
| 42 | @property |
| 43 | def image_mode(self) -> ImageMode: ... |
| 44 | |
| 45 | class InitializationError(Exception): ... |
| 46 | |
| 47 | class Request(object): |
| 48 | _uri_type: int |
| 49 | raw_uri: ImageResource |
| 50 | |
| 51 | @property |
| 52 | def filename(self) -> str: ... |
| 53 | @property |
| 54 | def extension(self) -> str: ... |
| 55 | @property |
| 56 | def format_hint(self) -> Optional[str]: ... |
| 57 | @format_hint.setter |
| 58 | def format_hint(self, format: str) -> None: ... |
| 59 | @property |
| 60 | def mode(self) -> Mode: ... |
| 61 | @property |
| 62 | def kwargs(self) -> Dict[str, Any]: ... |
| 63 | @property |
| 64 | def firstbytes(self) -> bytes: ... |
| 65 | def __init__( |
| 66 | self, |
| 67 | uri: ImageResource, |
| 68 | mode: str, |
| 69 | *, |
| 70 | extension: str = None, |
| 71 | format_hint: str = None, |
| 72 | **kwargs, |
| 73 | ) -> None: ... |
| 74 | def _parse_uri(self, uri: ImageResource) -> None: ... |
| 75 | def get_file(self) -> BinaryIO: ... |
| 76 | def get_local_filename(self) -> str: ... |
| 77 | def finish(self) -> None: ... |
| 78 | def get_result(self) -> Optional[bytes]: ... |
| 79 | def _read_first_bytes(self, N: int = 256) -> bytes: ... |
| 80 | |
| 81 | def read_n_bytes(f: BinaryIO, N: int) -> bytes: ... |
| 82 | |
| 83 | class SeekableFileObject: |
| 84 | def __init__(self, f: BinaryIO) -> None: ... |
| 85 | def read(self, n: int = None) -> bytes: ... |
| 86 | def tell(self) -> int: ... |
| 87 | def seek(self, i: int, mode: int = 0) -> int: ... |
| 88 | def close(self) -> None: ... |
| 89 | def isatty(self) -> bool: ... |
| 90 | def seekable(self) -> bool: ... |