U
    dZ                     @   sl  d Z ddlZddlmZ i Zi Zi ZdZd$ddZdd Z	d	d
 Z
dd Zdd Zdd Zeejejdddgd zddlZW n ek
r   Y nX eejejdddgd zddlZW n ek
r   Y nX eejejddgd zddlZW n ek
r   Y nX eejejdddgd zddlZW n ek
rB   Y n&X dd Zdd  Zeeed!d"d#gd dS )%zCompression utilities.    N)ensure_bytes)registerencodersget_encoderget_decodercompress
decompressc                    s0   | t  < |t < |r,t fdd|D  dS )a  Register new compression method.

    Arguments:
        encoder (Callable): Function used to compress text.
        decoder (Callable): Function used to decompress previously
            compressed text.
        content_type (str): The mime type this compression method
            identifies as.
        aliases (Sequence[str]): A list of names to associate with
            this compression method.
    c                 3   s   | ]}| fV  qd S N ).0aliascontent_typer
   5/tmp/pip-unpacked-wheel-hqfrjlvz/kombu/compression.py	<genexpr>   s     zregister.<locals>.<genexpr>N)	_encoders	_decoders_aliasesupdate)encoderdecoderr   aliasesr
   r   r   r      s    r   c                   C   s   t tS )z/Return a list of available compression methods.)listr   r
   r
   r
   r   r   !   s    r   c                 C   s   t | | } t|  | fS )zGet encoder by alias name.)r   getr   tr
   r
   r   r   &   s    r   c                 C   s   t t| |  S )zGet decoder by alias name.)r   r   r   r   r
   r
   r   r   ,   s    r   c                 C   s   t |\}}|t| |fS )zCompress text.

    Arguments:
        body (AnyStr): The text to compress.
        content_type (str): mime-type of compression method to use.
    )r   r   )bodyr   r   r
   r
   r   r   1   s    r   c                 C   s   t || S )zDecompress compressed text.

    Arguments:
        body (AnyStr): Previously compressed text to uncompress.
        content_type (str): mime-type of compression method used.
    )r   )r   r   r
   r
   r   r   <   s    r   zapplication/x-gzipgzipzlib)r   zapplication/x-bz2bzip2Zbzipzapplication/x-brotlibrotlizapplication/x-lzmalzmaxzc                 C   s   t  }|| S r	   )zstdZZstdCompressorr   )r   cr
   r
   r   zstd_compressj   s    r%   c                 C   s   t  }|| S r	   )r#   ZZstdDecompressorr   )r   dr
   r
   r   zstd_decompressn   s    r'   zapplication/zstdr#   	zstandard)N)__doc__r   Zkombu.utils.encodingr   r   r   r   __all__r   r   r   r   r   r   bz2ImportErrorr    r!   r(   r#   r%   r'   r
   r
   r
   r   <module>   sn   

     