Debian Codegraph @

jedi/third_party/typeshed/stdlib/ftplib.pyi

raw symbols SCIP
1 import sys
2 from _typeshed import StrOrBytesPath, SupportsRead, SupportsReadline
3 from collections.abc import Callable, Iterable, Iterator
4 from socket import socket
5 from ssl import SSLContext
6 from types import TracebackType
7 from typing import Any, Final, Literal, TextIO, overload
8 from typing_extensions import Self, deprecated
9
10 __all__ = ["FTP", "error_reply", "error_temp", "error_perm", "error_proto", "all_errors", "FTP_TLS"]
11
12 MSG_OOB: Final = 1
13 FTP_PORT: Final = 21
14 MAXLINE: Final = 8192
15 CRLF: Final = "\r\n"
16 B_CRLF: Final = b"\r\n"
17
18 class Error(Exception): ...
19 class error_reply(Error): ...
20 class error_temp(Error): ...
21 class error_perm(Error): ...
22 class error_proto(Error): ...
23
24 all_errors: tuple[type[Exception], ...]
25
26 class FTP:
27 debugging: int
28 host: str
29 port: int
30 maxline: int
31 sock: socket | None
32 welcome: str | None
33 passiveserver: int
34 timeout: float | None
35 af: int
36 lastresp: str
37 file: TextIO | None
38 encoding: str
39 def __enter__(self) -> Self: ...
40 def __exit__(
41 self, exc_type: type[BaseException] | None, exc_val: BaseException | None, exc_tb: TracebackType | None
42 ) -> None: ...
43 source_address: tuple[str, int] | None
44 def __init__(
45 self,
46 host: str = "",
47 user: str = "",
48 passwd: str = "",
49 acct: str = "",
50 timeout: float | None = ...,
51 source_address: tuple[str, int] | None = None,
52 *,
53 encoding: str = "utf-8",
54 ) -> None: ...
55 def connect(
56 self, host: str = "", port: int = 0, timeout: float = -999, source_address: tuple[str, int] | None = None
57 ) -> str: ...
58 def getwelcome(self) -> str: ...
59 def set_debuglevel(self, level: int) -> None: ...
60 def debug(self, level: int) -> None: ...
61 def set_pasv(self, val: bool | Literal[0, 1]) -> None: ...
62 def sanitize(self, s: str) -> str: ...
63 def putline(self, line: str) -> None: ...
64 def putcmd(self, line: str) -> None: ...
65 def getline(self) -> str: ...
66 def getmultiline(self) -> str: ...
67 def getresp(self) -> str: ...
68 def voidresp(self) -> str: ...
69 def abort(self) -> str: ...
70 def sendcmd(self, cmd: str) -> str: ...
71 def voidcmd(self, cmd: str) -> str: ...
72 def sendport(self, host: str, port: int) -> str: ...
73 def sendeprt(self, host: str, port: int) -> str: ...
74 def makeport(self) -> socket: ...
75 def makepasv(self) -> tuple[str, int]: ...
76 def login(self, user: str = "", passwd: str = "", acct: str = "") -> str: ...
77 # In practice, `rest` can actually be anything whose str() is an integer sequence, so to make it simple we allow integers
78 def ntransfercmd(self, cmd: str, rest: int | str | None = None) -> tuple[socket, int | None]: ...
79 def transfercmd(self, cmd: str, rest: int | str | None = None) -> socket: ...
80 def retrbinary(
81 self, cmd: str, callback: Callable[[bytes], object], blocksize: int = 8192, rest: int | str | None = None
82 ) -> str: ...
83 def storbinary(
84 self,
85 cmd: str,
86 fp: SupportsRead[bytes],
87 blocksize: int = 8192,
88 callback: Callable[[bytes], object] | None = None,
89 rest: int | str | None = None,
90 ) -> str: ...
91 def retrlines(self, cmd: str, callback: Callable[[str], object] | None = None) -> str: ...
92 def storlines(self, cmd: str, fp: SupportsReadline[bytes], callback: Callable[[bytes], object] | None = None) -> str: ...
93 def acct(self, password: str) -> str: ...
94 def nlst(self, *args: str) -> list[str]: ...
95 # Technically only the last arg can be a Callable but ...
96 def dir(self, *args: str | Callable[[str], object]) -> None: ...
97 def mlsd(self, path: str = "", facts: Iterable[str] = []) -> Iterator[tuple[str, dict[str, str]]]: ...
98 def rename(self, fromname: str, toname: str) -> str: ...
99 def delete(self, filename: str) -> str: ...
100 def cwd(self, dirname: str) -> str: ...
101 def size(self, filename: str) -> int | None: ...
102 def mkd(self, dirname: str) -> str: ...
103 def rmd(self, dirname: str) -> str: ...
104 def pwd(self) -> str: ...
105 def quit(self) -> str: ...
106 def close(self) -> None: ...
107
108 class FTP_TLS(FTP):
109 if sys.version_info >= (3, 12):
110 def __init__(
111 self,
112 host: str = "",
113 user: str = "",
114 passwd: str = "",
115 acct: str = "",
116 *,
117 context: SSLContext | None = None,
118 timeout: float | None = ...,
119 source_address: tuple[str, int] | None = None,
120 encoding: str = "utf-8",
121 ) -> None: ...
122 else:
123 @overload
124 def __init__(
125 self,
126 host: str = "",
127 user: str = "",
128 passwd: str = "",
129 acct: str = "",
130 keyfile: None = None,
131 certfile: None = None,
132 context: SSLContext | None = None,
133 timeout: float | None = ...,
134 source_address: tuple[str, int] | None = None,
135 *,
136 encoding: str = "utf-8",
137 ) -> None: ...
138 @overload
139 @deprecated(
140 "The `keyfile`, `certfile` parameters are deprecated since Python 3.6; "
141 "removed in Python 3.12. Use `context` parameter instead."
142 )
143 def __init__(
144 self,
145 host: str = "",
146 user: str = "",
147 passwd: str = "",
148 acct: str = "",
149 keyfile: StrOrBytesPath | None = None,
150 certfile: StrOrBytesPath | None = None,
151 context: None = None,
152 timeout: float | None = ...,
153 source_address: tuple[str, int] | None = None,
154 *,
155 encoding: str = "utf-8",
156 ) -> None: ...
157 ssl_version: int
158 keyfile: StrOrBytesPath | None
159 certfile: StrOrBytesPath | None
160 context: SSLContext
161 def login(self, user: str = "", passwd: str = "", acct: str = "", secure: bool = True) -> str: ...
162 def auth(self) -> str: ...
163 def prot_p(self) -> str: ...
164 def prot_c(self) -> str: ...
165 def ccc(self) -> str: ...
166
167 def parse150(resp: str) -> int | None: ... # undocumented
168 def parse227(resp: str) -> tuple[str, int]: ... # undocumented
169 def parse229(resp: str, peer: Any) -> tuple[str, int]: ... # undocumented
170 def parse257(resp: str) -> str: ... # undocumented
171 def ftpcp(
172 source: FTP, sourcename: str, target: FTP, targetname: str = "", type: Literal["A", "I"] = "I"
173 ) -> None: ... # undocumented