o
    é’OjR  ã                   @   sê   d dl Z d dlZd dlmZ d dlmZmZ d dlmZm	Z	 d dl
mZmZ d dlmZ d dlmZ d dlmZ ejd	krDd d
l mZ nd d
lmZ dedef dB defdd„Zdedef dedef fdd„ZeG dd„ dƒƒZdS )é    N)ÚCallable)Ú	dataclassÚfield)Úcached_propertyÚpartial)ÚAnyÚLiteral)Ú
ModelField)ÚSecurityBase)ÚDependencyCacheKey)é   é   )ÚiscoroutinefunctionÚcall.Úreturnc                 C   s   | d u r| S t  t| ƒ¡}|S ©N)ÚinspectÚunwrapÚ
_impartial)r   Ú	unwrapped© r   úa/var/www/html/pharmsmart-cdr-gen/venv/lib/python3.10/site-packages/fastapi/dependencies/models.pyÚ_unwrapped_call   s   r   Úfuncc                 C   s   t | tƒr| j} t | tƒs| S r   )Ú
isinstancer   r   )r   r   r   r   r      s   

ÿr   c                   @   s2  e Zd ZU eed�Zee ed< eed�Zee ed< eed�Z	ee ed< eed�Z
ee ed< eed�Zee ed< eed�Zed  ed< dZedB ed	< dZed
ef dB ed< dZedB ed< dZedB ed< dZedB ed< dZedB ed< dZedB ed< dZedB ed< dZee dB ed< dZee dB ed< dZeed< dZedB ed< dZed dB ed< edee fdd„ƒZ ede!fdd„ƒZ"edefdd„ƒZ#edefd d!„ƒZ$ede%fd"d#„ƒZ&eded  fd$d%„ƒZ'edefd&d'„ƒZ(edefd(d)„ƒZ)edefd*d+„ƒZ*ededB fd,d-„ƒZ+dS ).Ú	Dependant)Údefault_factoryÚpath_paramsÚquery_paramsÚheader_paramsÚcookie_paramsÚbody_paramsÚdependenciesNÚname.r   Úrequest_param_nameÚwebsocket_param_nameÚhttp_connection_param_nameÚresponse_param_nameÚbackground_tasks_param_nameÚsecurity_scopes_param_nameÚown_oauth_scopesÚparent_oauth_scopesTÚ	use_cacheÚpath)ÚfunctionÚrequestÚscoper   c                 C   s:   | j r| j  ¡ ng }| jpg D ]}||vr| |¡ q|S r   )r+   Úcopyr*   Úappend)ÚselfÚscopesr0   r   r   r   Úoauth_scopes5   s   
€zDependant.oauth_scopesc                 C   s2   | j rttt| jp
g ƒƒƒnd}| j|| jpdfS )Nr   Ú )Ú_uses_scopesÚtupleÚsortedÚsetr5   r   Úcomputed_scope)r3   Úscopes_for_cacher   r   r   Ú	cache_key>   s   ÿýzDependant.cache_keyc                 C   s>   | j rdS | jd urdS | jrdS | jD ]}|jr dS qdS )NTF)r*   r)   Ú_is_security_schemer"   r7   )r3   Úsub_depr   r   r   r7   I   s   

ÿzDependant._uses_scopesc                 C   s"   | j d u rdS t| j ƒ}t|tƒS )NF)r   r   r   r
   ©r3   r   r   r   r   r>   V   s   


zDependant._is_security_schemec                 C   s   t | jƒ}t|tƒsJ ‚|S r   )r   r   r   r
   r@   r   r   r   Ú_security_scheme^   s   
zDependant._security_schemec                 C   s   dd„ | j D ƒ}|S )Nc                 S   s   g | ]}|j r|‘qS r   )r>   )Ú.0Údepr   r   r   Ú
<listcomp>f   s    z4Dependant._security_dependencies.<locals>.<listcomp>)r"   )r3   Úsecurity_depsr   r   r   Ú_security_dependenciesd   s   z Dependant._security_dependenciesc                 C   óÆ   | j d u rdS t t| j ƒ¡st t| j ƒ¡rdS t t| j ƒ¡r#dS tt| j ƒdd ƒ}|d u r2dS t t|ƒ¡s@t t|ƒ¡rBdS tt| j ƒdd ƒ}|d u rQdS t t|ƒ¡s_t t|ƒ¡radS dS ©NFTÚ__call__)r   r   Úisgeneratorfunctionr   r   ÚisclassÚgetattr©r3   Údunder_callÚdunder_unwrapped_callr   r   r   Úis_gen_callablei   ó:   
ÿþÿþÿþzDependant.is_gen_callablec                 C   rG   rH   )r   r   Úisasyncgenfunctionr   r   rK   rL   rM   r   r   r   Úis_async_gen_callableƒ   rQ   zDependant.is_async_gen_callablec                 C   sÞ   | j d u rdS t t| j ƒ¡rtt| j ƒƒrdS t t| j ƒ¡r)tt| j ƒƒr)dS t t| j ƒ¡r3dS tt| j ƒdd ƒ}|d u rBdS tt|ƒƒsNtt|ƒƒrPdS tt| j ƒdd ƒ}|d u r_dS tt|ƒƒsktt|ƒƒrmdS dS rH   )r   r   Ú	isroutiner   r   r   rK   rL   rM   r   r   r   Úis_coroutine_callable�   s:   
ÿÿÿÿ
þzDependant.is_coroutine_callablec                 C   s    | j r| j S | js| jrdS d S )Nr/   )r0   rP   rS   )r3   r   r   r   r;   »   s
   zDependant.computed_scope),Ú__name__Ú
__module__Ú__qualname__r   Úlistr   r	   Ú__annotations__r   r   r    r!   r"   r#   Ústrr   r   r   r$   r%   r&   r'   r(   r)   r*   r+   r,   Úboolr-   r0   r   r   r5   r   r=   r7   r>   r
   rA   rF   rP   rS   rU   r;   r   r   r   r   r      sP   
 
r   )r   ÚsysÚcollections.abcr   Údataclassesr   r   Ú	functoolsr   r   Útypingr   r   Úfastapi._compatr	   Úfastapi.security.baser
   Úfastapi.typesr   Úversion_infor   Úasyncior   r   r   r   r   r   r   Ú<module>   s     
"