| 1 |
import enum |
| 2 |
from io import BufferedIOBase, TextIOWrapper, _WrappedBuffer |
| 3 |
from typing import ( |
| 4 |
Any, |
| 5 |
Final, |
| 6 |
Iterable, |
| 7 |
Literal, |
| 8 |
Mapping, |
| 9 |
Protocol, |
| 10 |
Self, |
| 11 |
TypeAlias, |
| 12 |
final, |
| 13 |
overload, |
| 14 |
type_check_only, |
| 15 |
) |
| 16 |
|
| 17 |
from _typeshed import ReadableBuffer, StrOrBytesPath, SupportsWrite, WriteableBuffer |
| 18 |
|
| 19 |
@type_check_only |
| 20 |
class _streams_Reader(Protocol): |
| 21 |
def read(self, n: int, /) -> bytes: ... |
| 22 |
def seekable(self) -> bool: ... |
| 23 |
def seek(self, n: int, /) -> Any: ... |
| 24 |
|
| 25 |
@type_check_only |
| 26 |
class _streams_BaseStream(BufferedIOBase): ... |
| 27 |
|
| 28 |
# |
| 29 |
# __init__.py |
| 30 |
# |
| 31 |
|
| 32 |
__all__ = ( |
| 33 |
# backports.zstd |
| 34 |
"COMPRESSION_LEVEL_DEFAULT", |
| 35 |
"compress", |
| 36 |
"CompressionParameter", |
| 37 |
"decompress", |
| 38 |
"DecompressionParameter", |
| 39 |
"finalize_dict", |
| 40 |
"get_frame_info", |
| 41 |
"Strategy", |
| 42 |
"train_dict", |
| 43 |
# backports.zstd._shutil |
| 44 |
"register_shutil", |
| 45 |
# backports.zstd._zstdfile |
| 46 |
"open", |
| 47 |
"ZstdFile", |
| 48 |
# backports.zstd._zstd |
| 49 |
"get_frame_size", |
| 50 |
"zstd_version", |
| 51 |
"zstd_version_info", |
| 52 |
"ZstdCompressor", |
| 53 |
"ZstdDecompressor", |
| 54 |
"ZstdDict", |
| 55 |
"ZstdError", |
| 56 |
) |
| 57 |
|
| 58 |
zstd_version_info: Final[tuple[int, int, int]] |
| 59 |
COMPRESSION_LEVEL_DEFAULT: Final[int] = ... |
| 60 |
|
| 61 |
class FrameInfo: |
| 62 |
__slots__ = ("decompressed_size", "dictionary_id") |
| 63 |
decompressed_size: int |
| 64 |
dictionary_id: int |
| 65 |
def __init__(self, decompressed_size: int, dictionary_id: int) -> None: ... |
| 66 |
|
| 67 |
def get_frame_info(frame_buffer: ReadableBuffer) -> FrameInfo: ... |
| 68 |
def train_dict(samples: Iterable[ReadableBuffer], dict_size: int) -> ZstdDict: ... |
| 69 |
def finalize_dict(zstd_dict: ZstdDict, /, samples: Iterable[ReadableBuffer], dict_size: int, level: int) -> ZstdDict: ... |
| 70 |
def compress( |
| 71 |
data: ReadableBuffer, |
| 72 |
level: int | None = None, |
| 73 |
options: Mapping[int, int] | None = None, |
| 74 |
zstd_dict: ZstdDict | tuple[ZstdDict, int] | None = None, |
| 75 |
) -> bytes: ... |
| 76 |
def decompress( |
| 77 |
data: ReadableBuffer, zstd_dict: ZstdDict | tuple[ZstdDict, int] | None = None, options: Mapping[int, int] | None = None |
| 78 |
) -> bytes: ... |
| 79 |
@final |
| 80 |
class CompressionParameter(enum.IntEnum): |
| 81 |
compression_level = ... |
| 82 |
window_log = ... |
| 83 |
hash_log = ... |
| 84 |
chain_log = ... |
| 85 |
search_log = ... |
| 86 |
min_match = ... |
| 87 |
target_length = ... |
| 88 |
strategy = ... |
| 89 |
enable_long_distance_matching = ... |
| 90 |
ldm_hash_log = ... |
| 91 |
ldm_min_match = ... |
| 92 |
ldm_bucket_size_log = ... |
| 93 |
ldm_hash_rate_log = ... |
| 94 |
content_size_flag = ... |
| 95 |
checksum_flag = ... |
| 96 |
dict_id_flag = ... |
| 97 |
nb_workers = ... |
| 98 |
job_size = ... |
| 99 |
overlap_log = ... |
| 100 |
def bounds(self) -> tuple[int, int]: ... |
| 101 |
|
| 102 |
@final |
| 103 |
class DecompressionParameter(enum.IntEnum): |
| 104 |
window_log_max = ... |
| 105 |
def bounds(self) -> tuple[int, int]: ... |
| 106 |
|
| 107 |
@final |
| 108 |
class Strategy(enum.IntEnum): |
| 109 |
fast = ... |
| 110 |
dfast = ... |
| 111 |
greedy = ... |
| 112 |
lazy = ... |
| 113 |
lazy2 = ... |
| 114 |
btlazy2 = ... |
| 115 |
btopt = ... |
| 116 |
btultra = ... |
| 117 |
btultra2 = ... |
| 118 |
|
| 119 |
# |
| 120 |
# _shutil |
| 121 |
# |
| 122 |
|
| 123 |
def register_shutil(*, tar: bool = True, zip: bool = True) -> None: ... |
| 124 |
|
| 125 |
# |
| 126 |
# _zstdfile |
| 127 |
# |
| 128 |
|
| 129 |
_ReadBinaryMode: TypeAlias = Literal["r", "rb"] |
| 130 |
_WriteBinaryMode: TypeAlias = Literal["w", "wb", "x", "xb", "a", "ab"] |
| 131 |
_ReadTextMode: TypeAlias = Literal["rt"] |
| 132 |
_WriteTextMode: TypeAlias = Literal["wt", "xt", "at"] |
| 133 |
|
| 134 |
@type_check_only |
| 135 |
class _FileBinaryRead(_streams_Reader, Protocol): |
| 136 |
def close(self) -> None: ... |
| 137 |
|
| 138 |
@type_check_only |
| 139 |
class _FileBinaryWrite(SupportsWrite[bytes], Protocol): |
| 140 |
def close(self) -> None: ... |
| 141 |
|
| 142 |
class ZstdFile(_streams_BaseStream): |
| 143 |
FLUSH_BLOCK = ZstdCompressor.FLUSH_BLOCK |
| 144 |
FLUSH_FRAME = ZstdCompressor.FLUSH_FRAME |
| 145 |
|
| 146 |
@overload |
| 147 |
def __init__( |
| 148 |
self, |
| 149 |
file: StrOrBytesPath | _FileBinaryRead, |
| 150 |
/, |
| 151 |
mode: _ReadBinaryMode = "r", |
| 152 |
*, |
| 153 |
level: None = None, |
| 154 |
options: Mapping[int, int] | None = None, |
| 155 |
zstd_dict: ZstdDict | tuple[ZstdDict, int] | None = None, |
| 156 |
) -> None: ... |
| 157 |
@overload |
| 158 |
def __init__( |
| 159 |
self, |
| 160 |
file: StrOrBytesPath | _FileBinaryWrite, |
| 161 |
/, |
| 162 |
mode: _WriteBinaryMode, |
| 163 |
*, |
| 164 |
level: int | None = None, |
| 165 |
options: Mapping[int, int] | None = None, |
| 166 |
zstd_dict: ZstdDict | tuple[ZstdDict, int] | None = None, |
| 167 |
) -> None: ... |
| 168 |
def write(self, data: ReadableBuffer, /) -> int: ... |
| 169 |
def flush(self, mode: _ZstdCompressorFlushBlock | _ZstdCompressorFlushFrame = 1) -> bytes: ... # type: ignore[override] |
| 170 |
def read(self, size: int | None = -1) -> bytes: ... |
| 171 |
def read1(self, size: int | None = -1) -> bytes: ... |
| 172 |
def readinto(self, b: WriteableBuffer) -> int: ... |
| 173 |
def readinto1(self, b: WriteableBuffer) -> int: ... |
| 174 |
def readline(self, size: int | None = -1) -> bytes: ... |
| 175 |
def seek(self, offset: int, whence: int = 0) -> int: ... |
| 176 |
def peek(self, size: int = -1) -> bytes: ... |
| 177 |
@property |
| 178 |
def name(self) -> str | bytes: ... |
| 179 |
@property |
| 180 |
def mode(self) -> Literal["rb", "wb"]: ... |
| 181 |
|
| 182 |
@overload |
| 183 |
def open( |
| 184 |
file: StrOrBytesPath | _FileBinaryRead, |
| 185 |
/, |
| 186 |
mode: _ReadBinaryMode = "rb", |
| 187 |
*, |
| 188 |
level: None = None, |
| 189 |
options: Mapping[int, int] | None = None, |
| 190 |
zstd_dict: ZstdDict | tuple[ZstdDict, int] | None = None, |
| 191 |
encoding: str | None = None, |
| 192 |
errors: str | None = None, |
| 193 |
newline: str | None = None, |
| 194 |
) -> ZstdFile: ... |
| 195 |
@overload |
| 196 |
def open( |
| 197 |
file: StrOrBytesPath | _FileBinaryWrite, |
| 198 |
/, |
| 199 |
mode: _WriteBinaryMode, |
| 200 |
*, |
| 201 |
level: int | None = None, |
| 202 |
options: Mapping[int, int] | None = None, |
| 203 |
zstd_dict: ZstdDict | tuple[ZstdDict, int] | None = None, |
| 204 |
encoding: str | None = None, |
| 205 |
errors: str | None = None, |
| 206 |
newline: str | None = None, |
| 207 |
) -> ZstdFile: ... |
| 208 |
@overload |
| 209 |
def open( |
| 210 |
file: StrOrBytesPath | _WrappedBuffer, |
| 211 |
/, |
| 212 |
mode: _ReadTextMode, |
| 213 |
*, |
| 214 |
level: None = None, |
| 215 |
options: Mapping[int, int] | None = None, |
| 216 |
zstd_dict: ZstdDict | tuple[ZstdDict, int] | None = None, |
| 217 |
encoding: str | None = None, |
| 218 |
errors: str | None = None, |
| 219 |
newline: str | None = None, |
| 220 |
) -> TextIOWrapper: ... |
| 221 |
@overload |
| 222 |
def open( |
| 223 |
file: StrOrBytesPath | _WrappedBuffer, |
| 224 |
/, |
| 225 |
mode: _WriteTextMode, |
| 226 |
*, |
| 227 |
level: int | None = None, |
| 228 |
options: Mapping[int, int] | None = None, |
| 229 |
zstd_dict: ZstdDict | tuple[ZstdDict, int] | None = None, |
| 230 |
encoding: str | None = None, |
| 231 |
errors: str | None = None, |
| 232 |
newline: str | None = None, |
| 233 |
) -> TextIOWrapper: ... |
| 234 |
|
| 235 |
# |
| 236 |
# _zstd |
| 237 |
# |
| 238 |
|
| 239 |
_ZstdCompressorContinue: TypeAlias = Literal[0] |
| 240 |
_ZstdCompressorFlushBlock: TypeAlias = Literal[1] |
| 241 |
_ZstdCompressorFlushFrame: TypeAlias = Literal[2] |
| 242 |
|
| 243 |
@final |
| 244 |
class ZstdCompressor: |
| 245 |
CONTINUE: Final = 0 |
| 246 |
FLUSH_BLOCK: Final = 1 |
| 247 |
FLUSH_FRAME: Final = 2 |
| 248 |
def __new__( |
| 249 |
cls, |
| 250 |
level: int | None = None, |
| 251 |
options: Mapping[int, int] | None = None, |
| 252 |
zstd_dict: ZstdDict | tuple[ZstdDict, int] | None = None, |
| 253 |
) -> Self: ... |
| 254 |
def compress( |
| 255 |
self, /, data: ReadableBuffer, mode: _ZstdCompressorContinue | _ZstdCompressorFlushBlock | _ZstdCompressorFlushFrame = 0 |
| 256 |
) -> bytes: ... |
| 257 |
def flush(self, /, mode: _ZstdCompressorFlushBlock | _ZstdCompressorFlushFrame = 2) -> bytes: ... |
| 258 |
def set_pledged_input_size(self, size: int | None, /) -> None: ... |
| 259 |
@property |
| 260 |
def last_mode(self) -> _ZstdCompressorContinue | _ZstdCompressorFlushBlock | _ZstdCompressorFlushFrame: ... |
| 261 |
|
| 262 |
@final |
| 263 |
class ZstdDecompressor: |
| 264 |
def __new__( |
| 265 |
cls, zstd_dict: ZstdDict | tuple[ZstdDict, int] | None = None, options: Mapping[int, int] | None = None |
| 266 |
) -> Self: ... |
| 267 |
def decompress(self, /, data: ReadableBuffer, max_length: int = -1) -> bytes: ... |
| 268 |
@property |
| 269 |
def eof(self) -> bool: ... |
| 270 |
@property |
| 271 |
def needs_input(self) -> bool: ... |
| 272 |
@property |
| 273 |
def unused_data(self) -> bytes: ... |
| 274 |
|
| 275 |
@final |
| 276 |
class ZstdDict: |
| 277 |
def __new__(cls, dict_content: bytes, /, *, is_raw: bool = False) -> Self: ... |
| 278 |
def __len__(self, /) -> int: ... |
| 279 |
@property |
| 280 |
def as_digested_dict(self) -> tuple[Self, int]: ... |
| 281 |
@property |
| 282 |
def as_prefix(self) -> tuple[Self, int]: ... |
| 283 |
@property |
| 284 |
def as_undigested_dict(self) -> tuple[Self, int]: ... |
| 285 |
@property |
| 286 |
def dict_content(self) -> bytes: ... |
| 287 |
@property |
| 288 |
def dict_id(self) -> int: ... |
| 289 |
|
| 290 |
class ZstdError(Exception): ... |
| 291 |
|
| 292 |
def get_frame_size(frame_buffer: ReadableBuffer) -> int: ... |
| 293 |
|
| 294 |
zstd_version: Final[str] |
| 295 |
zstd_version_number: Final[int] |