
    T>qj                        d dl mZ d dlZd dlZd dlZd dlmZ d dlmZ d dl	Z	d dl
mZ ddlmZmZmZ ddlmZmZ 	 	 	 	 	 	 	 	 d	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 dd	Z	 d	 	 	 	 	 	 	 dd
Zy)    )annotationsN)BufferedReader)Any)Session   )determine_print_spechandle_downloadprint_output)parse_request_itemsprocess_urlc           
        |
r|
j                   nt        j                   }	  |di d|d|d|d|d|d|d|d|d	|	d
| j                  d| j                  d| j                  d| j
                  d| j                  d| j                  dt        | dd      }	 |r&|j                         D ]  }|j                           	 t        |       }| j                   r@| j"                  st%        ||||dd       t'        ||| j(                  | j"                         n:d}|t+        j,                  |dd      }n|t/        |      }t%        ||||||       |j0                  dk\  ryy# t        $ rP}t        d| t        j                         Y d}~|r&|j                         D ]  }|j                           yyd}~ww xY w# |r&|j                         D ]  }|j                           w w xY w)z`Execute a single HTTP request and handle output.

    Returns:
        0 on success, 1 on error.methodurlheadersparamsdatajsonfilescookiesauthtimeoutverifyproxyallow_redirectsmax_redirectsimpersonatehttp_versionNzError: )filer   h)quiet   F)indentensure_asciii  r    )request	curl_cffir   r   r   followr   r   getattr	Exceptionprintsysstderrvaluescloser   downloadr    r
   r	   outputr   dumpsstrstatus_code)argsr   r   r   r   r   	json_bodyr   r   r   session
request_fnresponseef
print_specrequest_bodys                    T/opt/rentech/trading_bot/.venv/lib/python3.12/site-packages/curl_cffi/cli/request.py_execute_requestr>      s   " %,1B1BJ 


 
 	

 
 
 
 
 
 LL
 ;;
 **
 !KK
 ,,
 ((
  !~t<!
, \\^ 	 &d+J}}zz63sC#t{{$**E ::iNLt9LXvsG\:Ns"1  sm#**-\\^ 	 	 \\^ 	 s*   A=E( (	G1F<G <GG *G.c                   t        | j                        }t        | j                        }d}d}| j                  s| j
                  r"|j                  rit        |j                        }nS|j                  s|j                  r;t        |j                        }|j                  t        |j                               |}d}|j                  r%i }|j                  D ]  \  }	}
t        |
d      ||	<    d}| j                  r6| j                  j                  dd      }|d   t        |      dkD  r|d   ndf}t        | |||j                   |j"                  ||||j$                  |
      }|dk7  r|rt'        j(                  d       |S )zqEntrypoint for building and executing a request from parsed args.

    Returns:
        0 on success, 1 on error.Nrb:r   r    )r   r   r   r5   r   r   r   )r   r   r   itemsform	multipartdata_fieldsdictjson_fieldsupdater   openr   splitlenr>   r   query_paramsr   r+   exit)r4   r   exit_on_errorr   parsedr   r5   bodyr   
field_namefilepathr   partsrcs                 r=   handle_requestrV   P   sX    dhh
C ,FDIyyDNN**+D!3!3**+DKKV//01IE||$*LL 	5 J $Xt 4E*	5 Dyy		Q'ac%j1n%("=	""
B 
Qw=I    )NNNNNNNN)r4   argparse.Namespacer   r2   r   r2   r   dict[str, str] | Noner   zlist[tuple[str, str]] | Noner   zdict[str, str] | str | Noner5   zdict[str, Any] | Noner   z dict[str, BufferedReader] | Noner   rY   r   ztuple[str, str] | Noner6   zSession | Nonereturnint)T)r4   rX   r   r2   rO   boolrZ   r[   )
__future__r   argparser   r+   ior   typingr   r&   curl_cffi.requestsr   r0   r   r	   r
   parser   r   r>   rV   r$   rW   r=   <module>rc      s    "   
    & G G 3 &*+/(,'+.2%)#'"=
== 
= #	=
 )= &= %= ,= #= != = 	=B BF/
/&)/:>//rW   