o
    Fh"                     @   s  U d dl Z d dlZd dlZd dlmZ d dlmZmZmZm	Z	m
Z
mZ ejdkr/d dlmZ nd dlmZ eeeddf Zzzd dlZW n eyQ   d dlZY nw d	ZW n ey`   d
ZY nw dZG dd de	ZG dd de	ZG dd de	ZG dd de
d
dZG dd dZeeZeed< deddfddZ		
d(dee de de!fddZ"G d d! d!Z#G d"d# d#e#Z$G d$d% d%e#Z%G d&d' d'Z&dS ))    N)Executor)AnyFinalOptionalProtocol	TypedDictcast)      )Buffer)Unionzmemoryview[int]zmemoryview[bytes]TFi   c                   @   s2   e Zd ZdedefddZd
dedefddZd	S )ZLibCompressObjProtocoldatareturnc                 C      d S N selfr   r   r   L/var/www/html/venv/lib/python3.10/site-packages/aiohttp/compression_utils.pycompress       z ZLibCompressObjProtocol.compress.modec                C   r   r   r   r   r   r   r   r   flush   r   zZLibCompressObjProtocol.flushN.)__name__
__module____qualname__r   bytesr   intr   r   r   r   r   r      s    r   c                   @   sJ   e Zd ZddededefddZddedefdd	Zede	fd
dZ
dS )ZLibDecompressObjProtocol.r   
max_lengthr   c                 C   r   r   r   r   r   r"   r   r   r   
decompress!   r   z$ZLibDecompressObjProtocol.decompresslengthc                C   r   r   r   r   r%   r   r   r   r   "   r   zZLibDecompressObjProtocol.flushc                 C   r   r   r   r   r   r   r   eof$   s   zZLibDecompressObjProtocol.eofNr   )r   r   r   r   r    r   r$   r   propertyboolr(   r   r   r   r   r!       s
    r!   c                   @   s   e Zd ZU eed< eed< eed< eed< eed< 						ddeded	ed
ededee defddZ	dd	edede	fddZ
	dded	ededefddZ	dd	edededefddZdS )ZLibBackendProtocol	MAX_WBITSZ_FULL_FLUSHZ_SYNC_FLUSHZ_BEST_SPEEDZ_FINISH.levelmethodwbitsmemLevelstrategyzdictr   c                 C   r   r   r   )r   r1   r2   r3   r4   r5   r6   r   r   r   compressobj/   s   zZLibBackendProtocol.compressobjc                 C   r   r   r   )r   r3   r6   r   r   r   decompressobj8      z!ZLibBackendProtocol.decompressobjr   c                C   r   r   r   )r   r   r1   r3   r   r   r   r   <   r9   zZLibBackendProtocol.compressbufsizec                C   r   r   r   )r   r   r3   r:   r   r   r   r$   ?   r9   zZLibBackendProtocol.decompressN)......)..)r   r   r   r    __annotations__r   r   r   r7   r!   r8   r   r   r$   r   r   r   r   r+   (   sn   
 



r+   c                   @   s&   e Zd ZU eed< eed< eed< dS )CompressObjArgsr3   r5   r1   N)r   r   r   r    r;   r   r   r   r   r<   D   s   
 r<   )totalc                   @   s   e Zd ZdefddZedefddZedefddZ	edefd	d
Z
edefddZedefddZedefddZdededefddZdededefddZdedededefddZdedededefddZdedefddZdS ) ZLibBackendWrapper_zlib_backendc                 C   s
   || _ d S r   )r?   )r   r?   r   r   r   __init__K      
zZLibBackendWrapper.__init__r   c                 C   s   t | jddS )Nr   	undefinedgetattrr?   r'   r   r   r   nameN   s   zZLibBackendWrapper.namec                 C      | j jS r   )r?   r,   r'   r   r   r   r,   R      zZLibBackendWrapper.MAX_WBITSc                 C   rF   r   )r?   r-   r'   r   r   r   r-   V   rG   zZLibBackendWrapper.Z_FULL_FLUSHc                 C   rF   r   )r?   r.   r'   r   r   r   r.   Z   rG   zZLibBackendWrapper.Z_SYNC_FLUSHc                 C   rF   r   )r?   r/   r'   r   r   r   r/   ^   rG   zZLibBackendWrapper.Z_BEST_SPEEDc                 C   rF   r   )r?   r0   r'   r   r   r   r0   b   rG   zZLibBackendWrapper.Z_FINISHargskwargsc                 O      | j j|i |S r   )r?   r7   r   rH   rI   r   r   r   r7   f      zZLibBackendWrapper.compressobjc                 O   rJ   r   )r?   r8   rK   r   r   r   r8   i   rL   z ZLibBackendWrapper.decompressobjr   c                 O      | j j|g|R i |S r   )r?   r   r   r   rH   rI   r   r   r   r   l      zZLibBackendWrapper.compressc                 O   rM   r   )r?   r$   rN   r   r   r   r$   o   rO   zZLibBackendWrapper.decompressattrnamec                 C   s   t | j|S r   rC   )r   rP   r   r   r   __getattr__s      zZLibBackendWrapper.__getattr__N)r   r   r   r+   r@   r)   strrE   r    r,   r-   r.   r/   r0   r   r   r7   r!   r8   r   r   r   r$   rQ   r   r   r   r   r>   J   s&    r>   ZLibBackendnew_zlib_backendr   c                 C   s
   | t _d S r   )rT   r?   )rU   r   r   r   set_zlib_backendz   rA   rV   encodingsuppress_deflate_headerc                 C   s$   | dkr	dt j S |rt j S t jS )Ngzip   )rT   r,   )rW   rX   r   r   r   encoding_to_mode~   s   
r[   c                   @   s0   e Zd Zdefdedee dee fddZdS )ZlibBaseHandlerNr   executormax_sync_chunk_sizec                 C   s   || _ || _|| _d S r   )_mode	_executor_max_sync_chunk_size)r   r   r]   r^   r   r   r   r@      s   
zZlibBaseHandler.__init__)r   r   r   MAX_SYNC_CHUNK_SIZEr    r   r   r@   r   r   r   r   r\      s    r\   c                       s   e Zd Zddddddefdee dedee dee dee dee d	ee f fd
dZ	de
de
fddZde
de
fddZddee de
fddZ  ZS )ZLibCompressorNFrW   rX   r1   r3   r5   r]   r^   c           	         s   t  j|d u rt||n|||d ttj| _i }| j|d< |d ur'||d< |d ur/||d< | jjdi || _t	
 | _d S )Nr   r]   r^   r3   r5   r1   r   )superr@   r[   r>   rT   r?   r_   r7   _compressorasyncioLock_compress_lock)	r   rW   rX   r1   r3   r5   r]   r^   rI   	__class__r   r   r@      s    

	
zZLibCompressor.__init__r   r   c                 C   s   | j |S r   )rf   r   r   r   r   r   compress_sync   rR   zZLibCompressor.compress_syncc              	      s   | j 4 I dH 5 | jdur.t|| jkr.t | j| jj|I dH W  d  I dH  S | 	|W  d  I dH  S 1 I dH sCw   Y  dS )aC  Compress the data and returned the compressed bytes.

        Note that flush() must be called after the last call to compress()

        If the data size is large than the max_sync_chunk_size, the compression
        will be done in the executor. Otherwise, the compression will be done
        in the event loop.
        N)
ri   ra   lenrg   get_running_looprun_in_executorr`   rf   r   rl   r   r   r   r   r      s   	
0zZLibCompressor.compressr   c                 C   s   | j |d ur
|S | jjS r   )rf   r   r?   r0   r   r   r   r   r      s
   
