1 # Stubs for ftplib (Python 2.7/3)
\r
3 from typing import Optional, BinaryIO, Tuple, TextIO, Iterable, Callable, List, Union, Iterator, Dict, Text, Type, TypeVar, Generic, Any
\r
4 from types import TracebackType
\r
5 from socket import socket
\r
6 from ssl import SSLContext
\r
9 _IntOrStr = Union[int, Text]
\r
11 MSG_OOB = ... # type: int
\r
12 FTP_PORT = ... # type: int
\r
13 MAXLINE = ... # type: int
\r
14 CRLF = ... # type: str
\r
15 if sys.version_info >= (3,):
\r
16 B_CRLF = ... # type: bytes
\r
18 class Error(Exception): ...
\r
19 class error_reply(Error): ...
\r
20 class error_temp(Error): ...
\r
21 class error_perm(Error): ...
\r
22 class error_proto(Error): ...
\r
24 all_errors = Tuple[Exception, ...]
\r
27 debugging = ... # type: int
\r
29 # Note: This is technically the type that's passed in as the host argument. But to make it easier in Python 2 we
\r
30 # accept Text but return str.
\r
31 host = ... # type: str
\r
33 port = ... # type: int
\r
34 maxline = ... # type: int
\r
35 sock = ... # type: Optional[socket]
\r
36 welcome = ... # type: Optional[str]
\r
37 passiveserver = ... # type: int
\r
38 timeout = ... # type: int
\r
39 af = ... # type: int
\r
40 lastresp = ... # type: str
\r
42 if sys.version_info >= (3,):
\r
43 file = ... # type: Optional[TextIO]
\r
44 encoding = ... # type: str
\r
45 def __enter__(self: _T) -> _T: ...
\r
46 def __exit__(self, exc_type: Optional[Type[BaseException]], exc_val: Optional[BaseException],
\r
47 exc_tb: Optional[TracebackType]) -> bool: ...
\r
49 file = ... # type: Optional[BinaryIO]
\r
51 if sys.version_info >= (3, 3):
\r
52 source_address = ... # type: Optional[Tuple[str, int]]
\r
53 def __init__(self, host: Text = ..., user: Text = ..., passwd: Text = ..., acct: Text = ...,
\r
54 timeout: float = ..., source_address: Optional[Tuple[str, int]] = ...) -> None: ...
\r
55 def connect(self, host: Text = ..., port: int = ..., timeout: float = ...,
\r
56 source_address: Optional[Tuple[str, int]] = ...) -> str: ...
\r
58 def __init__(self, host: Text = ..., user: Text = ..., passwd: Text = ..., acct: Text = ...,
\r
59 timeout: float = ...) -> None: ...
\r
60 def connect(self, host: Text = ..., port: int = ..., timeout: float = ...) -> str: ...
\r
62 def getwelcome(self) -> str: ...
\r
63 def set_debuglevel(self, level: int) -> None: ...
\r
64 def debug(self, level: int) -> None: ...
\r
65 def set_pasv(self, val: Union[bool, int]) -> None: ...
\r
66 def sanitize(self, s: Text) -> str: ...
\r
67 def putline(self, line: Text) -> None: ...
\r
68 def putcmd(self, line: Text) -> None: ...
\r
69 def getline(self) -> str: ...
\r
70 def getmultiline(self) -> str: ...
\r
71 def getresp(self) -> str: ...
\r
72 def voidresp(self) -> str: ...
\r
73 def abort(self) -> str: ...
\r
74 def sendcmd(self, cmd: Text) -> str: ...
\r
75 def voidcmd(self, cmd: Text) -> str: ...
\r
76 def sendport(self, host: Text, port: int) -> str: ...
\r
77 def sendeprt(self, host: Text, port: int) -> str: ...
\r
78 def makeport(self) -> socket: ...
\r
79 def makepasv(self) -> Tuple[str, int]: ...
\r
80 def login(self, user: Text = ..., passwd: Text = ..., acct: Text = ...) -> str: ...
\r
82 # In practice, `rest` rest can actually be anything whose str() is an integer sequence, so to make it simple we allow integers.
\r
83 def ntransfercmd(self, cmd: Text, rest: Optional[_IntOrStr] = ...) -> Tuple[socket, int]: ...
\r
84 def transfercmd(self, cmd: Text, rest: Optional[_IntOrStr] = ...) -> socket: ...
\r
85 def retrbinary(self, cmd: Text, callback: Callable[[bytes], Any], blocksize: int = ..., rest: Optional[_IntOrStr] = ...) -> str: ...
\r
86 def storbinary(self, cmd: Text, fp: BinaryIO, blocksize: int = ..., callback: Optional[Callable[[bytes], Any]] = ..., rest: Optional[_IntOrStr] = ...) -> str: ...
\r
88 def retrlines(self, cmd: Text, callback: Optional[Callable[[str], Any]] = ...) -> str: ...
\r
89 def storlines(self, cmd: Text, fp: BinaryIO, callback: Optional[Callable[[bytes], Any]] = ...) -> str: ...
\r
91 def acct(self, password: Text) -> str: ...
\r
92 def nlst(self, *args: Text) -> List[str]: ...
\r
94 # Technically only the last arg can be a Callable but ...
\r
95 def dir(self, *args: Union[str, Callable[[str], None]]) -> None: ...
\r
97 if sys.version_info >= (3, 3):
\r
98 def mlsd(self, path: Text = ..., facts: Iterable[str] = ...) -> Iterator[Tuple[str, Dict[str, str]]]: ...
\r
99 def rename(self, fromname: Text, toname: Text) -> str: ...
\r
100 def delete(self, filename: Text) -> str: ...
\r
101 def cwd(self, dirname: Text) -> str: ...
\r
102 def size(self, filename: Text) -> str: ...
\r
103 def mkd(self, dirname: Text) -> str: ...
\r
104 def rmd(self, dirname: Text) -> str: ...
\r
105 def pwd(self) -> str: ...
\r
106 def quit(self) -> str: ...
\r
107 def close(self) -> None: ...
\r
109 class FTP_TLS(FTP):
\r
110 def __init__(self, host: Text = ..., user: Text = ..., passwd: Text = ..., acct: Text = ...,
\r
111 keyfile: Optional[str] = ..., certfile: Optional[str] = ...,
\r
112 context: Optional[SSLContext] = ..., timeout: float = ...,
\r
113 source_address: Optional[Tuple[str, int]] = ...) -> None: ...
\r
115 ssl_version = ... # type: int
\r
116 keyfile = ... # type: Optional[str]
\r
117 certfile = ... # type: Optional[str]
\r
118 context = ... # type: SSLContext
\r
120 def login(self, user: Text = ..., passwd: Text = ..., acct: Text = ..., secure: bool = ...) -> str: ...
\r
121 def auth(self) -> str: ...
\r
122 def prot_p(self) -> str: ...
\r
123 def prot_c(self) -> str: ...
\r
125 if sys.version_info >= (3, 3):
\r
126 def ccc(self) -> str: ...
\r
128 if sys.version_info < (3,):
\r
130 def __init__(self, filename: Optional[Text] = ...) -> None: ...
\r
131 def get_hosts(self) -> List[str]: ...
\r
132 def get_account(self, host: Text) -> Tuple[Optional[str], Optional[str], Optional[str]]: ...
\r
133 def get_macros(self) -> List[str]: ...
\r
134 def get_macro(self, macro: Text) -> Tuple[str, ...]: ...
\r