o
    ñ‘OjH  ã                   @   st  U d Z ddlZddlZddlZddlZddlZddlZddlZddl	Z	ddl
Z
ddlZddlZddlZddlZddlmZmZmZmZmZmZmZmZmZmZ ddlmZmZ ddlmZ  ddl!m"Z"m#Z# ddl!m$Z% ddl&m'Z'm(Z( dd	l)m*Z* dd
l+m,Z, ddl-m.Z. ddl/m0Z0 ddl1m2Z2 ddl3m4Z4 ddl5m6Z6 ddl7m8Z8 ddl9m:Z: ddl;m<Z< ddl=m>Z>m?Z? ddl@mAZA erËddlBmCZC ddlDmEZE e FeG¡ZHeeIeIeeeJeIf  f ZKejLde.d� g d¢ZMeeK eNd< dZOdePfdd„ZQdeIfdd „ZRG d!d"„ d"e#ƒZSG d#d$„ d$ƒZTG d%d&„ d&eTe%ƒZ$G d'd(„ d(eTe ƒZG d)d*„ d*e$ƒZUG d+d,„ d,eƒZVG d-d.„ d.ejWƒZXdS )/zhPipSession and supporting code, containing all pip-specific
network request configuration and behavior.
é    N)
ÚTYPE_CHECKINGÚAnyÚDictÚ	GeneratorÚListÚMappingÚOptionalÚSequenceÚTupleÚUnion)ÚrequestsÚurllib3)ÚCacheControlAdapter)ÚDEFAULT_POOLBLOCKÚBaseAdapter)ÚHTTPAdapter)ÚPreparedRequestÚResponse)ÚCaseInsensitiveDict)ÚConnectionPool)ÚInsecureRequestWarning)Ú__version__)Úget_default_environment)ÚLink)ÚMultiDomainBasicAuth)ÚSafeFileCache)Úhas_tls)Úlibc_ver)Úbuild_url_from_netlocÚparse_netloc)Úurl_to_path)Ú
SSLContext)ÚPoolManagerÚignore)Úcategory))ÚhttpsÚ*r&   )r&   Ú	localhostr&   )r&   z127.0.0.0/8r&   )r&   z::1/128r&   )Úfiler&   N)Ússhr&   r&   ÚSECURE_ORIGINS)ÚBUILD_BUILDIDÚBUILD_IDÚCIÚ	PIP_IS_CIÚreturnc                   C   s   t dd„ tD ƒƒS )z?
    Return whether it looks like pip is running under CI.
    c                 s   s   � | ]}|t jv V  qd S ©N)ÚosÚenviron)Ú.0Úname© r5   úc/var/www/html/pharmsmart-cdr-gen/venv/lib/python3.10/site-packages/pip/_internal/network/session.pyÚ	<genexpr>j   s   € z looks_like_ci.<locals>.<genexpr>)ÚanyÚCI_ENVIRONMENT_VARIABLESr5   r5   r5   r6   Úlooks_like_cic   s   r:   c            
      C   s°  dt dœt ¡ dt ¡ idœ} | d d dkr t ¡ | d d< nF| d d dkrEtj}|jd	kr6|d
d… }d dd„ |D ƒ¡| d d< n!| d d dkrVt ¡ | d d< n| d d dkrft ¡ | d d< tj d¡r¦ddl	m
} | ¡ | ¡ | ¡ f}ttdd„ tg d¢|ƒƒƒ}ttdd„ tddgtƒ ƒƒƒ}|r ||d< |r¦|| d< tj d¡r½t ¡ d r½dt ¡ d dœ| d< t ¡ rËt ¡ |  di ¡d< t ¡ rÙt ¡ |  di ¡d< t ¡ rãt ¡ | d< tƒ rïdd
l}|j| d < tƒ  d!¡}|d
u�rt|jƒ| d"< t d#¡d
u�r2ztj d#d$gtj!d%d&�}W n
 t"�y    Y nw | d'¡�r2| #d(¡d)  $¡ | d*< t%ƒ �r8d+nd
