Format: application/octet-stream
⬇ Download File (7.1 KB)
   1  import io
   2  import sys
   3  from _typeshed import StrPath
   4  from types import TracebackType
   5  from typing import (
   6      IO,
   7      Any,
   8      Callable,
   9      Dict,
  10      Iterable,
  11      Iterator,
  12      List,
  13      Optional,
  14      Pattern,
  15      Protocol,
  16      Sequence,
  17      Text,
  18      Tuple,
  19      Type,
  20      Union,
  21  )
  22  
  23  _SZI = Union[Text, ZipInfo]
  24  _DT = Tuple[int, int, int, int, int, int]
  25  
  26  if sys.version_info >= (3,):
  27      class BadZipFile(Exception): ...
  28      BadZipfile = BadZipFile
  29  else:
  30      class BadZipfile(Exception): ...
  31  
  32  error = BadZipfile
  33  
  34  class LargeZipFile(Exception): ...
  35  
  36  class ZipExtFile(io.BufferedIOBase):
  37      MAX_N: int = ...
  38      MIN_READ_SIZE: int = ...
  39  
  40      if sys.version_info < (3, 6):
  41          PATTERN: Pattern[str] = ...
  42  
  43      if sys.version_info >= (3, 7):
  44          MAX_SEEK_READ: int = ...
  45  
  46      newlines: Optional[List[bytes]]
  47      mode: str
  48      name: str
  49      if sys.version_info >= (3, 7):
  50          def __init__(
  51              self, fileobj: IO[bytes], mode: str, zipinfo: ZipInfo, pwd: Optional[bytes] = ..., close_fileobj: bool = ...
  52          ) -> None: ...
  53      else:
  54          def __init__(
  55              self,
  56              fileobj: IO[bytes],
  57              mode: str,
  58              zipinfo: ZipInfo,
  59              decrypter: Optional[Callable[[Sequence[int]], bytes]] = ...,
  60              close_fileobj: bool = ...,
  61          ) -> None: ...
  62      def __repr__(self) -> str: ...
  63      def peek(self, n: int = ...) -> bytes: ...
  64      def read1(self, n: Optional[int]) -> bytes: ...  # type: ignore
  65  
  66  class _Writer(Protocol):
  67      def write(self, __s: str) -> Any: ...
  68  
  69  class ZipFile:
  70      filename: Optional[Text]
  71      debug: int
  72      comment: bytes
  73      filelist: List[ZipInfo]
  74      fp: Optional[IO[bytes]]
  75      NameToInfo: Dict[Text, ZipInfo]
  76      start_dir: int  # undocumented
  77      if sys.version_info >= (3, 8):
  78          def __init__(
  79              self,
  80              file: Union[StrPath, IO[bytes]],
  81              mode: str = ...,
  82              compression: int = ...,
  83              allowZip64: bool = ...,
  84              compresslevel: Optional[int] = ...,
  85              *,
  86              strict_timestamps: bool = ...,
  87          ) -> None: ...
  88      elif sys.version_info >= (3, 7):
  89          def __init__(
  90              self,
  91              file: Union[StrPath, IO[bytes]],
  92              mode: str = ...,
  93              compression: int = ...,
  94              allowZip64: bool = ...,
  95              compresslevel: Optional[int] = ...,
  96          ) -> None: ...
  97      else:
  98          def __init__(
  99              self, file: Union[StrPath, IO[bytes]], mode: Text = ..., compression: int = ..., allowZip64: bool = ...
 100          ) -> None: ...
 101      def __enter__(self) -> ZipFile: ...
 102      def __exit__(
 103          self, exc_type: Optional[Type[BaseException]], exc_val: Optional[BaseException], exc_tb: Optional[TracebackType]
 104      ) -> None: ...
 105      def close(self) -> None: ...
 106      def getinfo(self, name: Text) -> ZipInfo: ...
 107      def infolist(self) -> List[ZipInfo]: ...
 108      def namelist(self) -> List[Text]: ...
 109      def open(self, name: _SZI, mode: Text = ..., pwd: Optional[bytes] = ..., *, force_zip64: bool = ...) -> IO[bytes]: ...
 110      def extract(self, member: _SZI, path: Optional[StrPath] = ..., pwd: Optional[bytes] = ...) -> str: ...
 111      def extractall(
 112          self, path: Optional[StrPath] = ..., members: Optional[Iterable[Text]] = ..., pwd: Optional[bytes] = ...
 113      ) -> None: ...
 114      if sys.version_info >= (3,):
 115          def printdir(self, file: Optional[_Writer] = ...) -> None: ...
 116      else:
 117          def printdir(self) -> None: ...
 118      def setpassword(self, pwd: bytes) -> None: ...
 119      def read(self, name: _SZI, pwd: Optional[bytes] = ...) -> bytes: ...
 120      def testzip(self) -> Optional[str]: ...
 121      if sys.version_info >= (3, 7):
 122          def write(
 123              self,
 124              filename: StrPath,
 125              arcname: Optional[StrPath] = ...,
 126              compress_type: Optional[int] = ...,
 127              compresslevel: Optional[int] = ...,
 128          ) -> None: ...
 129      else:
 130          def write(self, filename: StrPath, arcname: Optional[StrPath] = ..., compress_type: Optional[int] = ...) -> None: ...
 131      if sys.version_info >= (3, 7):
 132          def writestr(
 133              self,
 134              zinfo_or_arcname: _SZI,
 135              data: Union[bytes, str],
 136              compress_type: Optional[int] = ...,
 137              compresslevel: Optional[int] = ...,
 138          ) -> None: ...
 139      elif sys.version_info >= (3,):
 140          def writestr(self, zinfo_or_arcname: _SZI, data: Union[bytes, str], compress_type: Optional[int] = ...) -> None: ...
 141      else:
 142          def writestr(self, zinfo_or_arcname: _SZI, bytes: bytes, compress_type: Optional[int] = ...) -> None: ...
 143  
 144  class PyZipFile(ZipFile):
 145      if sys.version_info >= (3,):
 146          def __init__(
 147              self,
 148              file: Union[str, IO[bytes]],
 149              mode: str = ...,
 150              compression: int = ...,
 151              allowZip64: bool = ...,
 152              optimize: int = ...,
 153          ) -> None: ...
 154          def writepy(self, pathname: str, basename: str = ..., filterfunc: Optional[Callable[[str], bool]] = ...) -> None: ...
 155      else:
 156          def writepy(self, pathname: Text, basename: Text = ...) -> None: ...
 157  
 158  class ZipInfo:
 159      filename: Text
 160      date_time: _DT
 161      compress_type: int
 162      comment: bytes
 163      extra: bytes
 164      create_system: int
 165      create_version: int
 166      extract_version: int
 167      reserved: int
 168      flag_bits: int
 169      volume: int
 170      internal_attr: int
 171      external_attr: int
 172      header_offset: int
 173      CRC: int
 174      compress_size: int
 175      file_size: int
 176      def __init__(self, filename: Optional[Text] = ..., date_time: Optional[_DT] = ...) -> None: ...
 177      if sys.version_info >= (3, 8):
 178          @classmethod
 179          def from_file(cls, filename: StrPath, arcname: Optional[StrPath] = ..., *, strict_timestamps: bool = ...) -> ZipInfo: ...
 180      elif sys.version_info >= (3, 6):
 181          @classmethod
 182          def from_file(cls, filename: StrPath, arcname: Optional[StrPath] = ...) -> ZipInfo: ...
 183      if sys.version_info >= (3, 6):
 184          def is_dir(self) -> bool: ...
 185      def FileHeader(self, zip64: Optional[bool] = ...) -> bytes: ...
 186  
 187  if sys.version_info >= (3, 8):
 188      class Path:
 189          @property
 190          def name(self) -> str: ...
 191          @property
 192          def parent(self) -> Path: ...  # undocumented
 193          def __init__(self, root: Union[ZipFile, StrPath, IO[bytes]], at: str = ...) -> None: ...
 194          def open(self, mode: str = ..., pwd: Optional[bytes] = ..., *, force_zip64: bool = ...) -> IO[bytes]: ...
 195          def iterdir(self) -> Iterator[Path]: ...
 196          def is_dir(self) -> bool: ...
 197          def is_file(self) -> bool: ...
 198          def exists(self) -> bool: ...
 199          def read_text(
 200              self,
 201              encoding: Optional[str] = ...,
 202              errors: Optional[str] = ...,
 203              newline: Optional[str] = ...,
 204              line_buffering: bool = ...,
 205              write_through: bool = ...,
 206          ) -> str: ...
 207          def read_bytes(self) -> bytes: ...
 208          def joinpath(self, add: StrPath) -> Path: ...  # undocumented
 209          def __truediv__(self, add: StrPath) -> Path: ...
 210  
 211  def is_zipfile(filename: Union[StrPath, IO[bytes]]) -> bool: ...
 212  
 213  ZIP_STORED: int
 214  ZIP_DEFLATED: int
 215  ZIP64_LIMIT: int
 216  ZIP_FILECOUNT_LIMIT: int
 217  ZIP_MAX_COMMENT: int
 218  if sys.version_info >= (3, 3):
 219      ZIP_BZIP2: int
 220      ZIP_LZMA: int
 221