
    N j,                        S SK Jr  S SKrS SKrS SKrS SKJr  S SKJrJ	r	J
r
  S SKJrJr  S SKJr  SSKJr  SS	KJr  S
SKJr  S
SKJrJr  S
SKJr   S SKJr  \" \5         S SKJr   S SK!r"SSS5        \RF                  " S5      r$\%" 5       r&S\RN                  4S jr( " S S5      r) " S S5      r*g! \ a	    S SKJr   Nhf = f! , (       d  f       N_= f)    )suppressN)Future)AnyOptionalUnion)	AwaitableCallable)	timedelta   )Curl)CurlCffiWarning   )Cookies)	HTTPErrorRequestException)Headers)loads)markdownifyzcharset=([\w-]+)qc                     U R                      U R                  R                  5         U R                  R	                  5         SU l        S S S 5        g ! , (       d  f       g = f)Nr   )mutexqueueclearall_tasks_done
notify_allunfinished_tasks)r   s    j/root/GenerationalWealth/GenerationalWealth/venv/lib/python3.13/site-packages/curl_cffi/requests/models.pyclear_queuer      s:    	
		##% 
s   <A
A c            
       >    \ rS rSrSr S
S\S\S\S\\   4S jjr	S	r
g)Request%   zRepresenting a sent request.

Attributes:
    url: request url.
    headers: request headers.
    method: request http method.
    body: request body as bytes, or None if not provided.
Nurlheadersmethodbodyc                 4    Xl         X l        X0l        X@l        g N)r"   r#   r$   r%   )selfr"   r#   r$   r%   s        r   __init__Request.__init__/   s     	    )r%   r#   r$   r"   r'   )__name__
__module____qualname____firstlineno____doc__strr   r   bytesr)   __static_attributes__ r+   r   r    r    %   s@     !%

 
 	

 uo
 
r+   r    c                   d   \ rS rSrSrSS\\   S\\   4S jjr\	S\
4S j5       r\	S\
4S	 j5       r\R                  S
\
SS4S j5       r\	S\\
   4S j5       r\	S\
4S j5       rS\
4S jrS\S\
4S jrS rSS jrS S jrS rS rS!S jrSS jrS S jrS\
4S jrS\4S jrS rS\
4S jrSrg)"Response<   a  Contains information the server sends.

Attributes:
    url: url used in the request.
    content: response body in bytes.
    text: response body in str.
    status_code: http status code.
    reason: http response reason, such as OK, Not Found.
    ok: is status_code in [200, 400)?
    headers: response headers.
    cookies: response cookies.
    elapsed: timedelta of the request duration.
    encoding: http body encoding.
    charset: alias for encoding.
    primary_ip: primary ip of the server.
    primary_port: primary port of the server.
    local_ip: local ip used in this connection.
    local_port: local port used in this connection.
    charset_encoding: encoding specified by the Content-Type header.
    default_encoding: encoding for decoding response content if charset is not found
        in headers. Defaults to "utf-8". Can be set to a callable for automatic
        detection.
    redirect_count: how many redirects happened.
    redirect_url: the final redirected url.
    http_version: http version used.
    history: history redirections, only headers are available.
    download_size: total downloaded bytes (body).
    upload_size: total uploaded bytes (body).
    header_size: total header size.
    request_size: request size.
    response_size: download_size + header_size
Ncurlrequestc                    Xl         X l        SU l        SU l        SU l        SU l        SU l        [        5       U l        [        5       U l
        [        5       U l        SU l        SU l        SU l        SU l        SU l        SU l        SU l        SU l        / U l        0 U l        S U l        S U l        S U l        S U l        SU l        SU l        SU l        SU l        SU l        SU l         g )	N r+      OKTutf-8r   F)!r8   r9   r"   contentstatus_codereasonokr   r#   r   cookiesr
   elapseddefault_encodingredirect_countredirect_urlhttp_version
primary_ipprimary_portlocal_ip
local_porthistoryinfosr   stream_taskastream_taskquit_now_stream_closeddownload_sizeupload_sizeheader_sizerequest_sizeresponse_size)r(   r8   r9   s      r   r)   Response.__init__^   s    	yy"++DK!!" -/%'
,0
-115#"# ! !!""#r+   returnc                     U R                   $ )zAlias for encoding.)encodingr(   s    r   charsetResponse.charset~   s     }}r+   c                 <   [        U S5      (       d  U R                  nUca  [        U R                  [        5      (       a  U R                  nO5[        U R                  5      (       a  U R                  U R                  5      nU=(       d    SU l        U R                  $ )a  
Determines the encoding to decode byte content into text.

