
    ^jX                         d dl mZ d dlZ G d de          Z G d de          Z G d de          Z G d	 d
e          ZdefdZ G d de          Z	dS )    )ProtocolNc                       e Zd ZdZdS )DecodeRatioErrorzBOutput-to-input amplification ratio exceeded the configured limit.N__name__
__module____qualname____doc__     S/var/www/app.qaans.com/backend/venv/lib/python3.11/site-packages/httplib2/decode.pyr   r      s        LLLLr   r   c                       e Zd ZdZdS )DecodeLimitErrorz,Total output length exceeded the hard limit.Nr   r   r   r   r   r   	   s        6666r   r   c                   \    e Zd Zedefd            ZdedefdZdefdZddede	defd	Z
d
S )DecoderProtocolreturnc                     d S Nr   selfs    r   needs_inputzDecoderProtocol.needs_input   s    r   bc                     d S r   r   r   r   s     r   decodezDecoderProtocol.decode       r   c                     d S r   r   r   s    r   flushzDecoderProtocol.flush   r   r      data
chunk_sizec                 `   t                      }|dk    rt          |          }t          dt          |          |          D ]7}||||z            }|                    |                     |                     8|                    |                                            t          |          S )Nr   )	bytearraylenrangeextendr   r   bytes)r   r    r!   outichunks         r   consume_byteszDecoderProtocol.consume_bytes   s    kk??TJq#d))Z00 	+ 	+AQ^+,EJJt{{5))****

4::<<   Szzr   N)r   )r   r   r	   propertyboolr   r'   r   r   intr+   r   r   r   r   r      s        T    X %    u     % S       r   r   c                   n    e Zd ZdZdZdZdZdZdZefde	fdZ
ed	efd
            Zded	efdZd	efdZdS )ZlibDecodera#  
    Thin wrapper around zlib.Decompressor conforming to the Decoder interface.

    Note: zlib pushes all available decompressed data immediately upon receiving
    input. It never holds back output requiring `decode(b"")` to extract it.
    Thus, `needs_input` naturally remains True.
    )_decoderi      /   wbitsc                 8    t          j        |          | _        d S r   )zlibdecompressobjr1   )r   r5   s     r   __init__zZlibDecoder.__init__3   s    151CE1J1Jr   r   c                 H    | j         t          d          | j         j         S Nzused after flush())r1   RuntimeErroreofr   s    r   r   zZlibDecoder.needs_input6   s'    = 3444=$$$r   r   c                 b    | j         t          d          | j                             |          S r;   )r1   r<   
decompressr   s     r   r   zZlibDecoder.decode<   s/    = 3444}''***r   c                 r    | j         t          d          | j                                         }d | _         |S r;   )r1   r<   r   )r   results     r   r   zZlibDecoder.flushA   s8    = 3444$$&&r   N)r   r   r	   r
   	__slots__WBITS_DEFLATE
WBITS_ZLIB
WBITS_GZIPWBITS_AUTO_GZIP_ZLIBr.   r9   r,   r-   r   r'   r   r   r   r   r   r0   r0   #   s          IMJJ"$8 K Kc K K K K %T % % % X%
+ +% + + + +
u      r   r0   r   c                  4    t          t           j                  S r   )r0   rC   r   r   r   DeflateDecoderrH   I   s    {0111r   c                       e Zd ZdZ	 	 	 	 ddededed	ed
eddfdZddZe	de
fd            ZdedefdZdefdZdedefdZdS )LimitDecoder)	r1   _ratio_chunk_size_safe_limit_hard_limit_consumed_length_output_length_input_buffer_flushedd   r             
 decoderratior!   
safe_limit
hard_limitr   Nc                 d   |dk     rt          d| d          |dk     rt          d| d          |dk     rt          d| d          |dk     rt          d| d          || _        || _        || _        || _        || _        d| _        d| _        t                      | _	        d| _
        d S )Nr   zLimitDecoder() ratio=z expected >= 0zLimitDecoder() chunk_size=zLimitDecoder() safe_limit=F)
ValueErrorr1   rK   rL   rM   rN   rO   rP   r#   rQ   rR   )r   rV   rW   r!   rX   rY   s         r   r9   zLimitDecoder.__init__Z   s     199JUJJJKKK>>T*TTTUUU>>T*TTTUUU>>T*TTTUUU)0" * * *%&#$(1#r   c           
         | j         dk    r/| j        | j         k    rt          d| j         d| j                    | j        dk    r| j        | j        k     rd S | j        dk    rl| j        | j        | j        z  k    rV| j        dk    r| j        | j        z  nt          d          }t          d|dd| j         d| j         d	| j                   d S d S )
Nr   zOutput length z exceeds hard limit infzAmplification ratio z.1fz (/z) exceeds limit )rN   rP   r   rM   rK   rO   floatr   )r   actual_ratios     r   _check_limitszLimitDecoder._check_limitsu   s   q  t':T=M'M'M"#oD4G#o#o]a]m#o#opppq  t':T=M'M'MFK!OO$"58MPTP[8["["[JNJ_bcJcJc4.1FFFinotiuiuL"0|i 0 04;N 0 0QUQf 0 0"&+0 0   O"["[r   c                     | j         j        S r   )r1   r   r   s    r   r   zLimitDecoder.needs_input   s    }((r   r   c                 v    | j         rt          d          |                     |          }t          |          S )Nzdecode() called after flush())rR   r<   _pumpr'   )r   r   outputs      r   r   zLimitDecoder.decode   s7    = 	@>???AV}}r   c                 B   | j         rt          d          d| _         |                     d          }| j                                        }|                    |           | xj        t          |          z  c_        |                                  t          |          S )Nzflush() called more than onceTr   )
rR   r<   rd   r1   r   r&   rP   r$   ra   r'   )r   re   r    s      r   r   zLimitDecoder.flush   s    = 	@>???C}""$$ds4yy(V}}r   c                    | j                             |           t                      }	 | j        j        sc| j                            d          }|rG|                    |           | xj        t          |          z  c_        |                                  p| j         rt          | j         d | j
                           }| j         d | j
        = | j                            |          }| xj        t          |          z  c_        |rF|                    |           | xj        t          |          z  c_        |                                  (	 |S )NTr   )rQ   r&   r#   r1   r   r   rP   r$   ra   r'   rL   rO   )r   r   re   r    r*   s        r   rd   zLimitDecoder._pump   sQ   !!!$$$	=, }++C00 MM$'''''3t994''&&(((! d01C43C1CDEE&'9)9'9:}++E22%%U3%% )MM$'''''3t994''&&((( r   )rS   r   rT   rU   )r   N)r   r   r	   rB   r   r_   r.   r9   ra   r,   r-   r   r'   r   r   r#   rd   r   r   r   rJ   rJ   M   s       
I """$ $ $ $ 	$
 $ $ 
$ $ $ $6
 
 
 
 )T ) ) ) X) %    u    u       r   rJ   )
typingr   r7   	Exceptionr   r   r   r0   rH   rJ   r   r   r   <module>rj      s*         M M M M My M M M7 7 7 7 7y 7 7 7    h   ,# # # # #/ # # #L2 2 2 2 2j j j j j? j j j j jr   