U
    {fr                     @   sR   d dl Z d dlZd dlmZ d dlmZmZmZmZ ddl	m
Z
 G dd dZdS )    N)TracebackType)AnyDictOptionalType   )Requestc                   @   s   e Zd Zdeejee eeee	f  ddddZ
eeee	f ddddZd dd	d
Zdeee  ee ee ddddZeeee	f ddddZd dddZdeee  ee ee ddddZdS )TraceN)nameloggerrequestkwargsreturnc                 C   sp   || _ || _|d krd n
|jd| _| jtj| _|p<i | _	d | _
| jpT| jd k	| _| jj dd | _d S )Ntrace.)r
   r   
extensionsgettrace_extensionisEnabledForloggingDEBUGdebugr   return_valueshould_tracesplitprefix)selfr
   r   r   r    r   N/var/www/html/Darija-Ai-API/env/lib/python3.8/site-packages/httpcore/_trace.py__init__
   s    
zTrace.__init__)r
   infor   c                 C   s   | j d k	r8| j d| }|  ||}t|r8td| jr|rVd|kr\|d d kr\|}n&ddd | D }| d| }| j| d S )Nr   zIf you are using a synchronous interface, the callback of the `trace` extension should be a normal function instead of an asynchronous function.r    c                 S   s   g | ]\}}| d |qS =r   .0keyvaluer   r   r   
<listcomp>+   s     zTrace.trace.<locals>.<listcomp>	r   r   inspectiscoroutine	TypeErrorr   joinitemsr   )r   r
   r!   prefix_and_nameretmessageargsr   r   r   r      s    

zTrace.trace)r   c                 C   s$   | j r | j}| | j d| | S Nz.started)r   r   r   r
   r   r!   r   r   r   	__enter__/   s    zTrace.__enter__)exc_type	exc_value	tracebackr   c                 C   sN   | j rJ|d kr.d| ji}| | j d| nd|i}| | j d| d S Nr   z	.complete	exceptionz.failed)r   r   r   r
   r   r7   r8   r9   r!   r   r   r   __exit__5   s    
zTrace.__exit__c                    s   | j d k	rB| j d| }|  ||}t|s8td|I d H  | jr|r`d|krf|d d krf|}n&ddd | D }| d| }| j| d S )Nr   zIf you're using an asynchronous interface, the callback of the `trace` extension should be an asynchronous function rather than a normal function.r   r"   c                 S   s   g | ]\}}| d |qS r#   r   r%   r   r   r   r)   S   s     z Trace.atrace.<locals>.<listcomp>r*   )r   r
   r!   r0   coror2   r3   r   r   r   atraceC   s    


zTrace.atracec                    s*   | j r&| j}| | j d|I d H  | S r4   )r   r   r?   r
   r5   r   r   r   
__aenter__W   s    zTrace.__aenter__c                    sZ   | j rV|d kr4d| ji}| | j d|I d H  n"d|i}| | j d|I d H  d S r:   )r   r   r?   r
   r<   r   r   r   	__aexit__]   s    
zTrace.__aexit__)NN)NNN)NNN)__name__
__module____qualname__strr   Loggerr   r   r   r   r    r   r6   r   BaseExceptionr   r=   r?   r@   rA   r   r   r   r   r	   	   s>        
   
r	   )r+   r   typesr   typingr   r   r   r   Z_modelsr   r	   r   r   r   r   <module>   s
   