__init__.pyi 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481
  1. # Copyright (c) 2016-present, Gregory Szorc
  2. # All rights reserved.
  3. #
  4. # This software may be modified and distributed under the terms
  5. # of the BSD license. See the LICENSE file for details.
  6. import os
  7. from typing import (
  8. IO,
  9. BinaryIO,
  10. ByteString,
  11. Generator,
  12. Iterable,
  13. List,
  14. Optional,
  15. Set,
  16. Tuple,
  17. Union,
  18. )
  19. FLUSH_BLOCK: int
  20. FLUSH_FRAME: int
  21. COMPRESSOBJ_FLUSH_FINISH: int
  22. COMPRESSOBJ_FLUSH_BLOCK: int
  23. CONTENTSIZE_UNKNOWN: int
  24. CONTENTSIZE_ERROR: int
  25. MAX_COMPRESSION_LEVEL: int
  26. COMPRESSION_RECOMMENDED_INPUT_SIZE: int
  27. COMPRESSION_RECOMMENDED_OUTPUT_SIZE: int
  28. DECOMPRESSION_RECOMMENDED_INPUT_SIZE: int
  29. DECOMPRESSION_RECOMMENDED_OUTPUT_SIZE: int
  30. BLOCKSIZELOG_MAX: int
  31. BLOCKSIZE_MAX: int
  32. WINDOWLOG_MIN: int
  33. WINDOWLOG_MAX: int
  34. CHAINLOG_MIN: int
  35. CHAINLOG_MAX: int
  36. HASHLOG_MIN: int
  37. HASHLOG_MAX: int
  38. MINMATCH_MIN: int
  39. MINMATCH_MAX: int
  40. SEARCHLOG_MIN: int
  41. SEARCHLOG_MAX: int
  42. SEARCHLENGTH_MIN: int
  43. SEARCHLENGTH_MAX: int
  44. TARGETLENGTH_MIN: int
  45. TARGETLENGTH_MAX: int
  46. LDM_MINMATCH_MIN: int
  47. LDM_MINMATCH_MAX: int
  48. LDM_BUCKETSIZELOG_MAX: int
  49. STRATEGY_FAST: int
  50. STRATEGY_DFAST: int
  51. STRATEGY_GREEDY: int
  52. STRATEGY_LAZY: int
  53. STRATEGY_LAZY2: int
  54. STRATEGY_BTLAZY2: int
  55. STRATEGY_BTOPT: int
  56. STRATEGY_BTULTRA: int
  57. STRATEGY_BTULTRA2: int
  58. DICT_TYPE_AUTO: int
  59. DICT_TYPE_RAWCONTENT: int
  60. DICT_TYPE_FULLDICT: int
  61. FORMAT_ZSTD1: int
  62. FORMAT_ZSTD1_MAGICLESS: int
  63. ZSTD_VERSION: Tuple[int, int, int]
  64. FRAME_HEADER: bytes
  65. MAGIC_NUMBER: int
  66. backend: str
  67. backend_features: Set[str]
  68. __version__: str
  69. class ZstdError(Exception): ...
  70. class BufferSegment(object):
  71. offset: int
  72. def __len__(self) -> int: ...
  73. def tobytes(self) -> bytes: ...
  74. class BufferSegments(object):
  75. def __len__(self) -> int: ...
  76. def __getitem__(self, i: int) -> BufferSegment: ...
  77. class BufferWithSegments(object):
  78. size: int
  79. def __init__(self, data: ByteString, segments: ByteString): ...
  80. def __len__(self) -> int: ...
  81. def __getitem__(self, i: int) -> BufferSegment: ...
  82. def segments(self): ...
  83. def tobytes(self) -> bytes: ...
  84. class BufferWithSegmentsCollection(object):
  85. def __init__(self, *args): ...
  86. def __len__(self) -> int: ...
  87. def __getitem__(self, i: int) -> BufferSegment: ...
  88. def size(self) -> int: ...
  89. class ZstdCompressionParameters(object):
  90. @staticmethod
  91. def from_level(
  92. level: int, source_size: int = ..., dict_size: int = ..., **kwargs
  93. ) -> "ZstdCompressionParameters": ...
  94. def __init__(
  95. self,
  96. format: int = ...,
  97. compression_level: int = ...,
  98. window_log: int = ...,
  99. hash_log: int = ...,
  100. chain_log: int = ...,
  101. search_log: int = ...,
  102. min_match: int = ...,
  103. target_length: int = ...,
  104. strategy: int = ...,
  105. write_content_size: int = ...,
  106. write_checksum: int = ...,
  107. write_dict_id: int = ...,
  108. job_size: int = ...,
  109. overlap_log: int = ...,
  110. force_max_window: int = ...,
  111. enable_ldm: int = ...,
  112. ldm_hash_log: int = ...,
  113. ldm_min_match: int = ...,
  114. ldm_bucket_size_log: int = ...,
  115. ldm_hash_rate_log: int = ...,
  116. threads: int = ...,
  117. ): ...
  118. @property
  119. def format(self) -> int: ...
  120. @property
  121. def compression_level(self) -> int: ...
  122. @property
  123. def window_log(self) -> int: ...
  124. @property
  125. def hash_log(self) -> int: ...
  126. @property
  127. def chain_log(self) -> int: ...
  128. @property
  129. def search_log(self) -> int: ...
  130. @property
  131. def min_match(self) -> int: ...
  132. @property
  133. def target_length(self) -> int: ...
  134. @property
  135. def strategy(self) -> int: ...
  136. @property
  137. def write_content_size(self) -> int: ...
  138. @property
  139. def write_checksum(self) -> int: ...
  140. @property
  141. def write_dict_id(self) -> int: ...
  142. @property
  143. def job_size(self) -> int: ...
  144. @property
  145. def overlap_log(self) -> int: ...
  146. @property
  147. def force_max_window(self) -> int: ...
  148. @property
  149. def enable_ldm(self) -> int: ...
  150. @property
  151. def ldm_hash_log(self) -> int: ...
  152. @property
  153. def ldm_min_match(self) -> int: ...
  154. @property
  155. def ldm_bucket_size_log(self) -> int: ...
  156. @property
  157. def ldm_hash_rate_log(self) -> int: ...
  158. @property
  159. def threads(self) -> int: ...
  160. def estimated_compression_context_size(self) -> int: ...
  161. class CompressionParameters(ZstdCompressionParameters): ...
  162. class ZstdCompressionDict(object):
  163. k: int
  164. d: int
  165. def __init__(
  166. self,
  167. data: ByteString,
  168. dict_type: int = ...,
  169. k: int = ...,
  170. d: int = ...,
  171. ): ...
  172. def __len__(self) -> int: ...
  173. def dict_id(self) -> int: ...
  174. def as_bytes(self) -> bytes: ...
  175. def precompute_compress(
  176. self,
  177. level: int = ...,
  178. compression_params: ZstdCompressionParameters = ...,
  179. ): ...
  180. class ZstdCompressionObj(object):
  181. def compress(self, data: ByteString) -> bytes: ...
  182. def flush(self, flush_mode: int = ...) -> bytes: ...
  183. class ZstdCompressionChunker(object):
  184. def compress(self, data: ByteString): ...
  185. def flush(self): ...
  186. def finish(self): ...
  187. class ZstdCompressionReader(BinaryIO):
  188. def __enter__(self) -> "ZstdCompressionReader": ...
  189. def __exit__(self, exc_type, exc_value, exc_tb): ...
  190. def readable(self) -> bool: ...
  191. def writable(self) -> bool: ...
  192. def seekable(self) -> bool: ...
  193. def readline(self, limit: int = ...) -> bytes: ...
  194. def readlines(self, hint: int = ...) -> List[bytes]: ...
  195. def write(self, data: ByteString): ...
  196. def writelines(self, data: Iterable[bytes]): ...
  197. def isatty(self) -> bool: ...
  198. def flush(self): ...
  199. def close(self): ...
  200. @property
  201. def closed(self) -> bool: ...
  202. def tell(self) -> int: ...
  203. def readall(self) -> bytes: ...
  204. def __iter__(self): ...
  205. def __next__(self): ...
  206. def next(self): ...
  207. def read(self, size: int = ...) -> bytes: ...
  208. def read1(self, size: int = ...) -> bytes: ...
  209. def readinto(self, b) -> int: ...
  210. def readinto1(self, b) -> int: ...
  211. class ZstdCompressionWriter(BinaryIO):
  212. def __enter__(self) -> "ZstdCompressionWriter": ...
  213. def __exit__(self, exc_type, exc_value, exc_tb): ...
  214. def memory_size(self) -> int: ...
  215. def fileno(self) -> int: ...
  216. def close(self): ...
  217. @property
  218. def closed(self) -> bool: ...
  219. def isatty(self) -> bool: ...
  220. def readable(self) -> bool: ...
  221. def readline(self, size: int = ...) -> bytes: ...
  222. def readlines(self, hint: int = ...) -> List[bytes]: ...
  223. def seek(self, offset: int, whence: int = ...): ...
  224. def seekable(self) -> bool: ...
  225. def truncate(self, size: int = ...): ...
  226. def writable(self) -> bool: ...
  227. def writelines(self, lines: Iterable[bytes]): ...
  228. def read(self, size: int = ...) -> bytes: ...
  229. def readall(self) -> bytes: ...
  230. def readinto(self, b): ...
  231. def write(self, data: ByteString) -> int: ...
  232. def flush(self, flush_mode: int = ...) -> int: ...
  233. def tell(self) -> int: ...
  234. class ZstdCompressor(object):
  235. def __init__(
  236. self,
  237. level: int = ...,
  238. dict_data: Optional[ZstdCompressionDict] = ...,
  239. compression_params: Optional[ZstdCompressionParameters] = ...,
  240. write_checksum: Optional[bool] = ...,
  241. write_content_size: Optional[bool] = ...,
  242. write_dict_id: Optional[bool] = ...,
  243. threads: int = ...,
  244. ): ...
  245. def memory_size(self) -> int: ...
  246. def compress(self, data: ByteString) -> bytes: ...
  247. def compressobj(self, size: int = ...) -> ZstdCompressionObj: ...
  248. def chunker(
  249. self, size: int = ..., chunk_size: int = ...
  250. ) -> ZstdCompressionChunker: ...
  251. def copy_stream(
  252. self,
  253. ifh: IO[bytes],
  254. ofh: IO[bytes],
  255. size: int = ...,
  256. read_size: int = ...,
  257. write_size: int = ...,
  258. ) -> Tuple[int, int]: ...
  259. def stream_reader(
  260. self,
  261. source: Union[IO[bytes], ByteString],
  262. size: int = ...,
  263. read_size: int = ...,
  264. *,
  265. closefd: bool = ...,
  266. ) -> ZstdCompressionReader: ...
  267. def stream_writer(
  268. self,
  269. writer: IO[bytes],
  270. size: int = ...,
  271. write_size: int = ...,
  272. write_return_read: bool = ...,
  273. *,
  274. closefd: bool = ...,
  275. ) -> ZstdCompressionWriter: ...
  276. def read_to_iter(
  277. self,
  278. reader: Union[IO[bytes], ByteString],
  279. size: int = ...,
  280. read_size: int = ...,
  281. write_size: int = ...,
  282. ) -> Generator[bytes, None, None]: ...
  283. def frame_progression(self) -> Tuple[int, int, int]: ...
  284. def multi_compress_to_buffer(
  285. self,
  286. data: Union[
  287. BufferWithSegments,
  288. BufferWithSegmentsCollection,
  289. List[ByteString],
  290. ],
  291. threads: int = ...,
  292. ) -> BufferWithSegmentsCollection: ...
  293. class ZstdDecompressionObj(object):
  294. def decompress(self, data: ByteString) -> bytes: ...
  295. def flush(self, length: int = ...) -> bytes: ...
  296. @property
  297. def unused_data(self) -> bytes: ...
  298. @property
  299. def unconsumed_tail(self) -> bytes: ...
  300. @property
  301. def eof(self) -> bool: ...
  302. class ZstdDecompressionReader(BinaryIO):
  303. def __enter__(self) -> "ZstdDecompressionReader": ...
  304. def __exit__(self, exc_type, exc_value, exc_tb): ...
  305. def readable(self) -> bool: ...
  306. def writable(self) -> bool: ...
  307. def seekable(self) -> bool: ...
  308. def readline(self, size: int = ...): ...
  309. def readlines(self, hint: int = ...): ...
  310. def write(self, data: ByteString): ...
  311. def writelines(self, lines: Iterable[bytes]): ...
  312. def isatty(self) -> bool: ...
  313. def flush(self): ...
  314. def close(self): ...
  315. @property
  316. def closed(self) -> bool: ...
  317. def tell(self) -> int: ...
  318. def readall(self) -> bytes: ...
  319. def __iter__(self): ...
  320. def __next__(self): ...
  321. def next(self): ...
  322. def read(self, size: int = ...) -> bytes: ...
  323. def readinto(self, b) -> int: ...
  324. def read1(self, size: int = ...) -> bytes: ...
  325. def readinto1(self, b) -> int: ...
  326. def seek(self, pos: int, whence: int = ...) -> int: ...
  327. class ZstdDecompressionWriter(BinaryIO):
  328. def __enter__(self) -> "ZstdDecompressionWriter": ...
  329. def __exit__(self, exc_type, exc_value, exc_tb): ...
  330. def memory_size(self) -> int: ...
  331. def close(self): ...
  332. @property
  333. def closed(self) -> bool: ...
  334. def fileno(self) -> int: ...
  335. def flush(self): ...
  336. def isatty(self) -> bool: ...
  337. def readable(self) -> bool: ...
  338. def readline(self, size: int = ...): ...
  339. def readlines(self, hint: int = ...): ...
  340. def seek(self, offset: int, whence: int = ...): ...
  341. def seekable(self) -> bool: ...
  342. def tell(self): ...
  343. def truncate(self, size: int = ...): ...
  344. def writable(self) -> bool: ...
  345. def writelines(self, lines: Iterable[bytes]): ...
  346. def read(self, size: int = ...): ...
  347. def readall(self): ...
  348. def readinto(self, b): ...
  349. def write(self, data: ByteString) -> int: ...
  350. class ZstdDecompressor(object):
  351. def __init__(
  352. self,
  353. dict_data: Optional[ZstdCompressionDict] = ...,
  354. max_window_size: int = ...,
  355. format: int = ...,
  356. ): ...
  357. def memory_size(self) -> int: ...
  358. def decompress(
  359. self,
  360. data: ByteString,
  361. max_output_size: int = ...,
  362. read_across_frames: bool = ...,
  363. allow_extra_data: bool = ...,
  364. ) -> bytes: ...
  365. def stream_reader(
  366. self,
  367. source: Union[IO[bytes], ByteString],
  368. read_size: int = ...,
  369. read_across_frames: bool = ...,
  370. *,
  371. closefd=False,
  372. ) -> ZstdDecompressionReader: ...
  373. def decompressobj(
  374. self, write_size: int = ..., read_across_frames: bool = False
  375. ) -> ZstdDecompressionObj: ...
  376. def read_to_iter(
  377. self,
  378. reader: Union[IO[bytes], ByteString],
  379. read_size: int = ...,
  380. write_size: int = ...,
  381. skip_bytes: int = ...,
  382. ) -> Generator[bytes, None, None]: ...
  383. def stream_writer(
  384. self,
  385. writer: IO[bytes],
  386. write_size: int = ...,
  387. write_return_read: bool = ...,
  388. *,
  389. closefd: bool = ...,
  390. ) -> ZstdDecompressionWriter: ...
  391. def copy_stream(
  392. self,
  393. ifh: IO[bytes],
  394. ofh: IO[bytes],
  395. read_size: int = ...,
  396. write_size: int = ...,
  397. ) -> Tuple[int, int]: ...
  398. def decompress_content_dict_chain(
  399. self, frames: list[ByteString]
  400. ) -> bytes: ...
  401. def multi_decompress_to_buffer(
  402. self,
  403. frames: Union[
  404. BufferWithSegments,
  405. BufferWithSegmentsCollection,
  406. List[ByteString],
  407. ],
  408. decompressed_sizes: ByteString = ...,
  409. threads: int = ...,
  410. ) -> BufferWithSegmentsCollection: ...
  411. class FrameParameters(object):
  412. content_size: int
  413. window_size: int
  414. dict_id: int
  415. has_checksum: bool
  416. def estimate_decompression_context_size() -> int: ...
  417. def frame_content_size(data: ByteString) -> int: ...
  418. def frame_header_size(data: ByteString) -> int: ...
  419. def get_frame_parameters(
  420. data: ByteString, format: Optional[int] = None
  421. ) -> FrameParameters: ...
  422. def train_dictionary(
  423. dict_size: int,
  424. samples: list[ByteString],
  425. k: int = ...,
  426. d: int = ...,
  427. f: int = ...,
  428. split_point: float = ...,
  429. accel: int = ...,
  430. notifications: int = ...,
  431. dict_id: int = ...,
  432. level: int = ...,
  433. steps: int = ...,
  434. threads: int = ...,
  435. ) -> ZstdCompressionDict: ...
  436. def open(
  437. filename: Union[bytes, str, os.PathLike, BinaryIO],
  438. mode: str = ...,
  439. cctx: Optional[ZstdCompressor] = ...,
  440. dctx: Optional[ZstdDecompressor] = ...,
  441. encoding: Optional[str] = ...,
  442. errors: Optional[str] = ...,
  443. newline: Optional[str] = ...,
  444. closefd: bool = ...,
  445. ): ...
  446. def compress(data: ByteString, level: int = ...) -> bytes: ...
  447. def decompress(data: ByteString, max_output_size: int = ...) -> bytes: ...