Viewing File: /opt/imunify360/venv/lib/python3.11/site-packages/pyzstd/__pycache__/__init__.cpython-311.pyc



]jbddlZddlZddlmZ	ddlmZn#e$rGddZYnwxYw	ddlTddlmZm	Z	m
Z
n1#e$r)	ddlTddlmZm	Z	m
Z
d	Zn#e$red
wxYwYnwxYwdZ
dZd
ZddZddZdZdZdZdZGddejZdZdZdZGddejZddddddddZdS)N)maxsize)PathLikeceZdZdS)rN)__name__
__module____qualname__q/builddir/build/BUILD/imunify360-venv-2.6.3/opt/imunify360/venv/lib64/python3.11/site-packages/pyzstd/__init__.pyrrsr
r)*)_train_dict_finalize_dict_ZSTD_DStreamInSizeTapyzstd module: Neither C implementation nor CFFI implementation can be imported. If pyzstd module is dynamically linked to zstd library, make sure not to remove zstd library, and the run-time zstd library's version can't be lower than that at compile-time.z0.15.3zPython bindings to Zstandard (zstd) compression library, the API is similar to
Python's bz2/lzma/zlib modules.

Documentation: https://pyzstd.readthedocs.io
GitHub: https://github.com/animalize/pyzstd
PyPI: https://pypi.org/project/pyzstd)ZstdCompressorRichMemZstdCompressorZstdDecompressorEndlessZstdDecompressor
CParameter
DParameterStrategy	ZstdErrorcompressrichmem_compress
decompresscompress_streamdecompress_streamZstdDict
train_dict
finalize_dictget_frame_infoget_frame_sizeZstdFileopenzstd_versionzstd_version_infozstd_support_multithreadcompressionLevel_valuescbt||}||tjS)aCompress a block of data, return a bytes object.

    Compressing b'' will get an empty content frame (9 bytes or more).

    Parameters
    data:            A bytes-like object, data to be compressed.
    level_or_option: When it's an int object, it represents compression level.
                     When it's a dict object, it contains advanced compression
                     parameters.
    zstd_dict:       A ZstdDict object, pre-trained dictionary for compression.
    )rrFLUSH_FRAMEdatalevel_or_option	zstd_dictcomps    rrr3s*/955D==~9:::r
cLt||}||S)aBCompress a block of data, return a bytes object.

    Use rich memory mode, it's faster than compress() in some cases, but
    allocates more memory.

    Compressing b'' will get an empty content frame (9 bytes or more).

    Parameters
    data:            A bytes-like object, data to be compressed.
    level_or_option: When it's an int object, it represents compression level.
                     When it's a dict object, it contains advanced compression
                     parameters.
    zstd_dict:       A ZstdDict object, pre-trained dictionary for compression.
    )rrr+s    rrrCs%!)<<D==r
ct|ttfrt|St	|jSN)
isinstancebytes	bytearraylen
memoryviewnbytes)dats r_nbytesr:Vs3#y)**3xxc??!!r
cVt|tstdg}g}|D]9}|||t	|:d|}|st
dt|||}t|S)zTrain a zstd dictionary, return a ZstdDict object.

    Parameters
    samples:   An iterable of samples, a sample is a bytes-like object
               represents a file.
    dict_size: The dictionary's maximum size, in bytes.
    +dict_size argument should be an int object.r
z6The samples are empty content, can't train dictionary.)	r3int	TypeErrorappendr:join
ValueErrorrr)samples	dict_sizechunkschunk_sizeschunkdict_contents      rrr\si%%GEFFFFK++

e75>>****
XXf

FSQRRR
v{I>>LL!!!r
c<tdkrdtz}t|t|tstdt|tstdt|tstdg}g}|D]9}|||t|:d	|}|stdt|j||||}t	|S)aFinalize a zstd dictionary, return a ZstdDict object.

    Given a custom content as a basis for dictionary, and a set of samples,
    finalize dictionary by adding headers and statistics according to the zstd
    dictionary format.

    You may compose an effective dictionary content by hand, which is used as
    basis dictionary, and use some samples to finalize a dictionary. The basis
    dictionary can be a "raw content" dictionary, see is_raw parameter in
    ZstdDict.__init__ method.

    Parameters
    zstd_dict: A ZstdDict object, basis dictionary.
    samples:   An iterable of samples, a sample is a bytes-like object
               represents a file.
    dict_size: The dictionary's maximum size, in bytes.
    level:     The compression level expected to use in production. The
               statistics for each compression level differ, so tuning the
               dictionary for the compression level can help quite a bit.
    )rzThis function only available when the underlying zstd library's version is greater than or equal to v1.4.5, the current underlying zstd library's version is v%s./zstd_dict argument should be a ZstdDict object.r<z'level argument should be an int object.r