| d,< t&j' (d-¡}	|	d
u�rK|	| d.< d/j)| t*j+| d0d+d1�d2�S )3z6
    Return a string representing the user agent.
    Úpip)r4   Úversionr4   )Ú	installerÚpythonÚimplementationr?   ÚCPythonr<   ÚPyPyÚfinalNé   Ú.c                 S   s   g | ]}t |ƒ‘qS r5   )Ústr)r3   Úxr5   r5   r6   Ú
<listcomp>€   s    zuser_agent.<locals>.<listcomp>ÚJythonÚ
IronPythonÚlinuxr   )Údistroc                 S   ó   | d S ©Né   r5   ©rF   r5   r5   r6   Ú<lambda>�   ó    zuser_agent.<locals>.<lambda>)r4   r<   Úidc                 S   rL   rM   r5   rO   r5   r5   r6   rP   •   rQ   ÚlibÚlibcrK   ÚdarwinÚmacOSÚsystemÚreleaseÚcpuÚopenssl_versionÚ
setuptoolsÚsetuptools_versionÚrustcz	--versiong      à?)ÚstderrÚtimeouts   rustc ó    rN   Úrustc_versionTÚciÚPIP_USER_AGENT_USER_DATAÚ	user_dataz9{data[installer][name]}/{data[installer][version]} {json})ú,ú:)Ú
separatorsÚ	sort_keys)ÚdataÚjson),r   ÚplatformÚpython_versionÚpython_implementationÚsysÚpypy_version_infoÚreleaselevelÚjoinÚ
startswithÚpip._vendorrK   r4   r<   ÚcodenameÚdictÚfilterÚzipr   Úmac_verrW   Ú
setdefaultrX   Úmachiner   Ú_sslÚOPENSSL_VERSIONr   Úget_distributionrE   ÚshutilÚwhichÚ
subprocessÚcheck_outputÚSTDOUTÚ	ExceptionÚsplitÚdecoder:   r1   r2   ÚgetÚformatrj   Údumps)
ri   ro   rK   Úlinux_distributionÚdistro_infosrT   ÚsslÚsetuptools_distÚrustc_outputrd   r5   r5   r6   Ú
user_agentm   sŠ   ÿý
ÿþÿþÿ


ÿÿ
þrŽ   c                   @   s„   e Zd Z					ddededeeeeeef f  deee	f deee	ee	e	f f  d	ee
e	e	f  d
efdd„Zddd„ZdS )ÚLocalFSAdapterFNTÚrequestÚstreamr_   ÚverifyÚcertÚproxiesr/   c              
   C   sÖ   t |jƒ}tƒ }d|_|j|_zt |¡}	W n+ tyA }
 zd|_t|
ƒj|_	t
 |j	› d|
› � d¡¡|_W Y d }
~
|S d }
~
ww tjj|	jdd�}t |¡d pSd}t||	j|d	œƒ|_t|d
ƒ|_|jj|_|S )NéÈ   i”  z: Úutf8T)Úusegmtr   z
text/plain)zContent-TypezContent-LengthzLast-ModifiedÚrb)r    Úurlr   Ústatus_coder1   ÚstatÚOSErrorÚtypeÚ__name__ÚreasonÚioÚBytesIOÚencodeÚrawÚemailÚutilsÚ
formatdateÚst_mtimeÚ	mimetypesÚ
guess_typer   Úst_sizeÚheadersÚopenÚclose)Úselfr�   r‘   r_   r’   r“   r”   ÚpathnameÚrespÚstatsÚexcÚmodifiedÚcontent_typer5   r5   r6   ÚsendÓ   s0   
	(€ìýÿ
zLocalFSAdapter.sendc                 C   s   d S r0   r5   )r®   r5   r5   r6   r­   ú   s   zLocalFSAdapter.close)FNTNN)r/   N)rž   Ú
__module__Ú__qualname__r   Úboolr   r   Úfloatr
   rE   r   r   rµ   r­   r5   r5   r5   r6   r�   Ò   s,    ùþýü
