@@ -31,26 +31,24 @@ def _zstd_contentsize_converter(size):
3131 if size < 0 or size >= _lib .ZSTD_CONTENTSIZE_ERROR :
3232 raise ValueError (
3333 "size argument should be a positive int less "
34- "than %ull " % _lib .ZSTD_CONTENTSIZE_ERROR
34+ "than %u " % _lib .ZSTD_CONTENTSIZE_ERROR
3535 )
3636
3737 return size
3838
3939
4040class ZstdCompressor :
41- """
42- Create a compressor object for compressing data incrementally.
41+ """Create a compressor object for compressing data incrementally.
4342
44- level
45- The compression level to use. Defaults to COMPRESSION_LEVEL_DEFAULT.
46- options
47- A dict object that contains advanced compression parameters.
48- zstd_dict
49- A ZstdDict object, a pre-trained Zstandard dictionary.
43+ level
44+ The compression level to use. Defaults to COMPRESSION_LEVEL_DEFAULT.
45+ options
46+ A dict object that contains advanced compression parameters.
47+ zstd_dict
48+ A ZstdDict object, a pre-trained Zstandard dictionary.
5049
51- Thread-safe at method level. For one-shot compression, use the compress()
52- function instead.
53- """
50+ Thread-safe at method level. For one-shot compression, use the
51+ compress() function instead."""
5452
5553 CONTINUE = _lib .ZSTD_e_continue
5654 FLUSH_BLOCK = _lib .ZSTD_e_flush
@@ -95,13 +93,11 @@ def __init__(self, level=None, options=None, zstd_dict=None):
9593
9694 @property
9795 def last_mode (self ):
98- """
99- The last mode used to this compressor object, its value can be .CONTINUE,
100- .FLUSH_BLOCK, .FLUSH_FRAME. Initialized to .FLUSH_FRAME.
96+ """The last mode used to this compressor object, its value can be .CONTINUE,
97+ .FLUSH_BLOCK, .FLUSH_FRAME. Initialized to .FLUSH_FRAME.
10198
102- It can be used to get the current state of a compressor, such as, data
103- flushed, or a frame ended.
104- """
99+ It can be used to get the current state of a compressor, such as, data
100+ flushed, or a frame ended."""
105101 return self ._last_mode
106102
107103 def _zstd_set_c_level (self , level ):
@@ -203,17 +199,15 @@ def __del__(self):
203199 self ._cctx = _ffi .NULL
204200
205201 def compress (self , data , mode = _lib .ZSTD_e_continue ):
206- """
207- Provide data to the compressor object.
202+ """Provide data to the compressor object.
208203
209- mode
210- Can be these 3 values ZstdCompressor.CONTINUE,
211- ZstdCompressor.FLUSH_BLOCK, ZstdCompressor.FLUSH_FRAME
204+ mode
205+ Can be these 3 values ZstdCompressor.CONTINUE,
206+ ZstdCompressor.FLUSH_BLOCK, ZstdCompressor.FLUSH_FRAME
212207
213- Return a chunk of compressed data if possible, or b'' otherwise. When you have
214- finished providing data to the compressor, call the flush() method to finish
215- the compression process.
216- """
208+ Return a chunk of compressed data if possible, or b'' otherwise.
209+ When you have finished providing data to the compressor, call the
210+ flush() method to finish the compression process."""
217211 if (
218212 mode != _lib .ZSTD_e_continue
219213 and mode != _lib .ZSTD_e_flush
@@ -327,17 +321,15 @@ def _compress_mt_continue_lock_held(self, data):
327321 return _OutputBuffer_Finish (buffer , out )
328322
329323 def flush (self , mode = _lib .ZSTD_e_end ):
330- """
331- Finish the compression process.
324+ """Finish the compression process.
332325
333- mode
334- Can be these 2 values ZstdCompressor.FLUSH_FRAME,
335- ZstdCompressor.FLUSH_BLOCK
326+ mode
327+ Can be these 2 values ZstdCompressor.FLUSH_FRAME,
328+ ZstdCompressor.FLUSH_BLOCK
336329
337- Flush any remaining data left in internal buffers. Since Zstandard data
338- consists of one or more independent frames, the compressor object can still
339- be used after this method is called.
340- """
330+ Flush any remaining data left in internal buffers. Since Zstandard
331+ data consists of one or more independent frames, the compressor
332+ object can still be used after this method is called."""
341333 # Check mode value
342334 if mode != _lib .ZSTD_e_end and mode != _lib .ZSTD_e_flush :
343335 raise ValueError (
@@ -359,20 +351,19 @@ def flush(self, mode=_lib.ZSTD_e_end):
359351 raise
360352
361353 def set_pledged_input_size (self , size , / ):
362- """
363- Set the uncompressed content size to be written into the frame header.
354+ """Set the uncompressed content size to be written into the frame header.
364355
365- size
366- The size of the uncompressed data to be provided to the compressor.
356+ size
357+ The size of the uncompressed data to be provided to the compressor.
367358
368- This method can be used to ensure the header of the frame about to be written
369- includes the size of the data, unless the CompressionParameter.content_size_flag
370- is set to False. If last_mode != FLUSH_FRAME, then a RuntimeError is raised.
359+ This method can be used to ensure the header of the frame about to
360+ be written includes the size of the data, unless the
361+ CompressionParameter.content_size_flag is set to False.
362+ If last_mode != FLUSH_FRAME, then a RuntimeError is raised.
371363
372- It is important to ensure that the pledged data size matches the actual data
373- size. If they do not match the compressed output data may be corrupted and the
374- final chunk written may be lost.
375- """
364+ It is important to ensure that the pledged data size matches the
365+ actual data size. If they do not match the compressed output data
366+ may be corrupted and the final chunk written may be lost."""
376367 size = _zstd_contentsize_converter (size )
377368
378369 # Thread-safe code
0 commit comments