z9The samples are empty content, can't finalize dictionary.)
r&r%NotImplementedErrorr3rr>r=r?r:r@rArrG)	r.rBrClevelmsgrDrErFrGs	         rr r {s;*9$$GJVW"#&&&i**KIJJJi%%GEFFFeS!!CABBBFK++

e75>>****
XXf

FVTUUU")"8"(+"+U44LL!!!r
ic0eZdZdZddZejfdZdS)ZstdDecompressReadercg}	|t}|sn||3d|S)NTr
)readrr?r@)selfrDr,s   rreadallzZstdDecompressReader.readallsU	 99W%%D
MM$	 xxr
c|dkr|S|r|jrdS	|jjrR|jt}|s0|jjrd|_|j|_	dStdnd}|j||}|r|xjt|z
c_|S)Nrr
TzACompressed file ended before the end-of-stream marker was reached)
rT_eof
_decompressorneeds_input_fprRr
at_frame_edge_pos_sizeEOFErrorrr6)rSsizerawblockr,s    rrRzZstdDecompressReader.reads!88<<>>!	ty	3	!-
8==)<==K)7K$(	%)Y
"s&(JKKK
K%004@@D
		SYY&		#	r
cH|tjkrn|tjkr|j|z}n}|tjkrK|jdkr5|tr	|t|j|z}n"td	|||jkr|
n
||jz}|dkrC|tt|}|sn|t|z}|dkC|jS)NrzInvalid value for whence: {})
ioSEEK_SETSEEK_CURr\SEEK_ENDr]rR_32_KiBrAformat_rewindminr6)rSoffsetwhencer,s    rseekzZstdDecompressReader.seeksR[  
r{
"
"Y'FF
r{
"
"zA~~ii((ii((Z&(FF;BB6JJKKKDILLNNNNdiFqjj99S&1122D
c$iiF	qjjyr
NrU)rrrrTrRrbrcrlr	r
rrPrPsR
 
 
 :#%+r
rPceZdZdZdddddZdZddZdZd	ZddZ	ddZ
d
ZdZddZ
ejfdZddZdZdZedZdZdZdZdS)r#a?A file object providing transparent zstd (de)compression.

    A ZstdFile can act as a wrapper for an existing file object, or refer
    directly to a named file on disk.

    Note that ZstdFile provides a *binary* file interface - data read is
    returned as bytes, and data to be written must be given as bytes.
    rNr-r.cd|_d|_t|_t	|tdtfstd|dvr=t	|tdtfsd}t|t}n|dvr_t	|tdttfsd}t|t}t|||_
d|_n"td	|t	|t"t$t&fr2d
|vr|d
z
}t)j|||_d|_||_n>t-|dst-|d
r||_||_ntd|tkrDt/|jt0t2||}t)j|t6|_dSdS)aOpen a zstd compressed file in binary mode.

        filename can be either an actual file name (given as a str, bytes, or
        PathLike object), in which case the named file is opened, or it can be
        an existing file object to read from or write to.

        mode can be "r" for reading (default), "w" for (over)writing, "x" for
        creating exclusively, or "a" for appending. These can equivalently be
        given as "rb", "wb", "xb" and "ab" respectively.

        Parameters
        level_or_option: When it's an int object, it represents compression
            level. When it's a dict object, it contains advanced compression
            parameters. Note, in read mode (decompression), it can only be a
            dict object, that represents decompression option. It doesn't
            support int type compression level in this case.
        zstd_dict: A ZstdDict object, pre-trained dictionary for compression /
            decompression.
        NFrK)rprbzIn read mode (decompression), level_or_option argument should be a dict object, that represents decompression option. It doesn't support int type compression level in this case.)wwbaabxxbz6level_or_option argument should be int or dict object.rzInvalid mode: {!r}bTrRwritez6filename must be a str, bytes, file or PathLike object)trailing_errorr.option)rZ_closefp_MODE_CLOSED_moder3typerr>dict
