
    @wjX                         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	y)    )ProtocolNc                       e Zd ZdZy)DecodeRatioErrorzBOutput-to-input amplification ratio exceeded the configured limit.N__name__
__module____qualname____doc__     M/root/dashboard-youtube/.venv/lib/python3.12/site-packages/httplib2/decode.pyr   r      s    Lr   r   c                       e Zd ZdZy)DecodeLimitErrorz,Total output length exceeded the hard limit.Nr   r   r   r   r   r   	   s    6r   r   c                   T    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
y	)DecoderProtocolreturnc                      y Nr   selfs    r   needs_inputzDecoderProtocol.needs_input   s    r   bc                      y r   r   r   r   s     r   decodezDecoderProtocol.decode       r   c                      y r   r   r   s    r   flushzDecoderProtocol.flush   r   r   data
chunk_sizec                    t               }|dk(  rt        |      }t        dt        |      |      D ]*  }||||z    }|j                  | j	                  |             , |j                  | j                                t        |      S )Nr   )	bytearraylenrangeextendr   r   bytes)r   r   r    outichunks         r   consume_byteszDecoderProtocol.consume_bytes   sx    k?TJq#d)Z0 	+AQ^,EJJt{{5)*	+ 	

4::< Szr   N)   )r   r   r	   propertyboolr   r&   r   r   intr*   r   r   r   r   r      sT    T   % u % S  r   r   c                   f    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y)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                  |      | _        y r   )zlibdecompressobjr1   )r   r5   s     r   __init__zZlibDecoder.__init__3   s    151C1CE1Jr   r   c                 ^    | j                   t        d      | j                   j                   S Nzused after flush())r1   RuntimeErroreofr   s    r   r   zZlibDecoder.needs_input6   s+    == 344==$$$$r   r   c                 f    | j                   t        d      | j                   j                  |      S r;   )r1   r<   
decompressr   s     r   r   zZlibDecoder.decode<   s-    == 344}}''**r   c                 v    | j                   t        d      | j                   j                         }d | _         |S r;   )r1   r<   r   )r   results     r   r   zZlibDecoder.flushA   s6    == 3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   #   sn     IMJJ"$8 Kc K %T % %
+ +% +
u r   r0   r   c                  4    t        t         j                        S r   )r0   rC   r   r   r   DeflateDecoderrH   I   s    {00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y)LimitDecoder)	r1   _ratio_chunk_size_safe_limit_hard_limit_consumed_length_output_length_input_buffer_flusheddecoderratior    
safe_limit
hard_limitr   Nc                 2   |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| _
        y )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   rS   rT   r    rU   rV   s         r   r9   zLimitDecoder.__init__Z   s     194UG>JKK>9*^TUU>9*^TUU>9*^TUU)0" * * *%&#$(1#r   c           
      .   | j                   dkD  r>| j                  | j                   kD  r%t        d| j                   d| j                          | j                  dkD  r| j                  | j                  k  ry | j                  dkD  r| j                  | j
                  | j                  z  kD  ri| j
                  dkD  r| j                  | j
                  z  n
t        d      }t        d|dd| j                   d| j
                   d	| j                         y y )
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"^D4G4G3HH\]a]m]m\n#oppq t':':T=M=M'MKK!O$"5"58M8MPTP[P[8["[JNJ_J_bcJc4..1F1FFinotiuL"&|C&84;N;N:OqQUQfQfPg h""&++0  #\Or   c                 .    | j                   j                  S r   )r1   r   r   s    r   r   zLimitDecoder.needs_input   s    }}(((r   r   c                 h    | j                   rt        d      | j                  |      }t        |      S )Nzdecode() called after flush())rR   r<   _pumpr&   )r   r   outputs      r   r   zLimitDecoder.decode   s,    ==>??AV}r   c                 (   | j                   rt        d      d| _         | j                  d      }| j                  j	                         }|j                  |       | xj                  t        |      z  c_        | j                          t        |      S )Nzflush() called more than onceTr   )
rR   r<   ra   r1   r   r%   rP   r#   r^   r&   )r   rb   r   s      r   r   zLimitDecoder.flush   sr    ==>??C}}""$ds4y(V}r   c                    | j                   j                  |       t               }	 | j                  j                  s]| j                  j                  d      }|r@|j                  |       | xj                  t        |      z  c_        | j                          t| j                   rt        | j                   d | j                         }| j                   d | j                  = | j                  j                  |      }| xj                  t        |      z  c_        |r?|j                  |       | xj                  t        |      z  c_        | j                          7	 |S )Nr   )rQ   r%   r"   r1   r   r   rP   r#   r^   r&   rL   rO   )r   r   rb   r   r)   s        r   ra   zLimitDecoder._pump   s   !!!$==,,}}++C0MM$'''3t94'&&(!!d001C43C3CDE&&'9)9)9'9:}}++E2%%U3%MM$'''3t94'&&( r   )d   r+   i   l       
 )r   N)r   r   r	   rB   r   r\   r.   r9   r^   r,   r-   r   r&   r   r   r"   ra   r   r   r   rJ   rJ   M   s    
I """$ $ $ 	$
 $ $ 
$6
 )T ) ) % u u  r   rJ   )
typingr   r7   	Exceptionr   r   r   r0   rH   rJ   r   r   r   <module>rh      sX     My M7y 7h ,#/ #L2 2j? jr   