zZLibCompressor.flushr   )r   r   r   rb   r   rS   r*   r    r   r@   r   rl   r   r   __classcell__r   r   rj   r   rc      s4     rc   c                
       s   e Zd Zdddefdee dedee dee f fddZ	dd
e
dede
fddZdd
e
dede
fddZddede
fddZedefddZ  ZS )ZLibDecompressorNFrW   rX   r]   r^   c                    s:   t  jt||||d ttj| _| jj| jd| _d S )Nrd   )r3   )	re   r@   r[   r>   rT   r?   r8   r_   _decompressor)r   rW   rX   r]   r^   rj   r   r   r@      s   zZLibDecompressor.__init__r   r   r"   r   c                 C   s   | j ||S r   )rr   r$   r#   r   r   r   decompress_sync   s   z ZLibDecompressor.decompress_syncc                    sF   | j durt|| j krt | j| jj||I dH S | ||S )zDecompress the data and return the decompressed bytes.

        If the data size is large than the max_sync_chunk_size, the decompression
        will be done in the executor. Otherwise, the decompression will be done
        in the event loop.
        N)	ra   rm   rg   rn   ro   r`   rr   r$   rs   r#   r   r   r   r$      s   

zZLibDecompressor.decompressr%   c                 C   s   |dkr
| j |S | j  S )Nr   )rr   r   r&   r   r   r   r      s
   
zZLibDecompressor.flushc                 C   rF   r   )rr   r(   r'   r   r   r   r(      rG   zZLibDecompressor.eof)r   )r   r   r   rb   r   rS   r*   r   r    r@   r   rs   r$   r   r)   r(   rp   r   r   rj   r   rq      s&    rq   c                   @   s6   e Zd Zd
ddZdedefddZdefdd	ZdS )BrotliDecompressorr   Nc                 C   s   t stdt | _d S )NzIThe brotli decompression is not available. Please install `Brotli` module)
HAS_BROTLIRuntimeErrorbrotliDecompressor_objr'   r   r   r   r@     s
   zBrotliDecompressor.__init__r   c                 C   s0   t | jdrtt| j|S tt| j|S )Nr$   )hasattrry   r   r   r$   processr   r   r   r   rs     s   z"BrotliDecompressor.decompress_syncc                 C   s    t | jdrtt| j S dS )Nr       )rz   ry   r   r   r   r'   r   r   r   r     s   zBrotliDecompressor.flush)r   N)r   r   r   r@   r   rs   r   r   r   r   r   rt     s    
rt   )NF)'rg   syszlibconcurrent.futuresr   typingr   r   r   r   r   r   version_infocollections.abcr   r   r   	bytearray
brotlicffirw   ImportErrorru   rb   r   r!   r+   r<   r>   rT   r;   rV   rS   r*   r    r[   r\   rc   rq   rt   r   r   r   r   <module>   sP   
  
-

?/