a  ze@@sUdZddlZddlZddlZddlZddlZddlZddlZddl Z ddl Z ddl Z ddl Z ddlZddlmZmZmZmZmZmZmZmZmZddlmZmZddlmZddlmZm Z ddl!m"Z"m#Z#ddl$m%Z%dd l&m'Z'dd l(m)Z)dd l*m+Z+dd l,m-Z-dd l.m/Z/ddl0m1Z1ddl2m3Z3ddl4m5Z5ddl6m7Z7ddl8m9Z9m:Z:ddl;mZ?ee@e@eeeAe@ffZBejCde)dgdZDeeBeEd<dZFeGdddZHe@dddZIGdddeZJGd d!d!e ZKGd"d#d#eZLGd$d%d%ejMZNdS)&zhPipSession and supporting code, containing all pip-specific network request configuration and behavior. N) AnyDictIteratorListMappingOptionalSequenceTupleUnion)requestsurllib3)CacheControlAdapter) BaseAdapter HTTPAdapter)PreparedRequestResponse)CaseInsensitiveDict)ConnectionPool)InsecureRequestWarning) __version__)get_default_environment)Link)MultiDomainBasicAuth) SafeFileCache)has_tls)libc_ver)build_url_from_netloc parse_netloc) url_to_pathignore)category))https*r")r" localhostr")r"z 127.0.0.0/8r")r"z::1/128r")filer"N)sshr"r"SECURE_ORIGINS) BUILD_BUILDIDBUILD_IDCI PIP_IS_CIreturncCstddtDS)z? Return whether it looks like pip is running under CI. css|]}|tjvVqdSN)osenviron).0namer2_/opt/bitninja-python-dojo/embedded/lib/python3.9/site-packages/pip/_internal/network/session.py az looks_like_ci..)anyCI_ENVIRONMENT_VARIABLESr2r2r2r3 looks_like_ciZsr8c Csdtdtdtid}|dddkr@t|dd<n|dddkrtj}|jd krl|d d }d d d|D|dd<nB|dddkrt|dd<n |dddkrt|dd<tjdrDddl m }| }t t ddtgd|}t t ddtddgt}|r6||d<|rD||d<tjdrvtdrvdtdd|d<trt|did<trt|did<trt|d<trdd l}|j|d <td!}|d urt|j|d"<td#d urhztjd#d$gtj d%d&}Wnt!yDYn$0|d'rh|"d(d)#|d*<t$rtd+nd |d,<t%j&'d-} | d ur| |d.<d/j(|t)j*|d0d+d1d2S)3z6 Return a string representing the user agent. pip)r1versionr1) installerpythonimplementationr=CPythonr:PyPyfinalN.cSsg|] }t|qSr2)str)r0xr2r2r3 wr5zuser_agent..Jython IronPythonlinuxr)distrocSs|dSNr2rDr2r2r3r5zuser_agent..)r1r:idcSs|dSrJr2rLr2r2r3rMr5liblibcrIdarwinmacOSsystemreleasecpuopenssl_version setuptoolssetuptools_versionrustcz --versiong?)stderrtimeoutsrustc  rK rustc_versionTciPIP_USER_AGENT_USER_DATA user_dataz9{data[installer][name]}/{data[installer][version]} {json}),:) separators sort_keys)datajson)+rplatformpython_versionpython_implementationsyspypy_version_info releaseleveljoin startswith pip._vendorrIlinux_distributiondictfilterziprmac_verrS setdefaultrTmachiner_sslOPENSSL_VERSIONrget_distributionrCr:shutilwhich subprocess check_outputSTDOUT Exceptionsplitdecoder8r.r/getformatrfdumps) rerkrIrp distro_infosrPsslsetuptools_dist rustc_outputr`r2r2r3 user_agentds                rc @sreZdZd eeeeeeeeffeee feee ee e ffee e e fe dddZ dddd Z dS) LocalFSAdapterFNT)requeststreamr[verifycertproxiesr,c Cst|j}t}d|_|j|_zt|} Wn0ty\} zd|_| |_WYd} ~ nXd} ~ 00tj j | j dd} t |dpd} t| | j| d|_t|d|_|jj|_|S) NiT)usegmtrz text/plain)z Content-TypezContent-Lengthz Last-Modifiedrb)rurlr status_coder.statOSErrorrawemailutils formatdatest_mtime mimetypes guess_typerst_sizeheadersopenclose) selfrrr[rrrpathnamerespstatsexcmodified content_typer2r2r3sends(   zLocalFSAdapter.sendr+cCsdSr-r2)rr2r2r3rszLocalFSAdapter.close)FNTNN)__name__ __module__ __qualname__rboolrr floatr rCrrrrr2r2r2r3rs  $rc sFeZdZeeeeefeeeeeeffddfdd Z Z S)InsecureHTTPAdapterNconnrrrr,cstj||d|ddSNF)rrrrsuper cert_verifyrrrrr __class__r2r3rszInsecureHTTPAdapter.cert_verify rrrrrCr rrr r __classcell__r2r2rr3rs  rc sFeZdZeeeeefeeeeeeffddfdd Z Z S)InsecureCacheControlAdapterNrcstj||d|ddSrrrrr2r3rsz'InsecureCacheControlAdapter.cert_verifyrr2r2rr3rs  rc seZdZUdZeeed<dddddeeeee eee eeddfddZ e edd d d Z deeee dd ddZeedddZee dddZeeeeedfdd ZZS) PipSessionNr[rr2)retriescache trusted_hosts index_urls)argsrrrrkwargsr,c stj|i|g|_t|jd<t|d|_tj|gddd}t |d}|rvt t ||d}t t ||d|_ nt|d}||_ |d||d ||d t|D]} |j| d d qd S)zj :param trusted_hosts: Domains not to emit warnings for when not using HTTPS. z User-Agent)r)iiiig?)totalstatus_forcelistbackoff_factor) max_retries)rrzhttps://zhttp://zfile://T)suppress_loggingN)r__init__pip_trusted_originsrrrauthr Retryrr rr_trusted_host_adapterrmountradd_trusted_host) rrrrrrrinsecure_adaptersecure_adapterhostrr2r3r s4        zPipSession.__init__)new_index_urlsr,cCs ||j_dS)zn :param new_index_urls: New index urls to update the authentication handler with. N)rr)rrr2r2r3update_index_urlsZszPipSession.update_index_urlsF)rsourcerr,cCs|s0d|}|dur&|d|d7}t|t|}||jvrN|j||t|d|j|ds|t|d|jdS)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. zadding trusted host: Nz (from )/rKrb)loggerinforrappendrrr)rrrrmsg host_portr2r2r3ras     zPipSession.add_trusted_hostr+ccs6tEdH|jD] \}}d||dur(dn|fVqdS)Nr")r&r)rrportr2r2r3iter_secure_originsys zPipSession.iter_secure_origins)locationr,c Cstjt|}|j|j|j}}}|ddd}|D]}|\}}} ||kr^|dkr^q>zt |} t |} Wn2t y|r| | kr|dkrYq>Yn 0| | vrq>|| kr| dkr| durq>dStd||dS)N+rKr"TzThe 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)urllibparseurlparserCschemehostnamerrsplitr ipaddress ip_address ip_network ValueErrorlowerrwarning) rrparsedorigin_protocol origin_host origin_port secure_originsecure_protocol secure_host secure_portaddrnetworkr2r2r3is_secure_origin~sJ       zPipSession.is_secure_origin)methodrrrr,cs*|d|jtj||g|Ri|S)Nr[)rur[rr)rrrrrrr2r3rszPipSession.request)NF)rrrr[rint__annotations__rrCrrrrrrr SecureOriginrrrrrrr2r2rr3r s.  M  Cr)O__doc__ email.utilsrrrfloggingrr.rgrzr|rj urllib.parserwarningstypingrrrrrrrr r ror r pip._vendor.cachecontrolr Zpip._vendor.requests.adaptersrrZpip._vendor.requests.modelsrrZpip._vendor.requests.structuresrZ"pip._vendor.urllib3.connectionpoolrZpip._vendor.urllib3.exceptionsrr9rpip._internal.metadatarpip._internal.models.linkrpip._internal.network.authrpip._internal.network.cacherpip._internal.utils.compatrpip._internal.utils.glibcrpip._internal.utils.miscrrpip._internal.utils.urlsr getLoggerrrrCrrfilterwarningsr&rr7rr8rrrrSessionrr2r2r2r3sP,               f)