
    [j                       d dl mZ d dlZd dlmZmZmZmZ 	 d dlZdZ	n# e
$ r dZ	Y nw xY w	 d dlZdZn# e
$ r dZY nw xY w	 d dlmZmZ dZn# e
$ r dZY nw xY wd dlmZ d dlmZ h d	Zej        ej        hZe                    e           d!dZd"dZ G d d          Z G d d          Z G d d          Z G d d          Zd#d Z dS )$    )annotationsN)AnyIterableOptionalUnionTF)ZstdCompressorZstdDecompressor)HelloCompat)_SENSITIVE_COMMANDS>   zlibzstdsnappydummyr   valueUnion[str, Iterable[str]]return	list[str]c                P   	 |                     d          }n# t          $ r t          |          }Y nw xY w|d d          D ]}|t          vr/|                    |           t          j        d| d           :|dk    r3t          s,|                    |           t          j        dd           s|dk    r3t          s,|                    |           t          j        dd           |d	k    r2t          s+|                    |           t          j        d
d           |S )N,zUnsupported compressor:    )
stacklevelr   zuWire protocol compression with snappy is not available. You must install the python-snappy module for snappy support.r   zWWire protocol compression with zlib is not available. The zlib module is not available.r   zwWire protocol compression with zstandard is not available. You must install the zstandard module for zstandard support.)
splitAttributeErrorlist_SUPPORTED_COMPRESSORSremovewarningswarn_HAVE_SNAPPY
_HAVE_ZLIB
_HAVE_ZSTD)r   r   compressors
compressors       _/var/www/app.qaans.com/backend/venv/lib/python3.11/site-packages/pymongo/compression_support.pyvalidate_compressorsr%   2   s   "kk#&& " " "5kk" "!!!n  
333z***MAZAAaPPPPP8##L#z***MP    
 6!!*!z***M4    
 6!!*!z***MO   
 s    44optionstrintc                    	 t          |          }n$# t          $ r t          |  d|d          d w xY w|dk     s|dk    rt          d| |fz            |S )Nz must be an integer, not .	   z$%s must be between -1 and 9, not %d.)r(   	Exception	TypeError
ValueError)r&   r   levels      r$   validate_zlib_compression_levelr1   V   s    RE

 R R R6FFEFFFGGTQRrzzUQYY?65/QRRRLs    !3c                      e Zd ZddZdd	Zd
S )CompressionSettingsr"   r   zlib_compression_levelr(   c                "    || _         || _        d S N)r"   r4   )selfr"   r4   s      r$   __init__zCompressionSettings.__init__a   s    &&<###    Optional[list[str]]r   4Union[SnappyContext, ZlibContext, ZstdContext, None]c                    |rL|d         }|dk    rt                      S |dk    rt          | j                  S |dk    rt                      S d S d S )Nr   r   r   r   )SnappyContextZlibContextr4   ZstdContext)r7   r"   chosens      r$   get_compression_contextz+CompressionSettings.get_compression_contexte   se      	 ^F!!$&6!!"4#>???6!!"}}$4tr9   N)r"   r   r4   r(   )r"   r:   r   r;   )__name__
__module____qualname__r8   rA    r9   r$   r3   r3   `   s<        = = = =     r9   r3   c                  *    e Zd ZdZedd            ZdS )r=      databytesr   c                *    t          j        |           S r6   )r   compressrH   s    r$   rK   zSnappyContext.compressw   s    t$$$r9   NrH   rI   r   rI   rB   rC   rD   compressor_idstaticmethodrK   rE   r9   r$   r=   r=   t   s7        M% % % \% % %r9   r=   c                  "    e Zd ZdZd
dZddZd	S )r>   r   r0   r(   c                    || _         d S r6   )r0   )r7   r0   s     r$   r8   zZlibContext.__init__   s    


r9   rH   rI   r   c                6    t          j        || j                  S r6   )r   rK   r0   )r7   rH   s     r$   rK   zZlibContext.compress   s    }T4:...r9   N)r0   r(   rM   )rB   rC   rD   rO   r8   rK   rE   r9   r$   r>   r>   |   sA        M   / / / / / /r9   r>   c                  *    e Zd ZdZedd            ZdS )r?      rH   rI   r   c                D    t                                          |           S r6   )r   rK   rL   s    r$   rK   zZstdContext.compress   s     ((...r9   NrM   rN   rE   r9   r$   r?   r?      s7        M/ / / \/ / /r9   r?   rH   rI   rO   c                4   |t           j        k    r!t          j        t	          |                     S |t
          j        k    rt          j        |           S |t          j        k    r!t                                          |           S t          d|fz            )NzUnknown compressorId %d)r=   rO   r   
uncompressrI   r>   r   
decompressr?   r	   r/   )rH   rO   s     r$   rY   rY      s    333
  t---	+3	3	3t$$$	+3	3	3  !!,,T2222m5EEFFFr9   )r   r   r   r   r   r   )r&   r'   r   r   r   r(   )rH   rI   rO   r(   r   rI   )!
__future__r   r   typingr   r   r   r   r   r   ImportErrorr   r    	zstandardr   r	   r!   pymongo.hellor
   pymongo.monitoringr   r   CMD
LEGACY_CMD_NO_COMPRESSIONupdater%   r1   r3   r=   r>   r?   rY   rE   r9   r$   <module>rd      sC   # " " " " "  1 1 1 1 1 1 1 1 1 1 1 1MMMLL   LLLKKKJJ   JJJ::::::::JJ   JJJ & % % % % % 2 2 2 2 2 2333 ?K$:;   * + + +! ! ! !H          (% % % % % % % %/ / / / / / / // / / / / / / /G G G G G Gs*    ))4 >>
A AA