_MODE_READr=_MODE_WRITEr_compressorr\rArgstrr4rrbr$hasattrrPrrBufferedReaderrf_buffer)rSfilenamemoder-r.rN	mode_coderaws        r__init__zZstdFile.__init__.s*
!
)d4jj(%;<<	OMNNN;oT

D/ABB
%' nn$"II
6
6
6oT

C/FGG
%Nnn$#I-oyIIDDII188>>???heX 677
	V$wx..DH DM#DJJ
Xv
&
&	V'(G*D*D	VDH"DJJTUUU
""&tx1H6?1:?TTTC,S'::DLLL	#"r
c|jtkrdS	t|dr.	|jd|_nb#d|_wxYw|jt
krF	|j|j	d|_n#d|_wxYw	|j
r|jd|_d|_
t|_dS#d|_d|_
t|_wxYw#	|j
r|jd|_d|_
t|_n#d|_d|_
t|_wxYwwxYw)zFlush and close the file.

        May be called more than once without error. Once the file is
        closed, any other operation on it will raise a ValueError.
        NrF)rrrrcloserrZr{rflushr~rSs rrzZstdFile.closets:%%F	*tY''
,(L&&((($(DLL4DL''''{**,HNN4#3#9#9#;#;<<<(,D$$tD$++++
*=%HNN$$$ %
)


  %
)
))))

*=%HNN$$$ %
)

  %
)
))))))))s]DAD	AD#1BD	B%%D) C%%DE! E&E!EE!c|jtkrtd|tkr%|jtkrt	jdn/|tkr$|jtkrt	jd)NzI/O operation on closed filezFile not open for readingzFile not open for writing)rrrArrbUnsupportedOperationr)rS
expected_modes  r_check_modezZstdFile._check_modes~:%%;<<<J&&zZ''-.IJJJ(
k
)
)z[((-.IJJJ	r
cnt|ttfrt|}nt	|}|j}	|j|}n*#t$r|	tYnwxYw|r|j||xj
|z
c_
|S)aWrite a bytes-like object to the file.

        Returns the number of uncompressed bytes written, which is
        always the length of data in bytes. Note that due to buffering,
        the file on disk may not reflect the data written until close()
        is called.
        )r3r4r5r6r7r8rrAttributeErrorrrrZr{r\)rSr,length
compresseds    rr{zZstdFile.writesdUI.//	!YYFFd##D[F	*)22488JJ	*	*	*[)))))	*
	'HNN:&&&		V		
sA$BBcV|jtkrdS	|jtj}n$#t$r|YnwxYw|r|j	|t|jdr|jdSdS)aFlush remaining data to the underlying stream.

        It uses ZstdCompressor.FLUSH_BLOCK mode. Abuse of this method will
        reduce compression ratio, use it only when necessary.

        If the program is interrupted afterwards, all data can be recovered.
        To ensure saving to disk, also need to use os.fsync(fd).

        This method does nothing in reading mode.
        Nr)rrrrrFLUSH_BLOCKrrrZr{r)rSrs  rrzZstdFile.flushs:##F	)//0JKKJJ				
	'HNN:&&&48W%%	HNN		s$9AArUc	|j|S#t$r|tYdSwxYw)zRead up to size uncompressed bytes from the file.

        If size is negative or omitted, read until EOF is reached.
        Returns b"" if the file is already at EOF.
        N)rrRrrrrSr_s  rrRz
ZstdFile.readsU	)<$$T***	)	)	)Z((((((	)$AAc|dkrt}	|j|S#t$r|t
YdSwxYw)zRead up to size uncompressed bytes, while trying to avoid
        making multiple reads from the underlying stream. Reads up to a
        buffer's worth of data if size is negative.

        Returns b"" if the file is at EOF.
        rN)rfrread1rrrrs  rrzZstdFile.read1se!88D	)<%%d+++	)	)	)Z((((((	)s)$AAc	|j|S#t$r|tYdSwxYw)zRRead bytes into b.

        Returns the number of bytes read (0 for EOF).
        N)rreadintorrrrSrzs  rrzZstdFile.readintosU
	)<((+++	)	)	)Z((((((	)rc	|j|S#t$r|tYdSwxYw)zRead bytes into b, while trying to avoid making multiple reads
        from the underlying stream.

        Returns the number of bytes read (0 for EOF).
        N)r	readinto1rrrrs  rrzZstdFile.readinto1sU	)<))!,,,	)	)	)Z((((((	)rc	|j|S#t$r|tYdSwxYw)a
Read a line of uncompressed bytes from the file.

        The terminating newline (if present) is retained. If size is
        non-negative, no more than size bytes will be read (in which
        case the line may be incomplete). Returns b'' if already at EOF.
        N)rreadlinerrrrs  rrzZstdFile.readlinesU	)<((...	)	)	)Z((((((	)rc	|j||S#t$r|tYdSwxYw)aChange the file position.

        The new position is specified by offset, relative to the
        position indicated by whence. Possible values for whence are:

            0: start of stream (default): offset must not be negative
            1: current stream position
            2: end of stream; offset must not be positive

        Returns the new file position.

        Note that seeking is emulated, so depending on the arguments,
        this operation may be extremely slow.
        N)rrlrrr)rSrjrks   rrlz
ZstdFile.seeksW	)<$$VV444	)	)	)Z((((((	)s$AAc	|j|S#t$r|tYdSwxYw)zReturn buffered data without advancing the file position.

        Always returns at least one byte of data, unless at EOF.
        The exact number of bytes returned is unspecified.
        N)rpeekrrrrs  rrz
ZstdFile.peek3sU	)<$$T***	)	)	)Z((((((	)rc|jtkr|jS|jtkr|jS|dS)z!Return the current file position.N)rrrtellrr\rrs rrz
ZstdFile.tell@sR:##<$$&&&
Z;
&
&9	
r
c	|jS#t$r|YdSwxYw)z3Return the file descriptor for the underlying file.N)rZfilenorrrs rrzZstdFile.filenoJsO	8??$$$				s==c"|jtkS)zTrue if this file is closed.)rrrs rclosedzZstdFile.closedRsz\))r
cv|jtkrdS|jtkrdS|dS)z/Return whether the file was opened for writing.TFN)rrrrrs rwritablezZstdFile.writableWs@:$$4
Z:
%
%5	
r
cv|jtkrdS|jtkrdS|dS)z/Return whether the file was opened for reading.TFN)rrrrrs rreadablezZstdFile.readableas@:##4
Z;
&
&5	
r
c|jtkr|jS|jtkrdS|dS)z)Return whether the file supports seeking.FN)rrrseekablerrrs rrzZstdFile.seekableksO:##<((***
Z;
&
&5	
r
)rpr2rm)rrr__doc__rrrr{rrRrrrrrbrcrlrrrpropertyrrrrr	r
rr#r#$syD;!%D;D;D;D;D;L***D <>	)	)	)	)
)
)
)
))))	)	)	)
)
)
)
)#%+))))*))))**X*r
r#rs)r-r.encodingerrorsnewlinec*d|vrd|vrtd|n3|td|td|td|dd}t||||	}d|vrtj||||S|S)
a]Open a zstd compressed file in binary or text mode.

    filename can be either an actual file name (given as a str, bytes, or
    PathLike object), in which case the named file is opened, or it can be an
    existing file object to read from or write to.

    The mode parameter can be "r", "rb" (default), "w", "wb", "x", "xb", "a",
    "ab" for binary mode, or "rt", "wt", "xt", "at" for text mode.

    The level_or_option and zstd_dict parameters specify the settings, as for
    ZstdCompressor, ZstdDecompressor and ZstdFile.

    When using read mode (decompression), the level_or_option parameter can
    only be a dict object, that represents decompression option. It doesn't
    support int type compression level in this case.

    For binary mode, this function is equivalent to the ZstdFile constructor:
    ZstdFile(filename, mode, ...). In this case, the encoding, errors and
    newline parameters must not be provided.

    For text mode, an ZstdFile object is created, and wrapped in an
    io.TextIOWrapper instance with the specified encoding, error handling
    behavior, and line ending(s).
    trzzInvalid mode: Nz0Argument 'encoding' not supported in binary modez.Argument 'errors' not supported in binary modez/Argument 'newline' not supported in binary moderq)rAreplacer#rb
TextIOWrapper)	rrr-r.rrr	zstd_modebinary_files	         rr$r$ws6d{{$;;*449:::OPPPMNNNNOOOS"%%I8Y+:iQQQKd{{XvwGGGr
)NN)rs)_compressionrbsysrosrImportError
c.c_pyzstdrrrcffi.cffi_pyzstdCFFI_PYZSTD__version__r__all__rrr:rr rfDecompressReaderrPrrrBufferedIOBaser#r$r	r
r<module>rs				














P00000000000PPPP''''	:	:	:	:	:	:	:	:	:	:PPPk
OPP	PP	
P)B
;
;
;
; &"""""">7"7"7"zKKKKK<8KKK\
&OOOOOr OOOf
-tT-------s3,,?A-AA-A''A-,A-
Back to Directory File Manager