mirror of
https://github.com/davidhalter/typeshed.git
synced 2025-12-28 22:56:55 +08:00
Pysftp Stubs (#5120)
This commit is contained in:
3
stubs/pysftp/METADATA.toml
Normal file
3
stubs/pysftp/METADATA.toml
Normal file
@@ -0,0 +1,3 @@
|
||||
version = "0.2"
|
||||
python2 = true
|
||||
requires = ["types-typing-extensions", "types-paramiko"]
|
||||
126
stubs/pysftp/pysftp/__init__.pyi
Normal file
126
stubs/pysftp/pysftp/__init__.pyi
Normal file
@@ -0,0 +1,126 @@
|
||||
from stat import S_IMODE as S_IMODE
|
||||
from types import TracebackType
|
||||
from typing import IO, Any, Callable, ContextManager, List, Optional, Sequence, Text, Tuple, Type, Union
|
||||
from typing_extensions import Literal
|
||||
|
||||
import paramiko
|
||||
from paramiko import AuthenticationException as AuthenticationException
|
||||
from pysftp.exceptions import (
|
||||
ConnectionException as ConnectionException,
|
||||
CredentialException as CredentialException,
|
||||
HostKeysException as HostKeysException,
|
||||
)
|
||||
from pysftp.helpers import (
|
||||
WTCallbacks as WTCallbacks,
|
||||
_PathCallback,
|
||||
cd as cd,
|
||||
known_hosts as known_hosts,
|
||||
path_advance as path_advance,
|
||||
path_retreat as path_retreat,
|
||||
reparent as reparent,
|
||||
st_mode_to_int as st_mode_to_int,
|
||||
walktree as walktree,
|
||||
)
|
||||
|
||||
class CnOpts:
|
||||
log: bool = ...
|
||||
compression: bool = ...
|
||||
ciphers: Optional[Sequence[str]] = ...
|
||||
hostkeys: paramiko.HostKeys = ...
|
||||
def __init__(self, knownhosts: Optional[str] = ...) -> None: ...
|
||||
def get_hostkey(self, host: str) -> paramiko.PKey: ...
|
||||
|
||||
_Callback = Callable[[int, int], Any]
|
||||
_Path = Union[Text, bytes]
|
||||
|
||||
class Connection:
|
||||
def __init__(
|
||||
self,
|
||||
host: str,
|
||||
username: Optional[str] = ...,
|
||||
private_key: Optional[Union[str, paramiko.RSAKey, paramiko.AgentKey]] = ...,
|
||||
password: Optional[str] = ...,
|
||||
port: int = ...,
|
||||
private_key_pass: Optional[str] = ...,
|
||||
ciphers: Optional[Sequence[str]] = ...,
|
||||
log: bool = ...,
|
||||
cnopts: Optional[CnOpts] = ...,
|
||||
default_path: Optional[_Path] = ...,
|
||||
) -> None: ...
|
||||
@property
|
||||
def pwd(self) -> str: ...
|
||||
def get(
|
||||
self, remotepath: _Path, localpath: Optional[_Path] = ..., callback: Optional[_Callback] = ..., preserve_mtime: bool = ...
|
||||
) -> None: ...
|
||||
def get_d(self, remotedir: _Path, localdir: _Path, preserve_mtime: bool = ...) -> None: ...
|
||||
def get_r(self, remotedir: _Path, localdir: _Path, preserve_mtime: bool = ...) -> None: ...
|
||||
def getfo(self, remotepath: _Path, flo: IO[bytes], callback: Optional[_Callback] = ...) -> int: ...
|
||||
def put(
|
||||
self,
|
||||
localpath: _Path,
|
||||
remotepath: Optional[_Path] = ...,
|
||||
callback: Optional[_Callback] = ...,
|
||||
confirm: bool = ...,
|
||||
preserve_mtime: bool = ...,
|
||||
) -> paramiko.SFTPAttributes: ...
|
||||
def put_d(self, localpath: _Path, remotepath: _Path, confirm: bool = ..., preserve_mtime: bool = ...) -> None: ...
|
||||
def put_r(self, localpath: _Path, remotepath: _Path, confirm: bool = ..., preserve_mtime: bool = ...) -> None: ...
|
||||
def putfo(
|
||||
self,
|
||||
flo: IO[bytes],
|
||||
remotepath: Optional[_Path] = ...,
|
||||
file_size: int = ...,
|
||||
callback: Optional[_Callback] = ...,
|
||||
confirm: bool = ...,
|
||||
) -> paramiko.SFTPAttributes: ...
|
||||
def execute(self, command: str) -> List[str]: ...
|
||||
def cd(self, remotepath: Optional[_Path] = ...) -> ContextManager[None]: ... # noqa: F811
|
||||
def chdir(self, remotepath: _Path) -> None: ...
|
||||
def cwd(self, remotepath: _Path) -> None: ...
|
||||
def chmod(self, remotepath: _Path, mode: int = ...) -> None: ...
|
||||
def chown(self, remotepath: _Path, uid: Optional[int] = ..., gid: Optional[int] = ...) -> None: ...
|
||||
def getcwd(self) -> str: ...
|
||||
def listdir(self, remotepath: _Path = ...) -> List[str]: ...
|
||||
def listdir_attr(self, remotepath: _Path = ...) -> List[paramiko.SFTPAttributes]: ...
|
||||
def mkdir(self, remotepath: _Path, mode: int = ...) -> None: ...
|
||||
def normalize(self, remotepath: _Path) -> str: ...
|
||||
def isdir(self, remotepath: _Path) -> bool: ...
|
||||
def isfile(self, remotepath: _Path) -> bool: ...
|
||||
def makedirs(self, remotedir: _Path, mode: int = ...) -> None: ...
|
||||
def readlink(self, remotelink: _Path) -> str: ...
|
||||
def remove(self, remotefile: _Path) -> None: ...
|
||||
def unlink(self, remotefile: _Path) -> None: ...
|
||||
def rmdir(self, remotepath: _Path) -> None: ...
|
||||
def rename(self, remote_src: _Path, remote_dest: _Path) -> None: ...
|
||||
def stat(self, remotepath: _Path) -> paramiko.SFTPAttributes: ...
|
||||
def lstat(self, remotepath: _Path) -> paramiko.SFTPAttributes: ...
|
||||
def close(self) -> None: ...
|
||||
def open(self, remote_file: _Path, mode: str = ..., bufsize: int = ...) -> paramiko.SFTPFile: ...
|
||||
def exists(self, remotepath: _Path) -> bool: ...
|
||||
def lexists(self, remotepath: _Path) -> bool: ...
|
||||
def symlink(self, remote_src: _Path, remote_dest: _Path) -> None: ...
|
||||
def truncate(self, remotepath: _Path, size: int) -> int: ...
|
||||
def walktree( # noqa: F811
|
||||
self, remotepath: _Path, fcallback: _PathCallback, dcallback: _PathCallback, ucallback: _PathCallback, recurse: bool = ...
|
||||
) -> None: ...
|
||||
@property
|
||||
def sftp_client(self) -> paramiko.SFTPClient: ...
|
||||
@property
|
||||
def active_ciphers(self) -> Tuple[str, str]: ...
|
||||
@property
|
||||
def active_compression(self) -> Tuple[str, str]: ...
|
||||
@property
|
||||
def security_options(self) -> paramiko.SecurityOptions: ...
|
||||
@property
|
||||
def logfile(self) -> Union[str, Literal[False]]: ...
|
||||
@property
|
||||
def timeout(self) -> Optional[float]: ...
|
||||
@timeout.setter
|
||||
def timeout(self, val: Optional[float]) -> None: ...
|
||||
@property
|
||||
def remote_server_key(self) -> paramiko.PKey: ...
|
||||
def __del__(self) -> None: ...
|
||||
def __enter__(self) -> "Connection": ...
|
||||
def __exit__(
|
||||
self, etype: Optional[Type[BaseException]], value: Optional[BaseException], traceback: Optional[TracebackType]
|
||||
) -> None: ...
|
||||
9
stubs/pysftp/pysftp/exceptions.pyi
Normal file
9
stubs/pysftp/pysftp/exceptions.pyi
Normal file
@@ -0,0 +1,9 @@
|
||||
class ConnectionException(Exception):
|
||||
message: str = ...
|
||||
def __init__(self, host: str, port: int) -> None: ...
|
||||
|
||||
class CredentialException(Exception):
|
||||
message: str = ...
|
||||
def __init__(self, message: str) -> None: ...
|
||||
|
||||
class HostKeysException(Exception): ...
|
||||
33
stubs/pysftp/pysftp/helpers.pyi
Normal file
33
stubs/pysftp/pysftp/helpers.pyi
Normal file
@@ -0,0 +1,33 @@
|
||||
from typing import Callable, ContextManager, Iterator, List, Optional
|
||||
|
||||
def known_hosts() -> str: ...
|
||||
def st_mode_to_int(val: int) -> int: ...
|
||||
|
||||
class WTCallbacks:
|
||||
def __init__(self) -> None: ...
|
||||
def file_cb(self, pathname: str) -> None: ...
|
||||
def dir_cb(self, pathname: str) -> None: ...
|
||||
def unk_cb(self, pathname: str) -> None: ...
|
||||
@property
|
||||
def flist(self) -> List[str]: ...
|
||||
@flist.setter
|
||||
def flist(self, val: List[str]) -> None: ...
|
||||
@property
|
||||
def dlist(self) -> List[str]: ...
|
||||
@dlist.setter
|
||||
def dlist(self, val: List[str]) -> None: ...
|
||||
@property
|
||||
def ulist(self) -> List[str]: ...
|
||||
@ulist.setter
|
||||
def ulist(self, val: List[str]) -> None: ...
|
||||
|
||||
def path_advance(thepath: str, sep: str = ...) -> Iterator[str]: ...
|
||||
def path_retreat(thepath: str, sep: str = ...) -> Iterator[str]: ...
|
||||
def reparent(newparent: str, oldpath: str) -> str: ...
|
||||
|
||||
_PathCallback = Callable[[str], None]
|
||||
|
||||
def walktree(
|
||||
localpath: str, fcallback: _PathCallback, dcallback: _PathCallback, ucallback: _PathCallback, recurse: bool = ...
|
||||
) -> None: ...
|
||||
def cd(localpath: Optional[str] = ...) -> ContextManager[None]: ...
|
||||
Reference in New Issue
Block a user