| 1 |
import subprocess |
| 2 |
import sys |
| 3 |
import time |
| 4 |
from _typeshed import ReadableBuffer, SizedBuffer, StrOrBytesPath, Unused |
| 5 |
from builtins import list as _list |
| 6 |
from collections.abc import Callable, Generator |
| 7 |
from datetime import datetime |
| 8 |
from re import Pattern |
| 9 |
from socket import socket as _socket |
| 10 |
from ssl import SSLContext, SSLSocket |
| 11 |
from types import TracebackType |
| 12 |
from typing import IO, Any, Literal, SupportsAbs, SupportsInt, overload |
| 13 |
from typing_extensions import Self, TypeAlias, deprecated |
| 14 |
|
| 15 |
__all__ = ["IMAP4", "IMAP4_stream", "Internaldate2tuple", "Int2AP", "ParseFlags", "Time2Internaldate", "IMAP4_SSL"] |
| 16 |
|
| 17 |
|
| 18 |
|
| 19 |
_CommandResults: TypeAlias = tuple[str, list[Any]] |
| 20 |
|
| 21 |
_AnyResponseData: TypeAlias = list[None] | list[bytes | tuple[bytes, bytes]] |
| 22 |
|
| 23 |
Commands: dict[str, tuple[str, ...]] |
| 24 |
|
| 25 |
class IMAP4: |
| 26 |
class error(Exception): ... |
| 27 |
class abort(error): ... |
| 28 |
class readonly(abort): ... |
| 29 |
utf8_enabled: bool |
| 30 |
mustquote: Pattern[str] |
| 31 |
debug: int |
| 32 |
state: str |
| 33 |
literal: str | None |
| 34 |
tagged_commands: dict[bytes, _list[bytes] | None] |
| 35 |
untagged_responses: dict[str, _list[bytes | tuple[bytes, bytes]]] |
| 36 |
continuation_response: str |
| 37 |
is_readonly: bool |
| 38 |
tagnum: int |
| 39 |
tagpre: str |
| 40 |
tagre: Pattern[str] |
| 41 |
welcome: bytes |
| 42 |
capabilities: tuple[str, ...] |
| 43 |
PROTOCOL_VERSION: str |
| 44 |
def __init__(self, host: str = "", port: int = 143, timeout: float | None = None) -> None: ... |
| 45 |
def open(self, host: str = "", port: int = 143, timeout: float | None = None) -> None: ... |
| 46 |
if sys.version_info >= (3, 14): |
| 47 |
@property |
| 48 |
@deprecated("IMAP4.file is unsupported, can cause errors, and may be removed.") |
| 49 |
def file(self) -> IO[str] | IO[bytes]: ... |
| 50 |
else: |
| 51 |
file: IO[str] | IO[bytes] |
| 52 |
|
| 53 |
def __getattr__(self, attr: str) -> Any: ... |
| 54 |
host: str |
| 55 |
port: int |
| 56 |
sock: _socket |
| 57 |
def read(self, size: int) -> bytes: ... |
| 58 |
def readline(self) -> bytes: ... |
| 59 |
def send(self, data: ReadableBuffer) -> None: ... |
| 60 |
def shutdown(self) -> None: ... |
| 61 |
def socket(self) -> _socket: ... |
| 62 |
def recent(self) -> _CommandResults: ... |
| 63 |
def response(self, code: str) -> _CommandResults: ... |
| 64 |
def append( |
| 65 |
self, mailbox: str | None, flags: str | None, date_time: _TimeLike | None, message: ReadableBuffer |
| 66 |
) -> tuple[str, _list[bytes]]: ... |
| 67 |
def authenticate(self, mechanism: str, authobject: Callable[[bytes], bytes | None]) -> tuple[str, str]: ... |
| 68 |
def capability(self) -> _CommandResults: ... |
| 69 |
def check(self) -> _CommandResults: ... |
| 70 |
def close(self) -> _CommandResults: ... |
| 71 |
def copy(self, message_set: str, new_mailbox: str) -> _CommandResults: ... |
| 72 |
def create(self, mailbox: str) -> _CommandResults: ... |
| 73 |
def delete(self, mailbox: str) -> _CommandResults: ... |
| 74 |
def deleteacl(self, mailbox: str, who: str) -> _CommandResults: ... |
| 75 |
def enable(self, capability: str) -> _CommandResults: ... |
| 76 |
def __enter__(self) -> Self: ... |
| 77 |
def __exit__(self, t: type[BaseException] | None, v: BaseException | None, tb: TracebackType | None) -> None: ... |
| 78 |
def expunge(self) -> _CommandResults: ... |
| 79 |
def fetch(self, message_set: str, message_parts: str) -> tuple[str, _AnyResponseData]: ... |
| 80 |
def getacl(self, mailbox: str) -> _CommandResults: ... |
| 81 |
def getannotation(self, mailbox: str, entry: str, attribute: str) -> _CommandResults: ... |
| 82 |
def getquota(self, root: str) -> _CommandResults: ... |
| 83 |
def getquotaroot(self, mailbox: str) -> _CommandResults: ... |
| 84 |
if sys.version_info >= (3, 14): |
| 85 |
def idle(self, duration: float | None = None) -> Idler: ... |
| 86 |
|
| 87 |
def list(self, directory: str = '""', pattern: str = "*") -> tuple[str, _AnyResponseData]: ... |
| 88 |
def login(self, user: str, password: str) -> tuple[Literal["OK"], _list[bytes]]: ... |
| 89 |
def login_cram_md5(self, user: str, password: str) -> _CommandResults: ... |
| 90 |
def logout(self) -> tuple[str, _AnyResponseData]: ... |
| 91 |
def lsub(self, directory: str = '""', pattern: str = "*") -> _CommandResults: ... |
| 92 |
def myrights(self, mailbox: str) -> _CommandResults: ... |
| 93 |
def namespace(self) -> _CommandResults: ... |
| 94 |
def noop(self) -> tuple[str, _list[bytes]]: ... |
| 95 |
def partial(self, message_num: str, message_part: str, start: str, length: str) -> _CommandResults: ... |
| 96 |
def proxyauth(self, user: str) -> _CommandResults: ... |
| 97 |
def rename(self, oldmailbox: str, newmailbox: str) -> _CommandResults: ... |
| 98 |
def search(self, charset: str | None, *criteria: str) -> _CommandResults: ... |
| 99 |
def select(self, mailbox: str = "INBOX", readonly: bool = False) -> tuple[str, _list[bytes | None]]: ... |
| 100 |
def setacl(self, mailbox: str, who: str, what: str) -> _CommandResults: ... |
| 101 |
def setannotation(self, *args: str) -> _CommandResults: ... |
| 102 |
def setquota(self, root: str, limits: str) -> _CommandResults: ... |
| 103 |
def sort(self, sort_criteria: str, charset: str, *search_criteria: str) -> _CommandResults: ... |
| 104 |
def starttls(self, ssl_context: Any | None = None) -> tuple[Literal["OK"], _list[None]]: ... |
| 105 |
def status(self, mailbox: str, names: str) -> _CommandResults: ... |
| 106 |
def store(self, message_set: str, command: str, flags: str) -> _CommandResults: ... |
| 107 |
def subscribe(self, mailbox: str) -> _CommandResults: ... |
| 108 |
def thread(self, threading_algorithm: str, charset: str, *search_criteria: str) -> _CommandResults: ... |
| 109 |
def uid(self, command: str, *args: str) -> _CommandResults: ... |
| 110 |
def unsubscribe(self, mailbox: str) -> _CommandResults: ... |
| 111 |
def unselect(self) -> _CommandResults: ... |
| 112 |
def xatom(self, name: str, *args: str) -> _CommandResults: ... |
| 113 |
def print_log(self) -> None: ... |
| 114 |
|
| 115 |
if sys.version_info >= (3, 14): |
| 116 |
class Idler: |
| 117 |
def __init__(self, imap: IMAP4, duration: float | None = None) -> None: ... |
| 118 |
def __enter__(self) -> Self: ... |
| 119 |
def __exit__(self, exc_type: object, exc_val: Unused, exc_tb: Unused) -> Literal[False]: ... |
| 120 |
def __iter__(self) -> Self: ... |
| 121 |
def __next__(self) -> tuple[str, float | None]: ... |
| 122 |
def burst(self, interval: float = 0.1) -> Generator[tuple[str, float | None]]: ... |
| 123 |
|
| 124 |
class IMAP4_SSL(IMAP4): |
| 125 |
if sys.version_info >= (3, 12): |
| 126 |
def __init__( |
| 127 |
self, host: str = "", port: int = 993, *, ssl_context: SSLContext | None = None, timeout: float | None = None |
| 128 |
) -> None: ... |
| 129 |
else: |
| 130 |
@overload |
| 131 |
def __init__( |
| 132 |
self, |
| 133 |
host: str = "", |
| 134 |
port: int = 993, |
| 135 |
keyfile: None = None, |
| 136 |
certfile: None = None, |
| 137 |
ssl_context: SSLContext | None = None, |
| 138 |
timeout: float | None = None, |
| 139 |
) -> None: ... |
| 140 |
@overload |
| 141 |
@deprecated( |
| 142 |
"The `keyfile`, `certfile` parameters are deprecated since Python 3.6; " |
| 143 |
"removed in Python 3.12. Use `ssl_context` parameter instead." |
| 144 |
) |
| 145 |
def __init__( |
| 146 |
self, |
| 147 |
host: str = "", |
| 148 |
port: int = 993, |
| 149 |
keyfile: StrOrBytesPath | None = None, |
| 150 |
certfile: StrOrBytesPath | None = None, |
| 151 |
ssl_context: None = None, |
| 152 |
timeout: float | None = None, |
| 153 |
) -> None: ... |
| 154 |
keyfile: StrOrBytesPath | None |
| 155 |
certfile: StrOrBytesPath | None |
| 156 |
sslobj: SSLSocket |
| 157 |
if sys.version_info >= (3, 14): |
| 158 |
@property |
| 159 |
@deprecated("IMAP4_SSL.file is unsupported, can cause errors, and may be removed.") |
| 160 |
def file(self) -> IO[Any]: ... |
| 161 |
else: |
| 162 |
file: IO[Any] |
| 163 |
|
| 164 |
def open(self, host: str = "", port: int | None = 993, timeout: float | None = None) -> None: ... |
| 165 |
def ssl(self) -> SSLSocket: ... |
| 166 |
|
| 167 |
class IMAP4_stream(IMAP4): |
| 168 |
command: str |
| 169 |
def __init__(self, command: str) -> None: ... |
| 170 |
if sys.version_info >= (3, 14): |
| 171 |
@property |
| 172 |
@deprecated("IMAP4_stream.file is unsupported, can cause errors, and may be removed.") |
| 173 |
def file(self) -> IO[Any]: ... |
| 174 |
else: |
| 175 |
file: IO[Any] |
| 176 |
process: subprocess.Popen[bytes] |
| 177 |
writefile: IO[Any] |
| 178 |
readfile: IO[Any] |
| 179 |
def open(self, host: str | None = None, port: int | None = None, timeout: float | None = None) -> None: ... |
| 180 |
|
| 181 |
class _Authenticator: |
| 182 |
mech: Callable[[bytes], bytes | bytearray | memoryview | str | None] |
| 183 |
def __init__(self, mechinst: Callable[[bytes], bytes | bytearray | memoryview | str | None]) -> None: ... |
| 184 |
def process(self, data: str) -> str: ... |
| 185 |
def encode(self, inp: bytes | bytearray | memoryview) -> str: ... |
| 186 |
def decode(self, inp: str | SizedBuffer) -> bytes: ... |
| 187 |
|
| 188 |
def Internaldate2tuple(resp: ReadableBuffer) -> time.struct_time | None: ... |
| 189 |
def Int2AP(num: SupportsAbs[SupportsInt]) -> bytes: ... |
| 190 |
def ParseFlags(resp: ReadableBuffer) -> tuple[bytes, ...]: ... |
| 191 |
|
| 192 |
_TimeLike: TypeAlias = float | time.struct_time | time._TimeTuple | datetime | str |
| 193 |
|
| 194 |
def Time2Internaldate(date_time: _TimeLike) -> str: ... |