The method follows a specific priority to decide the encoding:
1. If ``.encoding`` has been explicitly set, it is used.
2. The encoding specified by the ``charset`` parameter in the ``Content-Type``
    header.
3. The encoding specified by the ``default_encoding`` attribute. This can either
    be a string (e.g., "utf-8") or a callable for charset autodetection.
	_encodingr>   )hasattrcharset_encoding
isinstancerE   r1   callabler?   r`   )r(   r[   s     r   r[   Response.encoding   s{     t[)),,Hd33S99#44Hd3344#44T\\BH%0DN~~r+   valuec                 H    [        U S5      (       a  [        S5      eXl        g )N_textz0Cannot set encoding after text has been accessed)ra   
ValueErrorr`   )r(   rf   s     r   r[   re      s     4!!OPPr+   c                     U R                   R                  S5      nU(       a/  [        R                  U5      nU(       a  UR	                  S5      $ S$ g)z=Return the encoding, as specified by the Content-Type header.zContent-Typer   N)r#   get
CHARSET_REsearchgroup)r(   content_typecharset_matchs      r   rb   Response.charset_encoding   sF     ||''7&--l;M-:=&&q)DDr+   c                     [        U S5      (       dD  U R                  (       d  SU l        U R                  $ U R                  U R                  5      U l        U R                  $ )Nrh   r;   )ra   r?   rh   _decoder\   s    r   textResponse.text   sI    tW%%<<
 zz "\\$,,7
zzr+   c                     [         R                  " U R                  5      nUR                  5       nUR	                  SS9n[        SU SU S35      nU$ )NT)html_partialz<h1>z</h1><main>z</main>)rdDocumentr?   titlesummarymd)r(   docrz   r{   
body_as_mds        r   markdownResponse.markdown   sN    kk$,,'		++4+0$ug[	AB
r+   r?   c                      UR                  U R                  SS9$ ! [        [        4 a    UR                  S5      s $ f = f)Nreplace)errorsz	utf-8-sig)decoder[   UnicodeDecodeErrorLookupError)r(   r?   s     r   rs   Response._decode   sA    	/>>$--	>BB"K0 	/>>+..	/s    !A A c                 t    U R                   (       d'  [        SU R                   SU R                   3SU 5      eg)z2Raise an error if status code is not in [200, 400)zHTTP Error z: r   N)rB   r   r@   rA   r\   s    r   raise_for_statusResponse.raise_for_status   s6    wwk$*:*:);2dkk]KQPTUU r+   c              #   4  #    SnU R                  XS9 Hu  nUb  XE-   nU(       a  UR                  U5      OUR                  5       nU(       a0  US   (       a&  U(       a  US   S   US   :X  a  UR                  5       OSnU Sh  vN   Mw     Ub  Uv   gg N7fz
iterate streaming content line by line, separated by ``\n``.

Copied from: https://requests.readthedocs.io/en/latest/_modules/requests/models/
which is under the License: Apache 2.0
N)
chunk_sizedecode_unicode)iter_contentsplit
splitlinespop)r(   r   r   	delimiterpendingchunkliness          r   
iter_linesResponse.iter_lines   s      &&! ' 
E ".7EKK	*U=M=M=OE U2Y5U2Yr]eBi5O 		  
 M  s   BBBBc              #     #    U(       a  [         R                  " S[        SS9  U(       a
  [        5       eU R                  (       a  U R
                  (       d   S5       e U R                  R                  5       n[        U[        5      (       a  U R                  5         UeU[        L a  OUv   MQ  U R                  5         g7fz4
iterate streaming content chunk by chunk in bytes.
z9chunk_size is ignored, there is no way to tell curl that.r   )
stacklevelzstream mode is not enabled.N)warningswarnr   NotImplementedErrorr   r8   rk   rc   r   _finalize_stream
STREAM_ENDr(   r   r   r   s       r   r   Response.iter_content   s      MMK
 %''zzdiiF)FF'JJNN$E %!122%%' 
"K  	s   B?Cc                 .    [        U R                  40 UD6$ )z+return a parsed json object of the content.)r   r?   )r(   kws     r   jsonResponse.json   s    T\\(R((r+   c                 $    U R                  5         gz:Close the streaming connection, only valid in stream mode.N)r   r\   s    r   closeResponse.close   s    r+   c                    U R                   (       a  g U R                  c  U R                  c  U R                  c  g SU l         U R                  (       a  U R                  R	                  5         U R                  (       a  U R                  R                  5         U R                  (       a  U R                  R                  5         g g )NT)rR   r   rO   rQ   setresultr8   r   r\   s    r   r   Response._finalize_stream  s    ::$"2"2":t}}?T"==MM##%99IIOO r+   c                H  #    SnU R                  XS9  Sh  vN nUb  XE-   nU(       a  UR                  U5      OUR                  5       nU(       a0  US   (       a&  U(       a  US   S   US   :X  a  UR                  5       OSnU H  nU7v   M
     M   N|
 Ub  U7v   gg7fr   )aiter_contentr   r   r   )r(   r   r   r   r   r   r   lines           r   aiter_linesResponse.aiter_lines  s      --! . 
 	% ".7EKK	*U=M=M=OE U2Y5U2Yr]eBi5O 		  
 	 
 M s&   B"BBBA9B"BB"c                  #    U(       a  [         R                  " S[        SS9  U(       a
  [        5       eU R                  (       a  U R
                  (       d   S5       e U R                  R                  5       I Sh  vN n[        U[        5      (       a  U R                  5       I Sh  vN   UeU[        L a  U R                  5       I Sh  vN   gU7v   Mz   N\ N1 N7fr   )r   r   r   r   r   r8   rk   rc   r   acloser   r   s       r   r   Response.aiter_content+  s      MMK
 %''zzdiiF)FF'**..**E %!122kkm## 
"kkm##K * $
 $s6   A:C<C=,C)C*"CCCCCc                 \   #    U R                  U R                  5       I Sh  vN 5      $  N7f)z
Return a decoded string.
N)rs   acontentr\   s    r   atextResponse.atextI  s"      ||$--/1221s   ,*	,c                    #    / nU R                  5         Sh  vN nUR                  U5        M   N
 SR                  U5      $ 7f)z8wait and read the streaming content in one bytes object.Nr+   )r   appendjoin)r(   chunksr   s      r   r   Response.acontentO  s@     --/ 	!%MM% 	!/xxs   A313A3Ac                 \   #    U R                   (       a  U R                   I Sh  vN   gg N7fr   )rP   r\   s    r   r   Response.acloseV  s'      #### #s   !,*,c                 "    SU R                    S3$ )Nz<Response [z]>)r@   r\   s    r   __repr__Response.__repr__]  s    T--.b11r+   ) r`   rR   rh   rP   r?   rC   r8   rE   rS   rD   rU   r#   rM   rH   rN   rK   rL   rB   rI   rJ   r   rQ   rA   rF   rG   r9   rV   rW   r@   rO   rT   r"   )NN)NFN)NF)rY   N) r,   r-   r.   r/   r0   r   r   r    r)   propertyr1   r]   r[   setterrb   rt   r   r2   rs   r   r   r   r   r   r   r   r   r   r   r   r   r3   r4   r+   r   r6   r6   <   s,   B$Xd^ $Xg=N $@    #  * __c d  
 (3-   c  # /u / /V
4 <) 6<3S 3   $2# 2r+   r6   )+
contextlibr   r   rer   concurrent.futuresr   typingr   r   r   collections.abcr   r	   datetimer
   r8   r   utilsr   rC   r   
exceptionsr   r   r#   r   orjsonr   ImportErrorr   r   r|   readabilityrx   compilerl   objectr   Queuer   r    r6   r4   r+   r   <module>r      s      	  % ' ' /   #  3  k-  ZZ+,
X
5;;  .b2 b2S   s   B2  C2C C
C