o
    RÊÆhO  ã                   @   sØ   d dl Z d dlZd dlmZ d dlmZmZ zzd dlZW n e	y*   d dlZY nw dZ
W n e	y9   dZ
Y nw 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)ÚOptionalÚcastTFi   ÚencodingÚsuppress_deflate_headerÚreturnc                 C   s$   | dkr	dt j S |rt j S t jS )NÚgzipé   )ÚzlibÚ	MAX_WBITS)r   r   © r   úf/var/www/html/HyperOracle/crypto_trader/venv/lib/python3.10/site-packages/aiohttp/compression_utils.pyÚ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 )ÚZlibBaseHandlerNÚmodeÚexecutorÚmax_sync_chunk_sizec                 C   s   || _ || _|| _d S ©N)Ú_modeÚ	_executorÚ_max_sync_chunk_size)Úselfr   r   r   r   r   r   Ú__init__   s   
zZlibBaseHandler.__init__)Ú__name__Ú
__module__Ú__qualname__ÚMAX_SYNC_CHUNK_SIZEÚintr   r   r   r   r   r   r   r      s    üþýür   c                       sœ   e Zd Zddddejdefdee dedee	 dee	 d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ejfde	defdd„Z‡  ZS )ÚZLibCompressorNFr   r   ÚlevelÚwbitsÚstrategyr   r   c                    sZ   t ƒ j|d u rt||ƒn|||d� |d u r!tj| j|d�| _d S tj| j||d�| _d S )N©r   r   r   )r    r!   )r    r!   r   )Úsuperr   r   r
   Úcompressobjr   Ú_compressor)r   r   r   r   r    r!   r   r   ©Ú	__class__r   r   r   *   s   

ÿûÿzZLibCompressor.__init__Údatar   c                 C   ó   | j  |¡S r   )r%   Úcompress©r   r(   r   r   r   Úcompress_syncB   ó   zZLibCompressor.compress_syncc                 Ã   s@   �| j d urt|ƒ| j krt ¡  | j| j|¡I d H S |  |¡S r   )r   ÚlenÚasyncioÚget_event_loopÚrun_in_executorr   r,   r+   r   r   r   r*   E   s   €


ÿ
zZLibCompressor.compressr   c                 C   r)   r   )r%   Úflush)r   r   r   r   r   r2   O   r-   zZLibCompressor.flush)r   r   r   r
   ÚZ_DEFAULT_STRATEGYr   r   ÚstrÚboolr   r   r   Úbytesr,   r*   ÚZ_FINISHr2   Ú__classcell__r   r   r&   r   r   )   s4    øþýüûúùø 
r   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ede
fdd„ƒZede
fdd„ƒZ‡  ZS )ÚZLibDecompressorNFr   r   r   r   c                    s,   t ƒ jt||ƒ||d� tj| jd�| _d S )Nr"   )r    )r#   r   r   r
   Údecompressobjr   Ú_decompressor)r   r   r   r   r   r&   r   r   r   T   s   ýzZLibDecompressor.__init__r   r(   Ú
max_lengthr   c                 C   s   | j  ||¡S r   )r;   Ú
decompress©r   r(   r<   r   r   r   Údecompress_syncb   s   z ZLibDecompressor.decompress_syncc                 Ã   sD   �| j d urt|ƒ| j krt ¡  | j| j||¡I d H S |  ||¡S r   )r   r.   r/   r0   r1   r   r?   r>   r   r   r   r=   e   s   €

ÿzZLibDecompressor.decompressÚlengthc                 C   s   |dkr
| j  |¡S | j  ¡ S )Nr   )r;   r2   )r   r@   r   r   r   r2   o   s
   
ÿÿýzZLibDecompressor.flushc                 C   ó   | j jS r   )r;   Úeof©r   r   r   r   rB   v   ó   zZLibDecompressor.eofc                 C   rA   r   )r;   Úunconsumed_tailrC   r   r   r   rE   z   rD   z ZLibDecompressor.unconsumed_tailc                 C   rA   r   )r;   Úunused_datarC   r   r   r   rF   ~   rD   zZLibDecompressor.unused_data)r   )r   r   r   r   r   r4   r5   r   r   r   r6   r?   r=   r2   ÚpropertyrB   rE   rF   r8   r   r   r&   r   r9   S   s.    ûþýüû
r9   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Ú_objrC   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=   )ÚhasattrrM   r   r6   r=   Úprocessr+   r   r   r   r?   �   s   z"BrotliDecompressor.decompress_syncc                 C   s    t | jdƒrtt| j ¡ ƒS dS )Nr2   ó    )rN   rM   r   r6   r2   rC   r   r   r   r2   ”   s   zBrotliDecompressor.flush)r   N)r   r   r   r   r6   r?   r2   r   r   r   r   rH   ƒ   s    
rH   )NF)r/   r
   Úconcurrent.futuresr   Útypingr   r   Ú
brotlicffirK   ÚImportErrorrI   r   r4   r5   r   r   r   r   r9   rH   r   r   r   r   Ú<module>   s8    ÿÿþÿþ
ý
*0