o
    Df                     @  sn  d Z ddlm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yN   Y nw e
ejejdddgd zddlZW n	 eyj   Y nw e
ejejddgd zddlZW n	 ey   Y nw e
ejejdddgd zddlZW n
 ey   Y dS w dd Zd d! Ze
eed"d#d$gd dS )&zCompression utilities.    )annotationsN)ensure_bytes)registerencodersget_encoderget_decodercompress
decompressc                   s4   | t  < |t < |rt fdd|D  dS 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   J/home/ubuntu/webapp/venv/lib/python3.10/site-packages/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   4   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bzip2bzipzapplication/x-brotlibrotlizapplication/x-lzmalzmaxzc                 C     t  }|| S r
   )zstdZstdCompressorr   )r   cr   r   r   zstd_compresso      
r)   c                 C  r%   r
   )r&   ZstdDecompressorr	   )r   dr   r   r   zstd_decompresss   r*   r-   zapplication/zstdr&   	zstandardr
   )__doc__
__future__r   r   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>   sp    