ûúù
ø'r�   c                       s^   e Zd ZdZddœded deddf‡ fdd	„Zefd
edede	deddf
‡ fdd„Z
‡  ZS )Ú_SSLContextAdapterMixina#  Mixin to add the ``ssl_context`` constructor argument to HTTP adapters.

    The additional argument is forwarded directly to the pool manager. This allows us
    to dynamically decide what SSL store to use at runtime, which is used to implement
    the optional ``truststore`` backend.
    N)Ússl_contextr»   r!   Úkwargsr/   c                   s   || _ tƒ jdi |¤Ž d S )Nr5   )Ú_ssl_contextÚsuperÚ__init__)r®   r»   r¼   ©Ú	__class__r5   r6   r¿     s   z _SSLContextAdapterMixin.__init__ÚconnectionsÚmaxsizeÚblockÚpool_kwargsr"   c                    s2   | j d ur| d| j ¡ tƒ jd|||dœ|¤ŽS )Nr»   )rÂ   rÃ   rÄ   r5   )r½   ry   r¾   Úinit_poolmanager)r®   rÂ   rÃ   rÄ   rÅ   rÀ   r5   r6   rÆ     s   
ýüz(_SSLContextAdapterMixin.init_poolmanager)rž   r¶   r·   Ú__doc__r   r   r¿   r   Úintr¸   rÆ   Ú__classcell__r5   r5   rÀ   r6   rº   þ   s,    
ýýüûüþýüûúrº   c                   @   ó   e Zd ZdS )r   N©rž   r¶   r·   r5   r5   r5   r6   r      ó    r   c                   @   rÊ   )r   NrË   r5   r5   r5   r6   r   $  rÌ   r   c                       óN   e Zd Zdededeeef deeeeeef f  ddf
‡ fdd„Z	‡  Z
S )	ÚInsecureHTTPAdapterÚconnr™   r’   r“   r/   Nc                    ó   t ƒ j||d|d� d S ©NF)rÏ   r™   r’   r“   ©r¾   Úcert_verify©r®   rÏ   r™   r’   r“   rÀ   r5   r6   rÓ   )  ó   zInsecureHTTPAdapter.cert_verify©rž   r¶   r·   r   rE   r   r¸   r   r
   rÓ   rÉ   r5   r5   rÀ   r6   rÎ   (  ó    þý
üûúrÎ   c                       rÍ   )	ÚInsecureCacheControlAdapterrÏ   r™   r’   r“   r/   Nc                    rÐ   rÑ   rÒ   rÔ   rÀ   r5   r6   rÓ   4  rÕ   z'InsecureCacheControlAdapter.cert_verifyrÖ   r5   r5   rÀ   r6   rØ   3  r×   rØ   c                       sö   e Zd ZU dZee ed< ddddddœdededee d	e	e d
ee
e  ded deddf‡ fdd„Zde
e ddfdd„Z	d#dedee deddfdd„Zdeeddf fdd„Zdedefdd„Zded edededef
‡ fd!d"„Z‡  ZS )$Ú
PipSessionNr_   r   r5   )ÚretriesÚcacheÚtrusted_hostsÚ
index_urlsr»   ÚargsrÚ   rÛ   rÜ   rÝ   r»   r!   r¼   r/   c                   sÌ   t ƒ j|i |¤Ž g | _tƒ | jd< t|d�| _tj|g d¢dd�}t	|d�}|r<t
t|ƒ||d�}	tt|ƒ|d�| _n	t||d	�}	|| _|  d
|	¡ |  d|¡ |  dtƒ ¡ |D ]	}
| j|
dd� qZdS )zj
        :param trusted_hosts: Domains not to emit warnings for when not using
            HTTPS.
        z
User-Agent)rÝ   )iô  i÷  i  i  g      Ð?)ÚtotalÚstatus_forcelistÚbackoff_factor)Úmax_retries)rÛ   râ   r»   )rÛ   râ   )râ   r»   zhttps://zhttp://zfile://T)Úsuppress_loggingN)r¾   r¿   Úpip_trusted_originsrŽ   r«   r   Úauthr   ÚRetryrÎ   r   r   rØ   Ú_trusted_host_adapterr   Úmountr�   Úadd_trusted_host)r®   rÚ   rÛ   rÜ   rÝ   r»   rÞ   r¼   Úinsecure_adapterÚsecure_adapterÚhostrÀ   r5   r6   r¿   B  s8   ó
ý
þÿzPipSession.__init__Únew_index_urlsc                 C   s   || j _dS )zn
        :param new_index_urls: New index urls to update the authentication
            handler with.
        N)rå   rÝ   )r®   rí   r5   r5   r6   Úupdate_index_urls‘  s   zPipSession.update_index_urlsFrì   Úsourcerã   c                 C   s¾   |sd|›�}|dur|d|› d�7 }t  |¡ t|ƒ}|| jvr'| j |¡ |  t|dd�d | j¡ |  t|ƒd | j¡ |d s]|  t|dd�d	 | j¡ |  t|ƒd	 | j¡ dS dS )
