Merge tarfile (#467)

This commit is contained in:
Valérian Rousset
2016-09-03 17:40:45 +02:00
committed by Guido van Rossum
parent 708fd960da
commit 1d5b35b2a5
4 changed files with 179 additions and 272 deletions

View File

@@ -1,239 +0,0 @@
# Stubs for tarfile (Python 2)
#
# NOTE: This dynamically typed stub was automatically generated by stubgen.
from typing import Any
class TarError(Exception): ...
class ExtractError(TarError): ...
class ReadError(TarError): ...
class CompressionError(TarError): ...
class StreamError(TarError): ...
class HeaderError(TarError): ...
class EmptyHeaderError(HeaderError): ...
class TruncatedHeaderError(HeaderError): ...
class EOFHeaderError(HeaderError): ...
class InvalidHeaderError(HeaderError): ...
class SubsequentHeaderError(HeaderError): ...
class _LowLevelFile:
fd = ... # type: Any
def __init__(self, name, mode) -> None: ...
def close(self): ...
def read(self, size): ...
def write(self, s): ...
class _Stream:
name = ... # type: Any
mode = ... # type: Any
comptype = ... # type: Any
fileobj = ... # type: Any
bufsize = ... # type: Any
buf = ... # type: Any
pos = ... # type: Any
closed = ... # type: Any
zlib = ... # type: Any
crc = ... # type: Any
dbuf = ... # type: Any
cmp = ... # type: Any
def __init__(self, name, mode, comptype, fileobj, bufsize) -> None: ...
def __del__(self): ...
def write(self, s): ...
def close(self): ...
def tell(self): ...
def seek(self, pos=...): ...
def read(self, size=...): ...
class _StreamProxy:
fileobj = ... # type: Any
buf = ... # type: Any
def __init__(self, fileobj) -> None: ...
def read(self, size): ...
def getcomptype(self): ...
def close(self): ...
class _BZ2Proxy:
blocksize = ... # type: Any
fileobj = ... # type: Any
mode = ... # type: Any
name = ... # type: Any
def __init__(self, fileobj, mode) -> None: ...
pos = ... # type: Any
bz2obj = ... # type: Any
buf = ... # type: Any
def init(self): ...
def read(self, size): ...
def seek(self, pos): ...
def tell(self): ...
def write(self, data): ...
def close(self): ...
class _FileInFile:
fileobj = ... # type: Any
offset = ... # type: Any
size = ... # type: Any
sparse = ... # type: Any
position = ... # type: Any
def __init__(self, fileobj, offset, size, sparse=...) -> None: ...
def tell(self): ...
def seek(self, position): ...
def read(self, size=...): ...
def readnormal(self, size): ...
def readsparse(self, size): ...
def readsparsesection(self, size): ...
class ExFileObject:
blocksize = ... # type: Any
fileobj = ... # type: Any
name = ... # type: Any
mode = ... # type: Any
closed = ... # type: Any
size = ... # type: Any
position = ... # type: Any
buffer = ... # type: Any
def __init__(self, tarfile, tarinfo) -> None: ...
def read(self, size=...): ...
def readline(self, size=...): ...
def readlines(self): ...
def tell(self): ...
def seek(self, pos, whence=...): ...
def close(self): ...
def __iter__(self): ...
class TarInfo:
name = ... # type: Any
mode = ... # type: Any
uid = ... # type: Any
gid = ... # type: Any
size = ... # type: Any
mtime = ... # type: Any
chksum = ... # type: Any
type = ... # type: Any
linkname = ... # type: Any
uname = ... # type: Any
gname = ... # type: Any
devmajor = ... # type: Any
devminor = ... # type: Any
offset = ... # type: Any
offset_data = ... # type: Any
pax_headers = ... # type: Any
def __init__(self, name=...) -> None: ...
path = ... # type: Any
linkpath = ... # type: Any
def get_info(self, encoding, errors): ...
def tobuf(self, format=..., encoding=..., errors=...): ...
def create_ustar_header(self, info): ...
def create_gnu_header(self, info): ...
def create_pax_header(self, info, encoding, errors): ...
@classmethod
def create_pax_global_header(cls, pax_headers): ...
@classmethod
def frombuf(cls, buf): ...
@classmethod
def fromtarfile(cls, tarfile): ...
def isreg(self): ...
def isfile(self): ...
def isdir(self): ...
def issym(self): ...
def islnk(self): ...
def ischr(self): ...
def isblk(self): ...
def isfifo(self): ...
def issparse(self): ...
def isdev(self): ...
class TarFile:
debug = ... # type: Any
dereference = ... # type: Any
ignore_zeros = ... # type: Any
errorlevel = ... # type: Any
format = ... # type: Any
encoding = ... # type: Any
errors = ... # type: Any
tarinfo = ... # type: Any
fileobject = ... # type: Any
mode = ... # type: Any
name = ... # type: Any
fileobj = ... # type: Any
pax_headers = ... # type: Any
closed = ... # type: Any
members = ... # type: Any
offset = ... # type: Any
inodes = ... # type: Any
firstmember = ... # type: Any
def __init__(self, name=..., mode=..., fileobj=..., format=..., tarinfo=..., dereference=..., ignore_zeros=..., encoding=..., errors=..., pax_headers=..., debug=..., errorlevel=...) -> None: ...
posix = ... # type: Any
@classmethod
def open(cls, name=..., mode=..., fileobj=..., bufsize=..., **kwargs): ...
@classmethod
def taropen(cls, name, mode=..., fileobj=..., **kwargs): ...
@classmethod
def gzopen(cls, name, mode=..., fileobj=..., compresslevel=..., **kwargs): ...
@classmethod
def bz2open(cls, name, mode=..., fileobj=..., compresslevel=..., **kwargs): ...
OPEN_METH = ... # type: Any
def close(self): ...
def getmember(self, name): ...
def getmembers(self): ...
def getnames(self): ...
def gettarinfo(self, name=..., arcname=..., fileobj=...): ...
def list(self, verbose=...): ...
def add(self, name, arcname=..., recursive=..., exclude=..., filter=...): ...
def addfile(self, tarinfo, fileobj=...): ...
def extractall(self, path=..., members=...): ...
def extract(self, member, path=...): ...
def extractfile(self, member): ...
def makedir(self, tarinfo, targetpath): ...
def makefile(self, tarinfo, targetpath): ...
def makeunknown(self, tarinfo, targetpath): ...
def makefifo(self, tarinfo, targetpath): ...
def makedev(self, tarinfo, targetpath): ...
def makelink(self, tarinfo, targetpath): ...
def chown(self, tarinfo, targetpath): ...
def chmod(self, tarinfo, targetpath): ...
def utime(self, tarinfo, targetpath): ...
def next(self): ...
def __iter__(self): ...
def __enter__(self): ...
def __exit__(self, type, value, traceback): ...
class TarIter:
tarfile = ... # type: Any
index = ... # type: Any
def __init__(self, tarfile) -> None: ...
def __iter__(self): ...
def next(self): ...
class _section:
offset = ... # type: Any
size = ... # type: Any
def __init__(self, offset, size) -> None: ...
def __contains__(self, offset): ...
class _data(_section):
realpos = ... # type: Any
def __init__(self, offset, size, realpos) -> None: ...
class _hole(_section): ...
class _ringbuffer(list):
idx = ... # type: Any
def __init__(self) -> None: ...
def find(self, offset): ...
class TarFileCompat:
tarfile = ... # type: Any
def __init__(self, file, mode=..., compression=...) -> None: ...
def namelist(self): ...
def infolist(self): ...
def printdir(self): ...
def testzip(self): ...
def getinfo(self, name): ...
def read(self, name): ...
def write(self, filename, arcname=..., compress_type=...): ...
def writestr(self, zinfo, bytes): ...
def close(self): ...
def is_tarfile(name): ...
open = TarFile.open

178
stdlib/2and3/tarfile.pyi Normal file
View File

@@ -0,0 +1,178 @@
## Stubs for tarfile
from typing import (
Callable, IO, Iterator, List, Mapping, Optional, Type,
Union,
)
import sys
from types import TracebackType
ENCODING = ... # type: str
USTAR_FORMAT = ... # type: int
GNU_FORMAT = ... # type: int
PAX_FORMAT = ... # type: int
DEFAULT_FORMAT = ... # type: int
REGTYPE = ... # type: bytes
AREGTYPE = ... # type: bytes
LNKTYPE = ... # type: bytes
SYMTYPE = ... # type: bytes
DIRTYPE = ... # type: bytes
FIFOTYPE = ... # type: bytes
CONTTYPE = ... # type: bytes
CHRTYPE = ... # type: bytes
BLKTYPE = ... # type: bytes
GNUTYPE_SPARSE = ... # type: bytes
if sys.version_info < (3,):
TAR_PLAIN = ... # type: int
TAR_GZIPPED = ... # type: int
def open(name: Optional[str] = ..., mode: str = ...,
fileobj: Optional[IO[bytes]] = ..., bufsize: int = ...,
*, format: Optional[int] = ..., tarinfo: Optional[TarInfo] = ...,
dereference: Optional[bool] = ...,
ignore_zeros: Optional[bool] = ...,
encoding: Optional[str] = ..., errors: str = ...,
pax_headers: Optional[Mapping[str, str]] = ...,
debug: Optional[int] = ...,
errorlevel: Optional[int] = ...) -> TarFile: ...
class TarFile:
name = ... # type: Optional[str]
mode = ... # type: str
fileobj = ... # type: Optional[IO[bytes]]
format = ... # type: Optional[int]
tarinfo = ... # type: Optional[TarInfo]
dereference = ... # type: Optional[bool]
ignore_zeros = ... # type: Optional[bool]
encoding = ... # type: Optional[str]
errors = ... # type: str
pax_headers = ... # type: Optional[Mapping[str, str]]
debug = ... # type: Optional[int]
errorlevel = ... # type: Optional[int]
if sys.version_info < (3,):
posix = ... # type: bool
def __init__(self, name: Optional[str] = ..., mode: str = ...,
fileobj: Optional[IO[bytes]] = ...,
format: Optional[int] = ..., tarinfo: Optional[TarInfo] = ...,
dereference: Optional[bool] = ...,
ignore_zeros: Optional[bool] = ...,
encoding: Optional[str] = ..., errors: str = ...,
pax_headers: Optional[Mapping[str, str]] = ...,
debug: Optional[int] = ...,
errorlevel: Optional[int] = ...) -> None: ...
def __enter__(self) -> TarFile: ...
def __exit__(self,
exc_type: Optional[Type[BaseException]],
exc_val: Optional[Exception],
exc_tb: Optional[TracebackType]) -> bool: ...
def __iter__(self) -> Iterator[TarInfo]: ...
@classmethod
def open(cls, name: Optional[str] = ..., mode: str = ...,
fileobj: Optional[IO[bytes]] = ..., bufsize: int = ...,
*, format: Optional[int] = ..., tarinfo: Optional[TarInfo] = ...,
dereference: Optional[bool] = ...,
ignore_zeros: Optional[bool] = ...,
encoding: Optional[str] = ..., errors: str = ...,
pax_headers: Optional[Mapping[str, str]] = ...,
debug: Optional[int] = ...,
errorlevel: Optional[int] = ...) -> TarFile: ...
def getmember(self, name: str) -> TarInfo: ...
def getmembers(self) -> List[TarInfo]: ...
def getnames(self) -> List[str]: ...
if sys.version_info >= (3, 5):
def list(self, verbose: bool = ...,
*, members: Optional[List[TarInfo]] = ...) -> None: ...
else:
def list(self, verbose: bool = ...) -> None: ...
def next(self) -> Optional[TarInfo]: ...
if sys.version_info >= (3, 5):
def extractall(self, path: str = ...,
members: Optional[List[TarInfo]] = ...,
*, numeric_owner: bool = ...) -> None: ...
else:
def extractall(self, path: str = ...,
members: Optional[List[TarInfo]] = ...) -> None: ...
if sys.version_info >= (3, 5):
def extract(self, member: Union[str, TarInfo], path: str = ...,
set_attrs: bool = ...,
*, numeric_owner: bool = ...) -> None: ...
elif sys.version_info >= (3,):
def extract(self, member: Union[str, TarInfo], path: str = ...,
set_attrs: bool = ...) -> None: ...
else:
def extract(self, member: Union[str, TarInfo],
path: str = ...) -> None: ...
def extractfile(self,
member: Union[str, TarInfo]) -> Optional[IO[bytes]]: ...
if sys.version_info >= (3,):
def add(self, name: str, arcname: Optional[str] = ...,
recursive: bool = ...,
exclude: Optional[Callable[[str], bool]] = ..., *,
filter: Optional[Callable[[TarInfo], Optional[TarInfo]]] = ...) -> None: ...
else:
def add(self, name: str, arcname: Optional[str] = ...,
recursive: bool = ...,
exclude: Optional[Callable[[str], bool]] = ...,
filter: Optional[Callable[[TarInfo], Optional[TarInfo]]] = ...) -> None: ...
def addfile(self, tarinfo: TarInfo,
fileobj: Optional[IO[bytes]] = ...) -> None: ...
def gettarinfo(self, name: Optional[str] = ...,
arcname: Optional[str] = ...,
fileobj: Optional[IO[bytes]] = ...) -> TarInfo: ...
def close(self) -> None: ...
def is_tarfile(name: str) -> bool: ...
if sys.version_info < (3,):
class TarFileCompat:
def __init__(self, filename: str, mode: str = ...,
compression: int = ...) -> None: ...
class TarError(Exception): ...
class ReadError(TarError): ...
class CompressionError(TarError): ...
class StreamError(TarError): ...
class ExtractError(TarError): ...
class HeaderError(TarError): ...
class TarInfo:
name = ... # type: str
size = ... # type: int
mtime = ... # type: int
mode = ... # type: int
type = ... # type: bytes
linkname = ... # type: str
uid = ... # type: int
gid = ... # type: int
uname = ... # type: str
gname = ... # type: str
pax_headers = ... # type: Mapping[str, str]
def __init__(self, name: str = ...) -> None: ...
if sys.version_info >= (3,):
@classmethod
def frombuf(cls, buf: bytes, encoding: str, errors: str) -> TarInfo: ...
else:
@classmethod
def frombuf(cls, buf: bytes) -> TarInfo: ...
@classmethod
def fromtarfile(cls, tarfile: TarFile) -> TarInfo: ...
def tobuf(self, format: Optional[int] = ...,
encoding: Optional[str] = ..., errors: str = ...) -> bytes: ...
def isfile(self) -> bool: ...
def isreg(self) -> bool: ...
def isdir(self) -> bool: ...
def issym(self) -> bool: ...
def islnk(self) -> bool: ...
def ischr(self) -> bool: ...
def isblk(self) -> bool: ...
def isfifo(self) -> bool: ...
def isdev(self) -> bool: ...

View File

@@ -1,33 +0,0 @@
# TODO these are incomplete
from typing import Any, List, overload, Callable
class TarError(Exception): ...
class TarInfo:
name = ... # type: str
size = 0
uid = 0
gid = 0
class TarFile:
def getmember(self, name: str) -> TarInfo: ...
def getmembers(self) -> List[TarInfo]: ...
def getnames(self) -> List[str]: ...
def extractall(self, path: str = ...,
members: List[TarInfo] = ...) -> None: ...
@overload
def extract(self, member: str, path: str = ...,
set_attrs: bool = ...) -> None: ...
@overload
def extract(self, member: TarInfo, path: str = ...,
set_attrs: bool = ...) -> None: ...
def add(self, name: str, arcname: str = ..., recursive: bool = ...,
exclude: Callable[[str], bool] = ..., *,
filter: 'Callable[[TarFile], TarFile]' = ...) -> None: ...
def close(self) -> None: ...
def open(name: str = ..., mode: str = ..., fileobj: Any = ..., bufsize: int = ...,
**kwargs) -> TarFile: ...