a
    ”˜ëjC  ã                   @   s¸  d Z ddlmZmZ ddlZddlZddlZddlZddlZej	dkrTddl
mZ nddlmZ ej dd¡ ¡ Zedkràe ¡ d	v r”d
dlT dZnJe ¡ dv r®d
dlT dZn0zd
dlT dZW n eyÜ   d
dlT dZY n0 n’edk�rzd
dlT dZW n  e�y   d
dlT dZY n0 nTedk�r6d
dlT dZn<edk�rNd
dlT dZn$edk�rfd
dlT dZnede ƒ‚dZdZd
ZdZddd„Zdeeedœdd„Zd eeedœdd„Z dS )!z=Python interface to the Zstandard (zstd) compression library.é    )Úabsolute_importÚunicode_literalsN)é   é   )ÚBuffer)Ú
ByteStringZPYTHON_ZSTANDARD_IMPORT_POLICYÚdefault)ÚCPythoné   )Ú*Zcext)ÚPyPyZcffiZcffi_fallbackZrustzKunknown module import policy: %s; use default, cffi_fallback, cext, or cffiz0.25.0é   Úrbc                 C   s&  |  dd¡}|dv r(|ptƒ }d}	d}
n<|dv rV|p8tƒ }d}	|}
|
 d¡sd|
d }
ntd	 |¡ƒ‚ttd
ƒr|tt	tj
f}ntt	f}t| |ƒr t | |
¡}d}n*t| dƒs´t| dƒrÂ| }t|ƒ}ntdƒ‚|	dkrâ|j||d�}n |	dkrú|j||d�}ntdƒ‚d|v�rtj||||d�S |S dS )a¹  Create a file object with zstd (de)compression.

    The object returned from this function will be a
    :py:class:`ZstdDecompressionReader` if opened for reading in binary mode,
    a :py:class:`ZstdCompressionWriter` if opened for writing in binary mode,
    or an ``io.TextIOWrapper`` if opened for reading or writing in text mode.

    :param filename:
       ``bytes``, ``str``, or ``os.PathLike`` defining a file to open or a
       file object (with a ``read()`` or ``write()`` method).
    :param mode:
       ``str`` File open mode. Accepts any of the open modes recognized by
       ``open()``.
    :param cctx:
       ``ZstdCompressor`` to use for compression. If not specified and file
       is opened for writing, the default ``ZstdCompressor`` will be used.
    :param dctx:
       ``ZstdDecompressor`` to use for decompression. If not specified and file
       is opened for reading, the default ``ZstdDecompressor`` will be used.
    :param encoding:
        ``str`` that defines text encoding to use when file is opened in text
        mode.
    :param errors:
       ``str`` defining text encoding error handling mode.
    :param newline:
       ``str`` defining newline to use in text mode.
    :param closefd:
       ``bool`` whether to close the file when the returned object is closed.
        Only used if a file object is passed. If a filename is specified, the
        opened file is always closed when the returned object is closed.
    ÚtÚ )Úrr   r   r   )ÚwÚwbÚaÚabÚxÚxbr   ÚbzInvalid mode: {!r}ÚPathLikeTÚreadÚwritez6filename must be a str, bytes, file or PathLike object)Úclosefdz2logic error in zstandard.open() handling open mode)ÚencodingÚerrorsÚnewlineN)ÚreplaceÚZstdDecompressorÚZstdCompressorÚendswithÚ
ValueErrorÚformatÚhasattrÚosÚstrÚbytesr   Ú
isinstanceÚbuiltinsÚopenÚboolÚ	TypeErrorZstream_readerZstream_writerÚRuntimeErrorÚioÚTextIOWrapper)ÚfilenameÚmodeÚcctxÚdctxr   r   r   r   Znormalized_modeZ	open_modeZraw_open_modeÚtypesZinner_fhÚfh© r8   úQ/mnt/bigstor/www/usecases/.venv/lib/python3.9/site-packages/zstandard/__init__.pyr,   a   sD    )






ÿ
ÿr,   r   )ÚdataÚlevelÚreturnc                 C   s   t |d�}| | ¡S )aÌ  Compress source data using the zstd compression format.

    This performs one-shot compression using basic/default compression
    settings.

    This method is provided for convenience and is equivalent to calling
    ``ZstdCompressor(level=level).compress(data)``.

    If you find yourself calling this function in a tight loop,
    performance will be greater if you construct a single ``ZstdCompressor``
    and repeatedly call ``compress()`` on it.
    )r;   )r"   Úcompress)r:   r;   r4   r8   r8   r9   r=   ¸   s    
r=   )r:   Úmax_output_sizer<   c                 C   s   t ƒ }|j| |d�S )aä  Decompress a zstd frame into its original data.

    This performs one-shot decompression using basic/default compression
    settings.

    This method is provided for convenience and is equivalent to calling
    ``ZstdDecompressor().decompress(data, max_output_size=max_output_size)``.

    If you find yourself calling this function in a tight loop, performance
    will be greater if you construct a single ``ZstdDecompressor`` and
    repeatedly call ``decompress()`` on it.
    )r>   )r!   Ú
decompress)r:   r>   r5   r8   r8   r9   r?   Ê   s    r?   )r   NNNNNN)r   )r   )!Ú__doc__Ú
__future__r   r   r+   r0   r'   ÚplatformÚsysÚversion_infoÚcollections.abcr   Útypingr   ÚenvironÚgetÚstripZ_module_policyÚpython_implementationZ	backend_cÚbackendZbackend_cffiÚImportErrorZbackend_rustÚ__version__Ú_MODE_CLOSEDÚ
_MODE_READÚ_MODE_WRITEr,   Úintr)   r=   r?   r8   r8   r8   r9   Ú<module>	   sx   
ÿ



ÿÿ       ø
W