
    4Քh9?                       S r SSKJr  SSKrSSKrSSKrSSKrSSKrSSK	r	SSK
r
SSKrSSKrSSKJrJrJr  SSKJr  SSKJr  SSKJr  SSKJrJrJr  SS	KJr  SS
KJr  SSK J!r!J"r"  SSK#J$r$  SSK%J&r&  SSK'J(r(  SSK)J*r*  SSK+J,r,  SSK-J.r.  SSK/J0r0  SSK1J2r2  SSK3J4r4J5r5J6r6  \	Rn                  " \85      r9\\:\:4   r;S2S jr< " S S\=5      r>S3S jr? " S S\=5      r@S4S jrAS5S jrBS6S jrC " S S 5      rD " S! S"\5      rES7S# jrF\FS8S% j5       rG\" S&S'9 " S( S$5      5       rH " S) S*\5      rI S9       S:S+ jjrJ S;     S<S, jjrKS=S- jrL " S. S/\5      rM " S0 S15      rNg)>zO
The main purpose of this module is to expose LinkCollector.collect_sources().
    )annotationsN)IterableMutableMappingSequence)	dataclass)
HTMLParser)Values)Callable
NamedTupleProtocol)requests)Response)
RetryErrorSSLError)NetworkConnectionError)Link)SearchScope)
PipSession)raise_for_status)is_archive_fileredact_auth_from_url)vcs   )CandidatesFromPage
LinkSourcebuild_sourcec                    [         R                   H?  nU R                  5       R                  U5      (       d  M)  U [	        U5         S;   d  M=  Us  $    g)z_Look for VCS schemes in the URL.

Returns the matched VCS scheme, or None if there's no match.
z+:N)r   schemeslower
startswithlen)urlschemes     U/var/www/auris/envauris/lib/python3.13/site-packages/pip/_internal/index/collector.py_match_vcs_schemer&   .   sC    
 ++99;!!&))c#f+.>$.FM      c                  ,   ^  \ rS rSrSU 4S jjrSrU =r$ )_NotAPIContent9   c                <   > [         TU ]  X5        Xl        X l        g N)super__init__content_typerequest_desc)selfr/   r0   	__class__s      r%   r.   _NotAPIContent.__init__:   s    4((r'   )r/   r0   )r/   strr0   r4   returnNone)__name__
__module____qualname____firstlineno__r.   __static_attributes____classcell__r2   s   @r%   r)   r)   9   s    ) )r'   r)   c                    U R                   R                  SS5      nUR                  5       nUR                  S5      (       a  g[	        XR
                  R                  5      e)z
Check the Content-Type header to ensure the response contains a Simple
API Response.

Raises `_NotAPIContent` if the content type is not a valid content-type.
Content-TypeUnknown)z	text/htmlz#application/vnd.pypi.simple.v1+html#application/vnd.pypi.simple.v1+jsonN)headersgetr    r!   r)   requestmethod)responser/   content_type_ls      r%   _ensure_api_headerrH   @   s^     ##''	BL!'')N  	
  	
'7'7'>'>
??r'   c                      \ rS rSrSrg)_NotHTTPV    N)r7   r8   r9   r:   r;   rL   r'   r%   rJ   rJ   V   s    r'   rJ   c                    [         R                  R                  U 5      u  p#pEnUS;  a
  [        5       eUR	                  U SS9n[        U5        [        U5        g)z
Send a HEAD request to the URL, and ensure the response contains a simple
API Response.

Raises `_NotHTTP` if the URL is not available for a HEAD request, or
`_NotAPIContent` if the content type is not a valid content type.
>   httphttpsT)allow_redirectsN)urllibparseurlsplitrJ   headr   rH   )r#   sessionr$   netlocpathqueryfragmentresps           r%   _ensure_api_responser[   Z   sR     -3LL,A,A#,F)FD&&j<<T<2DTtr'   c                   [        [        U 5      R                  5      (       a	  [        XS9  [        R                  S[        U 5      5        UR                  U SR                  / SQ5      SS.S9n[        U5        [        U5        [        R                  S[        U 5      UR                  R                  S	S
5      5        U$ )a5  Access an Simple API response with GET, and return the response.

This consists of three parts:

1. If the URL looks suspiciously like an archive, send a HEAD first to
   check the Content-Type is HTML or Simple API, to avoid downloading a
   large file. Raise `_NotHTTP` if the content type cannot be determined, or
   `_NotAPIContent` if it is not HTML or a Simple API.
2. Actually perform the request. Raise HTTP exceptions on network failures.
3. Check the Content-Type header to make sure we got a Simple API response,
   and raise `_NotAPIContent` otherwise.
