mirror of
https://github.com/davidhalter/typeshed.git
synced 2025-12-06 12:14:27 +08:00
add zipfile for py2 (#345)
This commit is contained in:
committed by
Matthias Kramm
parent
932737d322
commit
8ef221c162
94
stdlib/2and3/zipfile.pyi
Normal file
94
stdlib/2and3/zipfile.pyi
Normal file
@@ -0,0 +1,94 @@
|
||||
# Stubs for zipfile
|
||||
|
||||
from typing import Callable, IO, Optional, Tuple, Type, Union
|
||||
from types import TracebackType
|
||||
import sys
|
||||
|
||||
|
||||
_SZI = Union[str, ZipInfo]
|
||||
_DT = Tuple[int, int, int, int, int, int]
|
||||
|
||||
|
||||
class BadZipFile(Exception): ...
|
||||
|
||||
if sys.version_info >= (3,):
|
||||
BadZipfile = BadZipFile
|
||||
|
||||
class LargeZipFile(Exception): ...
|
||||
|
||||
class ZipFile:
|
||||
debug = ... # type: int
|
||||
comment = ... # type: bytes
|
||||
def __init__(self, file: Union[str, IO[bytes]], mode: str = ..., compression: int = ...,
|
||||
allowZip64: bool = ...) -> None: ...
|
||||
def __enter__(self) -> ZipFile: ...
|
||||
def __exit__(self, exc_type: Optional[Type[BaseException]],
|
||||
exc_val: Optional[Exception],
|
||||
exc_tb: Optional[TracebackType]) -> bool: ...
|
||||
def close(self) -> None: ...
|
||||
def getinfo(self, name: str) -> None: ...
|
||||
def infolist(self) -> List[ZipInfo]: ...
|
||||
def namelist(self) -> List[str]: ...
|
||||
def open(self, name: _SZI, mode: str = ...,
|
||||
pwd: Optional[bytes] = ...) -> IO[bytes]: ...
|
||||
def extract(self, member: _SZI, path: Optional[_SZI] = ...,
|
||||
pwd: bytes = ...) -> str: ...
|
||||
def extractall(self, path: Optional[str] = ...,
|
||||
members: Optional[List[str]] = ...,
|
||||
pwd: Optional[bytes] = ...) -> None: ...
|
||||
def printdir(self) -> None: ...
|
||||
def setpassword(self, pwd: bytes) -> None: ...
|
||||
def read(self, name: _SZI, pwd: Optional[bytes] = ...) -> bytes: ...
|
||||
def testzip(self) -> Optional[str]: ...
|
||||
def write(self, filename: str, arcname: Optional[str] = ...,
|
||||
compress_type: Optional[int] = ...) -> None: ...
|
||||
if sys.version_info >= (3,):
|
||||
def writestr(self, zinfo_or_arcname: _SZI, data: Union[bytes, str],
|
||||
compress_type: Optional[int] = ...) -> None: ...
|
||||
else:
|
||||
def writestr(self, # type: ignore
|
||||
zinfo_or_arcname: _SZI, bytes: bytes,
|
||||
compress_type: Optional[int] = ...) -> None: ...
|
||||
|
||||
class PyZipFile(ZipFile):
|
||||
if sys.version_info >= (3,):
|
||||
def __init__(self, file: Union[str, IO[bytes]], mode: str = ...,
|
||||
compression: int = ..., allowZip64: bool = ...,
|
||||
opimize: int = ...) -> None: ...
|
||||
def writepy(self, pathname: str, basename: str = ...,
|
||||
filterfunc: Optional[Callable[[str], bool]] = ...) \
|
||||
-> None: ...
|
||||
else:
|
||||
def writepy(self, # type: ignore
|
||||
pathname: str, basename: str = ...) -> None: ...
|
||||
|
||||
class ZipInfo:
|
||||
filename = ... # type: str
|
||||
date_time = ... # type: _DT
|
||||
compress_type = ... # type: int
|
||||
comment = ... # type: bytes
|
||||
extra = ... # type: bytes
|
||||
create_system = ... # type: int
|
||||
create_version = ... # type: int
|
||||
extract_version = ... # type: int
|
||||
reserved = ... # type: int
|
||||
flag_bits = ... # type: int
|
||||
volume = ... # type: int
|
||||
internal_attr = ... # type: int
|
||||
external_attr = ... # type: int
|
||||
header_offset = ... # type: int
|
||||
CRC = ... # type: int
|
||||
compress_size = ... # type: int
|
||||
file_size = ... # type: int
|
||||
if sys.version_info < (3,):
|
||||
def __init__(self, filename: Optional[str] = ...,
|
||||
date_time: Optional[_DT] = ...) -> None: ...
|
||||
|
||||
|
||||
def is_zipfile(filename: Union[str, IO[bytes]]) -> bool: ...
|
||||
|
||||
ZIP_STORED = ... # type: int
|
||||
ZIP_DEFLATED = ... # type: int
|
||||
if sys.version_info >= (3, 3):
|
||||
ZIP_BZIP2 = ... # type: int
|
||||
ZIP_LZMA = ... # type: int
|
||||
@@ -1,29 +0,0 @@
|
||||
# TODO these are incomplete
|
||||
|
||||
from typing import List, Tuple, BinaryIO, Union
|
||||
|
||||
ZIP_STORED = 0
|
||||
ZIP_DEFLATED = 0
|
||||
|
||||
def is_zipfile(filename: Union[str, BinaryIO]) -> bool: ...
|
||||
|
||||
class ZipInfo:
|
||||
filename = ... # type: str
|
||||
date_time = ... # type: Tuple[int, int, int, int, int, int]
|
||||
compressed_size = 0
|
||||
file_size = 0
|
||||
|
||||
class ZipFile:
|
||||
def __init__(self, file: Union[str, BinaryIO], mode: str = ...,
|
||||
compression: int = ...,
|
||||
allowZip64: bool = ...) -> None: ...
|
||||
def close(self) -> None: ...
|
||||
def getinfo(name: str) -> ZipInfo: ...
|
||||
def infolist(self) -> List[ZipInfo]: ...
|
||||
def namelist(self) -> List[str]: ...
|
||||
def read(self, name: Union[str, ZipInfo], pwd: str = ...) -> bytes: ...
|
||||
def write(self, filename: str, arcname: str = ...,
|
||||
compress_type: int = ...) -> None: ...
|
||||
|
||||
def __enter__(self) -> 'ZipFile': ...
|
||||
def __exit__(self, type, value, traceback) -> bool: ...
|
||||
@@ -57,3 +57,6 @@
|
||||
2.7/tempfile.pyi
|
||||
2and3/argparse.pyi
|
||||
2and3/bz2.pyi
|
||||
|
||||
# fail because of conditionals pytype#28
|
||||
2and3/zipfile.pyi
|
||||
|
||||
Reference in New Issue
Block a user