zÒ
        :param host: It is okay to provide a host that has previously been
            added.
        :param source: An optional source string, for logging where the host
            string came from.
        zadding trusted host: Nz (from ú)Úhttp)Úschemeú/rN   rf   )ÚloggerÚinfor   rä   Úappendrè   r   rç   )r®   rì   rï   rã   ÚmsgÚ	host_portr5   r5   r6   ré   ˜  s&   	


ÿþúzPipSession.add_trusted_hostc                 c   s8   � t E d H  | jD ]\}}d||d u rdn|fV  q	d S )Nr&   )r*   rä   )r®   rì   Úportr5   r5   r6   Úiter_secure_origins·  s
   €
ÿzPipSession.iter_secure_originsÚlocationc              	   C   sê   t j t|ƒ¡}|j|j|j}}}| dd¡d }|  ¡ D ]L}|\}}}	||kr/|dkr/qzt	 
|p5d¡}
t	 |¡}W n tyV   |rT| ¡ | ¡ krT|dkrTY qY nw |
|vr\q||	kri|	dkri|	d uriq dS t d||¡ dS )	Nú+rN   éÿÿÿÿr&   Ú TzõThe repository located at %s is not a trusted or secure host and is being ignored. If this repository is available via HTTPS we recommend you use HTTPS instead, otherwise you may silence this warning and allow it anyway with '--trusted-host %s'.F)ÚurllibÚparseÚurlparserE   rò   Úhostnamerù   Úrsplitrú   Ú	ipaddressÚ
ip_addressÚ
ip_networkÚ
ValueErrorÚlowerrô   Úwarning)r®   rû   ÚparsedÚorigin_protocolÚorigin_hostÚorigin_portÚsecure_originÚsecure_protocolÚsecure_hostÚsecure_portÚaddrÚnetworkr5   r5   r6   Úis_secure_origin¼  sN   
ý

ÿþý€øÿþýú	zPipSession.is_secure_originÚmethodr™   c                    s8   |  d| j¡ |  d| j¡ tƒ j||g|¢R i |¤ŽS )Nr_   r”   )ry   r_   r”   r¾   r�   )r®   r  r™   rÞ   r¼   rÀ   r5   r6   r�   ÿ  s   zPipSession.request)NF)rž   r¶   r·   r_   r   rÈ   Ú__annotations__r   rE   r	   r   r¿   rî   r¸   ré   r   ÚSecureOriginrú   r   r  r   r�   rÉ   r5   r5   rÀ   r6   rÙ   >  sL   
 ùþýüû
úùø	÷Oÿÿÿÿ
þ*CrÙ   )YrÇ   Úemail.utilsr¤   r    r  rj   Úloggingr¨   r1   rk   r~   r€   rn   Úurllib.parserÿ   ÚwarningsÚtypingr   r   r   r   r   r   r   r	   r
   r   rs   r   r   Úpip._vendor.cachecontrolr   Ú_BaseCacheControlAdapterÚpip._vendor.requests.adaptersr   r   r   Ú_BaseHTTPAdapterÚpip._vendor.requests.modelsr   r   Úpip._vendor.requests.structuresr   Ú"pip._vendor.urllib3.connectionpoolr   Úpip._vendor.urllib3.exceptionsr   r;   r   Úpip._internal.metadatar   Úpip._internal.models.linkr   Úpip._internal.network.authr   Úpip._internal.network.cacher   Úpip._internal.utils.compatr   Úpip._internal.utils.glibcr   Úpip._internal.utils.miscr   r   Úpip._internal.utils.urlsr    r‹   r!   Úpip._vendor.urllib3.poolmanagerr"   Ú	getLoggerrž   rô   rE   rÈ   r  Úfilterwarningsr*   r  r9   r¸   r:   rŽ   r�   rº   rÎ   rØ   ÚSessionrÙ   r5   r5   r5   r6   Ú<module>   sb    0

e,"