rU   zGetting page %sz, )rA   z*application/vnd.pypi.simple.v1+html; q=0.1ztext/html; q=0.01z	max-age=0)AcceptzCache-Control)rB   zFetched page %s as %sr?   r@   )r   r   filenamer[   loggerdebugr   rC   joinr   rH   rB   )r#   rU   rZ   s      r%   _get_simple_responserc   l   s     tCy))**S2
LL"$8$=>;;ii( )+
  D4 T t
LLS!3 Kr'   c                    U (       aO  SU ;   aI  [         R                  R                  5       nU S   US'   UR                  S5      nU(       a  [	        U5      $ g)z=Determine if we have any encoding information in our headers.r?   zcontent-typecharsetN)emailmessageMessage	get_paramr4   )rB   mre   s      r%   _get_encoding_from_headersrk      sK    >W,MM!!##N3.++i(w<r'   c                  2    \ rS rSrSS jrSS jrS	S jrSrg)
CacheablePageContent   c                6    UR                   (       d   eXl        g r,   )cache_link_parsingpager1   rq   s     r%   r.   CacheablePageContent.__init__   s    &&&&	r'   c                    [        U[        U 5      5      =(       a-    U R                  R                  UR                  R                  :H  $ r,   )
isinstancetyperq   r#   )r1   others     r%   __eq__CacheablePageContent.__eq__   s-    %d,P%**..1PPr'   c                @    [        U R                  R                  5      $ r,   )hashrq   r#   r1   s    r%   __hash__CacheablePageContent.__hash__   s    DIIMM""r'   )rq   N)rq   IndexContentr5   r6   )rw   objectr5   bool)r5   int)r7   r8   r9   r:   r.   rx   r}   r;   rL   r'   r%   rm   rm      s    Q#r'   rm   c                      \ rS rSrSS jrSrg)
ParseLinks   c                    g r,   rL   rr   s     r%   __call__ParseLinks.__call__   s    cr'   rL   Nrq   r   r5   zIterable[Link])r7   r8   r9   r:   r   r;   rL   r'   r%   r   r      s    Ar'   r   c                   ^ ^ [         R                  SU 4S jj5       m[         R                  " T 5      SU U4S jj5       nU$ )z
Given a function that parses an Iterable[Link] from an IndexContent, cache the
function's result (keyed by CacheablePageContent), unless the IndexContent
`page` has `page.cache_link_parsing == False`.
c                :   > [        T" U R                  5      5      $ r,   )listrq   )cacheable_pagefns    r%   wrapper*with_cached_index_content.<locals>.wrapper   s    B~**+,,r'   c                j   > U R                   (       a  T" [        U 5      5      $ [        T" U 5      5      $ r,   )rp   rm   r   )rq   r   r   s    r%   wrapper_wrapper2with_cached_index_content.<locals>.wrapper_wrapper   s+    ""/566BtH~r'   )r   rm   r5   
list[Link])rq   r   r5   r   )	functoolscachewraps)r   r   r   s   ` @r%   with_cached_index_contentr      s@     __- - __R 
 r'   r   c              #  ~  #    U R                   R                  5       nUR                  S5      (       ac  [        R                  " U R
                  5      nUR                  S/ 5       H,  n[        R                  " X0R                  5      nUc  M(  Uv   M.     g[        U R                  5      nU R                  =(       d    SnUR                  U R
                  R                  U5      5        U R                  nUR                  =(       d    UnUR                   H!  n	[        R                   " XUS9nUc  M  Uv   M#     g7f)zT
Parse a Simple API's Index Content, and yield its anchor elements as Link objects.
rA   filesNzutf-8)page_urlbase_url)r/   r    r!   jsonloadscontentrC   r   	from_jsonr#   HTMLLinkParserencodingfeeddecoder   anchorsfrom_element)
rq   rG   datafilelinkparserr   r#   r   anchors
             r%   parse_linksr      s      &&,,.N  !FGGzz$,,'HHWb)D>>$1D|J	 *
 	DHH%F}}'H
KK##H-.
((C%#H..  I<
	 !s   D;D=T)frozenc                  Z    \ rS rSr% SrS\S'   S\S'   S\S'   S\S	'   S
rS\S'   SS jrSrg)r      at  Represents one response (or page), along with its URL.

:param encoding: the encoding to decode the given content.
:param url: the URL from which the HTML was downloaded.
:param cache_link_parsing: whether links parsed from this page's url
                           should be cached. PyPI index urls should
                           have this set to False, for example.
bytesr   r4   r/   
str | Noner   r#   Tr   rp   c                ,    [        U R                  5      $ r,   )r   r#   r|   s    r%   __str__IndexContent.__str__  s    #DHH--r'   rL   N)r5   r4   )	r7   r8   r9   r:   __doc____annotations__rp   r   r;   rL   r'   r%   r   r      s/     N	H##.r'   c                  D   ^  \ rS rSrSrSU 4S jjrSS jrS	S jrSrU =r	$ )
r   i  zZ
HTMLParser that keeps the first base HREF and a list of all anchor
elements' attributes.
c                H   > [         TU ]  SS9  Xl        S U l        / U l        g )NT)convert_charrefs)r-   r.   r#   r   r   )r1   r#   r2   s     r%   r.   HTMLLinkParser.__init__  s&    $/$(46r'   c                    US:X  a)  U R                   c  U R                  U5      nUb  X0l         g g US:X  a%  U R                  R                  [	        U5      5        g g )Nbasea)r   get_hrefr   appenddict)r1   tagattrshrefs       r%   handle_starttagHTMLLinkParser.handle_starttag  sR    &=T]]2=='D $  CZLLU, r'   c                .    U H  u  p#US:X  d  M  Us  $    g )Nr   rL   )r1   r   namevalues       r%   r   HTMLLinkParser.get_href!  s     KDv~ ! r'   )r   r   r#   )r#   r4   r5   r6   )r   r4   r   list[tuple[str, str | None]]r5   r6   )r   r   r5   r   )
r7   r8   r9   r:   r   r.   r   r   r;   r<   r=   s   @r%   r   r     s    
7- r'   r   c                <    Uc  [         R                  nU" SX5        g )Nz%Could not fetch URL %s: %s - skipping)r`   ra   )r   reasonmeths      r%   _handle_get_simple_failr   (  s    
 |||	0$?r'   c                    [        U R                  5      n[        U R                  U R                  S   UU R                  US9$ )Nr?   )r   r#   rp   )rk   rB   r   r   r#   )rF   rp   r   s      r%   _make_index_contentr   2  sE     *(*:*:;H(LL- r'   c                  U R                   R                  SS5      S   n[        U5      nU(       a  [        R	                  SUU 5        g [
        R                  R                  U5      u  pEn    nUS:X  a  [        R                  R                  [
        R                  R                  U5      5      (       aQ  UR                  S5      (       d  US-  n[
        R                  R                  US5      n[        R                  SU5         [!        X!S	9n[#        XpR$                  S
9$ ! [&         a    [        R	                  SU 5         g [(         a6  n[        R	                  SU UR*                  UR,                  5         S nAg S nAf[.         a  n[1        X5         S nAg S nAf[2         a  n[1        X5         S nAg S nAf[4         a2  nSn	U	[7        U5      -  n	[1        X	[        R8                  S9   S nAg S nAf[:        R<                   a  n[1        U SU 35         S nAg S nAf[:        R>                   a    [1        U S5         g f = f)N#r   r   zICannot look at %s URL %s because it does not support lookup as web pages.r   /z
index.htmlz# file: URL is directory, getting %sr]   )rp   z`Skipping page %s because it looks like an archive, and cannot be checked by a HTTP HEAD request.zSkipping page %s because the %s request got Content-Type: %s. The only supported Content-Types are application/vnd.pypi.simple.v1+json, application/vnd.pypi.simple.v1+html, and text/htmlz4There was a problem confirming the ssl certificate: )r   zconnection error: z	timed out) r#   splitr&   r`   warningrQ   rR   urlparseosrW   isdirrD   url2pathnameendswithurljoinra   rc   r   rp   rJ   r)   r0   r/   r   r   r   r   r4   infor   ConnectionErrorTimeout)
r   rU   r#   
vcs_schemer$   _rW   rZ   excr   s
             r%   _get_index_contentr   ?  s   
((..a
 
#C #3'JW	

   &||44S9FtQ1BGGMM&..*E*Ed*KLL ||C  3JC
 ll""35:C@U#C9: #4<S<STT9  
1	
8 /  
A 	
 	
,  " +**   +**   @G#c(6;;?  ## B(:3%&@AA
 	  3k2 	3sT   	D$ $ I	I,F  IFI*F::I(G44IH#IIc                  *    \ rS rSr% S\S'   S\S'   Srg)CollectedSourcesi|  zSequence[LinkSource | None]
find_links
index_urlsrL   N)r7   r8   r9   r:   r   r;   rL   r'   r%   r   r   |  s    ++++r'   r   c                      \ rS rSrSr      S
S jr\ S       SS jj5       r\SS j5       r	SS jr
      SS jrSrg	)LinkCollectori  z
Responsible for collecting Link objects from all configured locations,
making network requests as needed.

The class's main method is its collect_sources() method.
c                    X l         Xl        g r,   search_scoperU   )r1   rU   r   s      r%   r.   LinkCollector.__init__  s    
 )r'   c                D   UR                   /UR                  -   nUR                  (       a5  U(       d.  [        R	                  SSR                  S U 5       5      5        / nUR                  =(       d    / n[        R                  " UUUR                  S9n[        UUS9nU$ )z
:param session: The Session to use to make requests.
:param suppress_no_index: Whether to ignore the --no-index option
    when constructing the SearchScope object.
zIgnoring indexes: %s,c              3  8   #    U  H  n[        U5      v   M     g 7fr,   r   ).0r#   s     r%   	<genexpr>'LinkCollector.create.<locals>.<genexpr>  s     Ijs-c22js   )r   r   no_index)rU   r   )
	index_urlextra_index_urlsr   r`   ra   rb   r   r   creater   )clsrU   optionssuppress_no_indexr   r   r   link_collectors           r%   r   LinkCollector.create  s     ''(7+C+CC
$5LL&IjII J ''-2
"))!!%%

 '%
 r'   c                .    U R                   R                  $ r,   )r   r   r|   s    r%   r   LinkCollector.find_links  s      +++r'   c                (    [        XR                  S9$ )z.
Fetch an HTML page containing package links.
r]   )r   rU   )r1   locations     r%   fetch_responseLinkCollector.fetch_response  s     "(LLAAr'   c                  ^ ^^ [         R                  " UUU 4S jT R                  R                  T5       5       5      R	                  5       n[         R                  " UUU 4S jT R
                   5       5      R	                  5       n[        R                  [        R                  5      (       a  [        R                  " XC5       Vs/ s H&  nUc  M  UR                  c  M  SUR                   3PM(     nn[        U5       ST S3/U-   n[        R                  SR                  U5      5        [!        [#        U5      [#        U5      S9$ s  snf )Nc           
   3  h   >#    U  H'  n[        UTTR                  R                  S S TS9v   M)     g7f)Fcandidates_from_pagepage_validator
expand_dirrp   project_nameNr   rU   is_secure_originr   locr  r  r1   s     r%   r   0LinkCollector.collect_sources.<locals>.<genexpr>  s?      
4
 P %9#||<< #() P   /2c           
   3  h   >#    U  H'  n[        UTTR                  R                  S S TS9v   M)     g7f)Tr  Nr	  r  s     r%   r   r    s=      
5
 ' %9#||<<#') 'r  z* z' location(s) to search for versions of :
)r   r   )collectionsOrderedDictr   get_index_urls_locationsvaluesr   r`   isEnabledForloggingDEBUG	itertoolschainr   r"   ra   rb   r   r   )r1   r  r  index_url_sourcesfind_links_sourcessliness   ```    r%   collect_sourcesLinkCollector.collect_sources  s8    (33 
4
 ((AA,O
4
 

 &( 	 )44 
5
 
5
 

 &( 	 w}}-- #);OOA %&VV "QVVHO   u:, ##/.3 E LL5)*./-.
 	
s   EE!Er   N)rU   r   r   r   r5   r6   )F)rU   r   r   r	   r   r   r5   r   )r5   z	list[str])r   r   r5   IndexContent | None)r  r4   r  r   r5   r   )r7   r8   r9   r:   r   r.   classmethodr   propertyr   r   r  r;   rL   r'   r%   r   r     s     " 
	 
 #(	   	
 
 B , ,B,
,
 1,
 
	,
r'   r   )r#   r4   r5   r   )rF   r   r5   r6   )r#   r4   rU   r   r5   r6   )r#   r4   rU   r   r5   r   )rB   ResponseHeadersr5   r   )r   r   r5   r   r   r,   )r   r   r   zstr | Exceptionr   zCallable[..., None] | Noner5   r6   )T)rF   r   rp   r   r5   r   )r   r   rU   r   r5   r!  )Or   
__future__r   r  email.messagerf   r   r  r   r  r   urllib.parserQ   urllib.requestcollections.abcr   r   r   dataclassesr   html.parserr   optparser	   typingr
   r   r   pip._vendorr   pip._vendor.requestsr   pip._vendor.requests.exceptionsr   r   pip._internal.exceptionsr   pip._internal.models.linkr   !pip._internal.models.search_scoper   pip._internal.network.sessionr   pip._internal.network.utilsr   pip._internal.utils.filetypesr   pip._internal.utils.miscr   pip._internal.vcsr   sourcesr   r   r   	getLoggerr7   r`   r4   r$  r&   	Exceptionr)   rH   rJ   r[   rc   rk   rm   r   r   r   r   r   r   r   r   r   r   rL   r'   r%   <module>r<     s   #       	   > > ! "   ! ) @ ; * 9 4 8 9 9 ! A A			8	$ c*)Y )@,	y 	$<~	# 	#B B(  8 $. . .(Z > (,@
@@ %@ 
	@ 48

,0

:z,z ,
h
 h
r'   