Format: application/octet-stream
⬇ Download File (5.8 KB)
   1  import os
   2  import sys
   3  from _typeshed import StrPath, SupportsRead, SupportsWrite
   4  from typing import (
   5      Any,
   6      AnyStr,
   7      Callable,
   8      Iterable,
   9      List,
  10      NamedTuple,
  11      Optional,
  12      Sequence,
  13      Set,
  14      Tuple,
  15      Type,
  16      TypeVar,
  17      Union,
  18      overload,
  19  )
  20  
  21  if sys.version_info >= (3, 6):
  22      _AnyStr = str
  23      _AnyPath = TypeVar("_AnyPath", str, os.PathLike[str])
  24      # Return value of some functions that may either return a path-like object that was passed in or
  25      # a string
  26      _PathReturn = Any
  27  elif sys.version_info >= (3,):
  28      _AnyStr = str
  29      _AnyPath = str
  30      _PathReturn = str
  31  else:
  32      _AnyStr = TypeVar("_AnyStr", str, unicode)
  33      _AnyPath = TypeVar("_AnyPath", str, unicode)
  34      _PathReturn = Type[None]
  35  
  36  if sys.version_info >= (3,):
  37      class Error(OSError): ...
  38      class SameFileError(Error): ...
  39      class SpecialFileError(OSError): ...
  40      class ExecError(OSError): ...
  41      class ReadError(OSError): ...
  42      class RegistryError(Exception): ...
  43  
  44  else:
  45      class Error(EnvironmentError): ...
  46      class SpecialFileError(EnvironmentError): ...
  47      class ExecError(EnvironmentError): ...
  48  
  49  def copyfileobj(fsrc: SupportsRead[AnyStr], fdst: SupportsWrite[AnyStr], length: int = ...) -> None: ...
  50  
  51  if sys.version_info >= (3,):
  52      def copyfile(src: StrPath, dst: _AnyPath, *, follow_symlinks: bool = ...) -> _AnyPath: ...
  53      def copymode(src: StrPath, dst: StrPath, *, follow_symlinks: bool = ...) -> None: ...
  54      def copystat(src: StrPath, dst: StrPath, *, follow_symlinks: bool = ...) -> None: ...
  55      def copy(src: StrPath, dst: StrPath, *, follow_symlinks: bool = ...) -> _PathReturn: ...
  56      def copy2(src: StrPath, dst: StrPath, *, follow_symlinks: bool = ...) -> _PathReturn: ...
  57  
  58  else:
  59      def copyfile(src: StrPath, dst: StrPath) -> None: ...
  60      def copymode(src: StrPath, dst: StrPath) -> None: ...
  61      def copystat(src: StrPath, dst: StrPath) -> None: ...
  62      def copy(src: StrPath, dst: StrPath) -> _PathReturn: ...
  63      def copy2(src: StrPath, dst: StrPath) -> _PathReturn: ...
  64  
  65  def ignore_patterns(*patterns: StrPath) -> Callable[[Any, List[_AnyStr]], Set[_AnyStr]]: ...
  66  
  67  if sys.version_info >= (3, 8):
  68      def copytree(
  69          src: StrPath,
  70          dst: StrPath,
  71          symlinks: bool = ...,
  72          ignore: Union[None, Callable[[str, List[str]], Iterable[str]], Callable[[StrPath, List[str]], Iterable[str]]] = ...,
  73          copy_function: Callable[[str, str], None] = ...,
  74          ignore_dangling_symlinks: bool = ...,
  75          dirs_exist_ok: bool = ...,
  76      ) -> _PathReturn: ...
  77  
  78  elif sys.version_info >= (3,):
  79      def copytree(
  80          src: StrPath,
  81          dst: StrPath,
  82          symlinks: bool = ...,
  83          ignore: Union[None, Callable[[str, List[str]], Iterable[str]], Callable[[StrPath, List[str]], Iterable[str]]] = ...,
  84          copy_function: Callable[[str, str], None] = ...,
  85          ignore_dangling_symlinks: bool = ...,
  86      ) -> _PathReturn: ...
  87  
  88  else:
  89      def copytree(
  90          src: AnyStr,
  91          dst: AnyStr,
  92          symlinks: bool = ...,
  93          ignore: Union[None, Callable[[AnyStr, List[AnyStr]], Iterable[AnyStr]]] = ...,
  94      ) -> _PathReturn: ...
  95  
  96  if sys.version_info >= (3,):
  97      def rmtree(
  98          path: Union[bytes, StrPath], ignore_errors: bool = ..., onerror: Optional[Callable[[Any, Any, Any], Any]] = ...
  99      ) -> None: ...
 100  
 101  else:
 102      def rmtree(
 103          path: _AnyPath, ignore_errors: bool = ..., onerror: Optional[Callable[[Any, _AnyPath, Any], Any]] = ...
 104      ) -> None: ...
 105  
 106  _CopyFn = Union[Callable[[str, str], None], Callable[[StrPath, StrPath], None]]
 107  
 108  if sys.version_info >= (3, 9):
 109      def move(src: StrPath, dst: StrPath, copy_function: _CopyFn = ...) -> _PathReturn: ...
 110  
 111  elif sys.version_info >= (3, 5):
 112      # See https://bugs.python.org/issue32689
 113      def move(src: str, dst: StrPath, copy_function: _CopyFn = ...) -> _PathReturn: ...
 114  
 115  else:
 116      def move(src: StrPath, dst: StrPath) -> _PathReturn: ...
 117  
 118  if sys.version_info >= (3,):
 119      class _ntuple_diskusage(NamedTuple):
 120          total: int
 121          used: int
 122          free: int
 123      def disk_usage(path: StrPath) -> _ntuple_diskusage: ...
 124      def chown(path: StrPath, user: Optional[Union[str, int]] = ..., group: Optional[Union[str, int]] = ...) -> None: ...
 125  
 126  if sys.version_info >= (3, 8):
 127      @overload
 128      def which(cmd: StrPath, mode: int = ..., path: Optional[StrPath] = ...) -> Optional[str]: ...
 129      @overload
 130      def which(cmd: bytes, mode: int = ..., path: Optional[StrPath] = ...) -> Optional[bytes]: ...
 131  
 132  elif sys.version_info >= (3,):
 133      def which(cmd: StrPath, mode: int = ..., path: Optional[StrPath] = ...) -> Optional[str]: ...
 134  
 135  def make_archive(
 136      base_name: _AnyStr,
 137      format: str,
 138      root_dir: Optional[StrPath] = ...,
 139      base_dir: Optional[StrPath] = ...,
 140      verbose: bool = ...,
 141      dry_run: bool = ...,
 142      owner: Optional[str] = ...,
 143      group: Optional[str] = ...,
 144      logger: Optional[Any] = ...,
 145  ) -> _AnyStr: ...
 146  def get_archive_formats() -> List[Tuple[str, str]]: ...
 147  def register_archive_format(
 148      name: str,
 149      function: Callable[..., Any],
 150      extra_args: Optional[Sequence[Union[Tuple[str, Any], List[Any]]]] = ...,
 151      description: str = ...,
 152  ) -> None: ...
 153  def unregister_archive_format(name: str) -> None: ...
 154  
 155  if sys.version_info >= (3,):
 156      if sys.version_info >= (3, 7):
 157          def unpack_archive(filename: StrPath, extract_dir: Optional[StrPath] = ..., format: Optional[str] = ...) -> None: ...
 158      else:
 159          # See http://bugs.python.org/issue30218
 160          def unpack_archive(filename: str, extract_dir: Optional[StrPath] = ..., format: Optional[str] = ...) -> None: ...
 161      def register_unpack_format(
 162          name: str, extensions: List[str], function: Any, extra_args: Sequence[Tuple[str, Any]] = ..., description: str = ...
 163      ) -> None: ...
 164      def unregister_unpack_format(name: str) -> None: ...
 165      def get_unpack_formats() -> List[Tuple[str, List[str], str]]: ...
 166      def get_terminal_size(fallback: Tuple[int, int] = ...) -> os.terminal_size: ...
 167