Format: application/octet-stream
1 import io
2 from _typeshed import AnyPath, ReadableBuffer
3 from typing import IO, Any, Mapping, Optional, Sequence, TextIO, TypeVar, Union, overload
4 from typing_extensions import Literal
5
6 _OpenBinaryWritingMode = Literal["w", "wb", "x", "xb", "a", "ab"]
7 _OpenTextWritingMode = Literal["wt", "xt", "at"]
8
9 _PathOrFile = Union[AnyPath, IO[bytes]]
10
11 _FilterChain = Sequence[Mapping[str, Any]]
12 _T = TypeVar("_T")
13
14 FORMAT_AUTO: int
15 FORMAT_XZ: int
16 FORMAT_ALONE: int
17 FORMAT_RAW: int
18 CHECK_NONE: int
19 CHECK_CRC32: int
20 CHECK_CRC64: int
21 CHECK_SHA256: int
22 CHECK_ID_MAX: int
23 CHECK_UNKNOWN: int
24 FILTER_LZMA1: int
25 FILTER_LZMA2: int
26 FILTER_DELTA: int
27 FILTER_X86: int
28 FILTER_IA64: int
29 FILTER_ARM: int
30 FILTER_ARMTHUMB: int
31 FILTER_SPARC: int
32 FILTER_POWERPC: int
33 MF_HC3: int
34 MF_HC4: int
35 MF_BT2: int
36 MF_BT3: int
37 MF_BT4: int
38 MODE_FAST: int
39 MODE_NORMAL: int
40 PRESET_DEFAULT: int
41 PRESET_EXTREME: int
42
43 # from _lzma.c
44 class LZMADecompressor(object):
45 def __init__(
46 self, format: Optional[int] = ..., memlimit: Optional[int] = ..., filters: Optional[_FilterChain] = ...
47 ) -> None: ...
48 def decompress(self, data: bytes, max_length: int = ...) -> bytes: ...
49 @property
50 def check(self) -> int: ...
51 @property
52 def eof(self) -> bool: ...
53 @property
54 def unused_data(self) -> bytes: ...
55 @property
56 def needs_input(self) -> bool: ...
57
58 # from _lzma.c
59 class LZMACompressor(object):
60 def __init__(
61 self, format: Optional[int] = ..., check: int = ..., preset: Optional[int] = ..., filters: Optional[_FilterChain] = ...
62 ) -> None: ...
63 def compress(self, data: bytes) -> bytes: ...
64 def flush(self) -> bytes: ...
65
66 class LZMAError(Exception): ...
67
68 class LZMAFile(io.BufferedIOBase, IO[bytes]):
69 def __init__(
70 self,
71 filename: Optional[_PathOrFile] = ...,
72 mode: str = ...,
73 *,
74 format: Optional[int] = ...,
75 check: int = ...,
76 preset: Optional[int] = ...,
77 filters: Optional[_FilterChain] = ...,
78 ) -> None: ...
79 def __enter__(self: _T) -> _T: ...
80 def close(self) -> None: ...
81 @property
82 def closed(self) -> bool: ...
83 def fileno(self) -> int: ...
84 def seekable(self) -> bool: ...
85 def readable(self) -> bool: ...
86 def writable(self) -> bool: ...
87 def peek(self, size: int = ...) -> bytes: ...
88 def read(self, size: Optional[int] = ...) -> bytes: ...
89 def read1(self, size: int = ...) -> bytes: ...
90 def readline(self, size: Optional[int] = ...) -> bytes: ...
91 def write(self, data: ReadableBuffer) -> int: ...
92 def seek(self, offset: int, whence: int = ...) -> int: ...
93 def tell(self) -> int: ...
94
95 @overload
96 def open(
97 filename: _PathOrFile,
98 mode: Literal["r", "rb"] = ...,
99 *,
100 format: Optional[int] = ...,
101 check: Literal[-1] = ...,
102 preset: None = ...,
103 filters: Optional[_FilterChain] = ...,
104 encoding: None = ...,
105 errors: None = ...,
106 newline: None = ...,
107 ) -> LZMAFile: ...
108 @overload
109 def open(
110 filename: _PathOrFile,
111 mode: _OpenBinaryWritingMode,
112 *,
113 format: Optional[int] = ...,
114 check: int = ...,
115 preset: Optional[int] = ...,
116 filters: Optional[_FilterChain] = ...,
117 encoding: None = ...,
118 errors: None = ...,
119 newline: None = ...,
120 ) -> LZMAFile: ...
121 @overload
122 def open(
123 filename: AnyPath,
124 mode: Literal["rt"],
125 *,
126 format: Optional[int] = ...,
127 check: Literal[-1] = ...,
128 preset: None = ...,
129 filters: Optional[_FilterChain] = ...,
130 encoding: Optional[str] = ...,
131 errors: Optional[str] = ...,
132 newline: Optional[str] = ...,
133 ) -> TextIO: ...
134 @overload
135 def open(
136 filename: AnyPath,
137 mode: _OpenTextWritingMode,
138 *,
139 format: Optional[int] = ...,
140 check: int = ...,
141 preset: Optional[int] = ...,
142 filters: Optional[_FilterChain] = ...,
143 encoding: Optional[str] = ...,
144 errors: Optional[str] = ...,
145 newline: Optional[str] = ...,
146 ) -> TextIO: ...
147 @overload
148 def open(
149 filename: _PathOrFile,
150 mode: str,
151 *,
152 format: Optional[int] = ...,
153 check: int = ...,
154 preset: Optional[int] = ...,
155 filters: Optional[_FilterChain] = ...,
156 encoding: Optional[str] = ...,
157 errors: Optional[str] = ...,
158 newline: Optional[str] = ...,
159 ) -> Union[LZMAFile, TextIO]: ...
160 def compress(
161 data: bytes, format: int = ..., check: int = ..., preset: Optional[int] = ..., filters: Optional[_FilterChain] = ...
162 ) -> bytes: ...
163 def decompress(data: bytes, format: int = ..., memlimit: Optional[int] = ..., filters: Optional[_FilterChain] = ...) -> bytes: ...
164 def is_check_supported(check: int) -> bool: ...
165