+
     h?  c                   s   R t ^ RIt^ RIt^ RIt^ RIt^ RIt^ RIt^ RIt^ RI	t
^ RIt
^ RIHt ^ RIHt ^ RIHt ^ RIHtHtHtHtHtHtHtHtHtHtHt ^ RIHt ^ RI H!t! ^ RI"H#t#H$t$ ^ R	I%H&t& ^ R
I'H(t( ^ RI)H*t* ^ RI+H,t, ^ RI-H.t. ^ RI/H0t0 ^ RI1H2t2 ^ RI3H4t4 ^RI5H6t6H7t7H8t8 ]Pr                  ! ]:4      t;]]<]<3,          t=R R lt> ! R R]?4      t@R R ltA ! R R]?4      tBR R ltCR R ltDR R ltE ! R  R!4      tF ! R" R#]4      tGR$ R% ltH]HR& R' l4       tI]! R(R)7       ! R* R+4      4       tJ ! R, R-]4      tKR8R. R/ lltLR9R0 R1 lltMR2 R3 ltN ! R4 R5]4      tO ! R6 R74      tPR# ):zO
The main purpose of this module is to expose LinkCollector.collect_sources().
N)	dataclass)
HTMLParser)Values)CallableDictIterableListMutableMapping
NamedTupleOptionalProtocolSequenceTupleUnion)requestsResponse)
RetryErrorSSLError)NetworkConnectionError)Link)SearchScope)
PipSession)raise_for_status)is_archive_fileredact_auth_from_url)vcs)CandidatesFromPage
LinkSourcebuild_sourcec                sF    V ^8  d   QhR\         R\        \         ,          /# )   urlreturn)strr	   format   "B/usr/lib/python3.14/site-packages/pip/_internal/index/collector.py__annotate__r'   3   s      3 8C=     c                s    \         P                   FE  pV P                  4       P                  V4      '       g   K*  V \	        V4      ,          R9   g   KC  Vu # 	  R# )z_Look for VCS schemes in the URL.

Returns the matched VCS scheme, or None if there's no match.
z+:N)r   Zschemeslower
startswithlen)r    scheme   & r&   _match_vcs_schemer.   3   sC    
 ++99;!!&))c#f+.>$.FM  r(   c                   s>   a a ] tR t^>t oV3R lV 3R lltRtVtV ;t# )_NotAPIContentc                s*   < V ^8  d   QhRS[ RS[ RR/# )r   content_typerequest_descr!   Nr"   r$   __classdict__   "r&   r'   Z_NotAPIContent.__annotate__?   s"     ) )S ) ) )r(   c                s>   < \         SV `  W4       Wn        W n        R # N)super__init__r0   r1   )selfr0   r1   	__class__s   &&&r&   r8   Z_NotAPIContent.__init__?   s    4((r(   )r0   r1   )__name__
__module____qualname____firstlineno__r8   __static_attributes____classdictcell____classcell__r:   r4      @@r&   r/   r/   >   s     ) ) )r(   r/   c                s(    V ^8  d   QhR\         RR/# )r   responser!   Nr   r#   r%   r&   r'   r'   E   s     @ @ @d @r(   c                s    V P                   P                  RR4      pVP                  4       pVP                  R4      '       d   R# \	        WP
                  P                  4      h)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UnknownN)z	text/htmlz#application/vnd.pypi.simple.v1+html#application/vnd.pypi.simple.v1+json)headersgetr)   r*   r/   requestZmethod)rD   r0   content_type_l   &  r&   _ensure_api_headerrM   E   s^     ##''	BL!'')N  	
  	
'7'7'>'>
??r(   c                   s    ] tR t^[tRtR# )_NotHTTP N)r;   r<   r=   r>   r?   rO   r(   r&   rN   rN   [   s    r(   rN   c                s4    V ^8  d   QhR\         R\        RR/# )r   r    sessionr!   N)r"   r   r#   r%   r&   r'   r'   _   s!      c J 4 r(   c                s    \         P                  P                  V 4      w  r#rEpVR9  d   \        4       hVP	                  V RR7      p\        V4       \        V4       R# )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.
T)Zallow_redirectsN>   ZhttpZhttps)urllibparseZurlsplitrN   Zheadr   rM   )r    rP   r,   ZnetlocpathZqueryZfragmentresps   &&      r&   _ensure_api_responserU   _   sR     -3LL,A,A#,F)FD&&j<<T<2DTtr(   c                <    V ^8  d   QhR\         R\        R\        /# )r   r    rP   r!   )r"   r   r   r#   r%   r&   r'   r'   q   s!     < <c <J <8 <r(   c                s   \        \        V 4      P                  4      '       d   \        WR7       \        P                  R\        V 4      4       VP                  V RRP                  . RO4      RR/R7      p\        V4       \        V4       \        P                  R\        V 4      VP                  P                  R	R
4      4       V# )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.
rP   zGetting page %sZAcceptz, zCache-Controlz	max-age=0)rH   zFetched page %s as %srE   rF   )rG   z*application/vnd.pypi.simple.v1+html; q=0.1ztext/html; q=0.01)r   r   ZfilenamerU   loggerdebugr   rI   joinr   rM   rH   )r    rP   rT      && r&   _get_simple_responser\   q   s     tCy))**S2
LL"$8$=>;;dii( [+
  D4 T t
LLS!3 Kr(   c                F    V ^8  d   QhR\         R\        \        ,          /# )r   rH   r!   )ResponseHeadersr	   r"   r#   r%   r&   r'   r'      s       HSM r(   c                s    V '       dV   RV 9   dO   \         P                  P                  4       pV R,          VR&   VP                  R4      pV'       d   \	        V4      # R# )z=Determine if we have any encoding information in our headers.rE   zcontent-typecharsetN)emailZmessageZMessageZ	get_paramr"   )rH   Zmr_   rL   r&   _get_encoding_from_headersra      sK    >W,MM!!##N3.++i(w<r(   c                   sV   a  ] tR t^t o V 3R lR ltV 3R lR ltV 3R lR ltRtV tR# )	CacheablePageContentc                s"   < V ^8  d   QhRRRR/# )r   pageIndexContentr!   NrO   r3   r5   r&   r'   !CacheablePageContent.__annotate__   s      ^  r(   c                s    Wn         R # r6   rc   r9   rc      &&r&   r8   ZCacheablePageContent.__init__   s    	r(   c                s&   < V ^8  d   QhRS[ RS[/# )r   otherr!   )Zobjectboolr3   r5   r&   r'   re      s     Q QF Qt Qr(   c                s    \        V\        V 4      4      ;'       d.    V P                  P                  VP                  P                  8H  # r6   )Z
isinstanceZtyperc   r    )r9   ri   rh   r&   __eq__ZCacheablePageContent.__eq__   s0    %d,PP%**..1PPr(   c                    < V ^8  d   QhRS[ /# r   r!   )Zintr3   r5   r&   r'   re      s     # ## #r(   c                s@    \        V P                  P                  4      # r6   )Zhashrc   r    r9      &r&   __hash__ZCacheablePageContent.__hash__   s    DIIMM""r(   rf   N)	r;   r<   r=   r>   r8   rk   rp   r?   r@   r4      @r&   rb   rb      s%      Q Q# #r(   rb   c                   s2   a  ] tR t^t o V 3R lR ltRtV tR# )
ParseLinksc                s4   < V ^8  d   QhRRRS[ S[,          /# r   rc   rd   r!   r   r   r3   r5   r&   r'   ZParseLinks.__annotate__   s    CC^CCr(   c                s    R # r6   rO   rg   rh   r&   __call__ZParseLinks.__call__   s    r(   rO   N)r;   r<   r=   r>   rv   r?   r@   rq   rr   r&   rs   rs      s     CCr(   rs   c                s0    V ^8  d   QhR\         R\         /# )r   fnr!   )rs   r#   r%   r&   r'   r'      s      *  r(   c                s   a a \         P                  ! RR7      R V 3R ll4       o\         P                  ! S 4      R V V3R ll4       pV# )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`.
N)Zmaxsizec                r]   )r   cacheable_pager!   )rb   r   r   r#   r%   r&   r'   /with_cached_index_content.<locals>.__annotate__   s     - - 4 -d -r(   c                 s:   < \        S! V P                  4      4      # r6   )listrc   )rx   rw   s   &r&   wrapperZ*with_cached_index_content.<locals>.wrapper   s    B~**+,,r(   c                >    V ^8  d   QhRRR\         \        ,          /# rt   )r   r   r#   r%   r&   r'   ry      s      n d r(   c                 sl   < V P                   '       d   S! \        V 4      4      # \        S! V 4      4      # r6   )cache_link_parsingrb   rz   )rc   rw   r{   s   &r&   wrapper_wrapperZ2with_cached_index_content.<locals>.wrapper_wrapper   s.    """/566BtH~r(   )	functoolsZ	lru_cacheZwraps)rw   r~   r{   s   f @r&   with_cached_index_contentr      sL     &- '- __R  
 r(   c                r|   rt   ru   r#   r%   r&   r'   r'      s      n $ r(   c              #  s  "   V P                   P                  4       pVP                  R4      '       df   \        P                  ! V P
                  4      pVP                  R. 4       F-  p\        P                  ! W0P                  4      pVf   K)  Vx  K/  	  R# \        V P                  4      pV P                  ;'       g    RpVP                  V P
                  P                  V4      4       V P                  pVP                  ;'       g    TpVP                   F%  p	\        P                   ! WVR7      pVf   K!  Vx  K'  	  R# 5i)zT
Parse a Simple API's Index Content, and yield its anchor elements as Link objects.
rG   ZfilesNzutf-8)Zpage_urlbase_url)r0   r)   r*   jsonZloadscontentrI   r   Z	from_jsonr    HTMLLinkParserencodingZfeedZdecoder   anchorsZfrom_element)
rc   rK   ZdatafilelinkZparserr   r    r   Zanchors
   &         r&   parse_linksr      s      &&,,.N  !FGGzz$,,'HHWb)D>>$1D|J	 *
 	DHH%F}}''H
KK##H-.
((C%%#H..  I<
	 !s   B>EAE:ET)Zfrozenc                   sF   a  ] tR t^t o RtRtV 3R lR ltV 3R ltRtV t	R# )rd   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.
Tc                rl   rm   r2   r3   r5   r&   r'   IndexContent.__annotate__  s     . . .r(   c                s,    \        V P                  4      # r6   )r   r    rn   ro   r&   __str__ZIndexContent.__str__  s    #DHH--r(   c                sf   < V ^8  d   Qh/ S[ ;R&   S[;R&   S[S[,          ;R&   S[;R&   S[;R&   # )r   r   r0   r   r    r}   )Zbytesr"   r	   rj   r3   r5   r&   r'   r      sH      N    sm  
H  # r(   rO   N)
r;   r<   r=   r>   __doc__r}   r   __annotate_func__r?   r@   rq   rr   r&   rd   rd      s#       $. .#  r(   rd   c                   sf   a a ] tR tRt oRtV3R lV 3R lltV3R lR ltV3R lR ltR	tVt	V ;t
# )
r   i  zZ
HTMLParser that keeps the first base HREF and a list of all anchor
elements' attributes.
c                s$   < V ^8  d   QhRS[ RR/# )r   r    r!   Nr2   r3   r5   r&   r'   HTMLLinkParser.__annotate__  s     : :C :D :r(   c                sP   < \         SV `  R R7       Wn        RV n        . V n        R# )T)Zconvert_charrefsN)r7   r8   r    r   r   )r9   r    r:   s   &&r&   r8   ZHTMLLinkParser.__init__  s&    $/'+79r(   c                s`   < V ^8  d   QhRS[ RS[S[S[ S[S[ ,          3,          ,          RR/# )r   tagattrsr!   N)r"   r   r   r	   r3   r5   r&   r'   r     s6     - -3 -tE#x}:L4M/N -SW -r(   c                s    VR 8X  d.   V P                   f    V P                  V4      pVe	   W0n         R# R# VR8X  d'   V P                  P                  \	        V4      4       R# R# )ZbaseNZa)r   get_hrefr   ZappendZdict)r9   r   r   hrefs   &&& r&   handle_starttagZHTMLLinkParser.handle_starttag  sR    &=T]]2=='D $  CZLLU, r(   c                sl   < V ^8  d   QhRS[ S[S[S[S[,          3,          ,          RS[S[,          /# )r   r   r!   )r   r   r"   r	   r3   r5   r&   r'   r   &  s2      d5hsm);#<= (3- r(   c                s2    V F  w  r#VR 8X  g   K  Vu # 	  R# )r   NrO   )r9   r   ZnameZvalues   &&  r&   r   ZHTMLLinkParser.get_href&  s     KDv~ ! r(   )r   r   r    )r;   r<   r=   r>   r   r8   r   r   r?   r@   rA   rB   rC   r&   r   r     s-     
: :- -  r(   r   c                s    V ^8  d   QhR\         R\        \        \        3,          R\        \
        R,          ,          RR/# )r   r   reasonmethNr!   ).N)r   r   r"   	Exceptionr	   r   r#   r%   r&   r'   r'   -  sI     @ @
@#y.!@ 8I&
'@ 
	@r(   c                 s@    Vf   \         P                  pV! RW4       R # )Nz%Could not fetch URL %s: %s - skipping)rX   rY   )r   r   r      &&&r&   _handle_get_simple_failr   -  s    
 |||	0$?r(   c                rV   )r   rD   r}   r!   )r   rj   rd   r#   r%   r&   r'   r'   7  s$     
 

,0

r(   c                 s    \        V P                  4      p\        V P                  V P                  R ,          VV P                  VR7      # )rE   )r   r    r}   )ra   rH   rd   r   r    )rD   r}   r   r[   r&   _make_index_contentr   7  sE     *(*:*:;H(LL- r(   c                sJ    V ^8  d   QhR\         R\        R\        R,          /# )r   r   rP   r!   rd   )r   r   r	   r#   r%   r&   r'   r'   D  s&     : :T :z :h~>V :r(   c                s   V P                   P                  R ^4      ^ ,          p\        V4      pV'       d   \        P	                  RVV 4       R# \
        P                  P                  V4      w  rEp  pVR8X  d   \        P                  P                  \
        P                  P                  V4      4      '       dW   VP                  R4      '       g
   VR,          p\
        P                  P                  VR4      p\        P                  RV4        \!        W!R7      p\#        WpP$                  R7      #   \&         d    \        P	                  R	T 4        R# \(         d8   p\        P	                  R
T TP*                  TP,                  4        Rp?R# Rp?i\.         d   p\1        Y4        Rp?R# Rp?i\2         d   p\1        Y4        Rp?R# Rp?i\4         d;   pRp	T	\7        T4      ,          p	\1        Y	\        P8                  R7        Rp?R# Rp?i\:        P<                   d   p\1        T RT 24        Rp?R# Rp?i\:        P>                   d    \1        T R4        R# i ; i)Z#zICannot look at %s URL %s because it does not support lookup as web pages.Nr   Z/z
index.htmlz# file: URL is directory, getting %srW   )r}   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    Zsplitr.   rX   ZwarningrQ   rR   ZurlparseosrS   ZisdirrJ   Zurl2pathnameZendswithZurljoinrY   r\   r   r}   rN   r/   r1   r0   r   r   r   r   r"   Zinfor   ZConnectionErrorZTimeout)
r   rP   r    Z
vcs_schemer,   Z_rS   rT   Zexcr   s
   &$        r&   _get_index_contentr   D  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 	3sx   D7 7!I-I-$I-%,FI-$I-%F66I-I-GI-"I-#/HI-/I-0II-I-,I-c                   s,   a  ] tR tRt o V 3R ltRtV tR# )CollectedSourcesi  c                sr   < V ^8  d   Qh/ S[ S[S[,          ,          ;R&   S[ S[S[,          ,          ;R&   # )r   
find_links
index_urls)r   r	   r   r3   r5   r&   r'   ZCollectedSources.__annotate__  s/     *-.. *-.. r(   rO   N)r;   r<   r=   r>   r   r?   r@   rq   rr   r&   r   r     s      r(   r   c                   s   a  ] tR tRt o RtV 3R lR lt]RV 3R lR ll4       t]V 3R lR l4       t	V 3R	 lR
 lt
V 3R lR ltRtV tR# )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                s*   < V ^8  d   QhRS[ RS[RR/# )r   rP   search_scoper!   N)r   r   r3   r5   r&   r'   LinkCollector.__annotate__  s)       " 
	r(   c                s    W n         Wn        R # r6   r   rP   )r9   rP   r   r   r&   r8   ZLinkCollector.__init__  s    
 )r(   c                s0   < V ^8  d   QhRS[ RS[RS[RR/# )r   rP   optionssuppress_no_indexr!   r   )r   r   rj   r3   r5   r&   r'   r     s3         	
 
r(   c                s^   VP                   .VP                  ,           pVP                  '       d7   V'       g/   \        P	                  RRP                  R V 4       4      4       . pVP                  ;'       g    . p\        P                  ! VVVP                  R7      p\        VVR7      pV# )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: %sZ,c              3   s8   "   T F  p\        V4      x  K  	  R # 5ir6   r   ).0r    r-   r&   	<genexpr>Z'LinkCollector.create.<locals>.<genexpr>  s     Ijs-c22js   )r   r   no_index)rP   r   )
Z	index_urlZextra_index_urlsr   rX   rY   rZ   r   r   creater   )ZclsrP   r   r   r   r   r   Zlink_collectors   &&&&    r&   r   ZLinkCollector.create  s     ''(7+C+CC
$5LL&IjII J ''--2
"))!!%%

 '%
 r(   c                s0   < V ^8  d   QhRS[ S[,          /# rm   )r   r"   r3   r5   r&   r'   r     s     , ,DI ,r(   c                s.    V P                   P                  # r6   )r   r   rn   ro   r&   r   ZLinkCollector.find_links  s      +++r(   c                s6   < V ^8  d   QhRS[ RS[S[,          /# )r   locationr!   )r   r	   rd   r3   r5   r&   r'   r     s$     B Bt B0F Br(   c                s.    \        WP                  R7      # )z.
Fetch an HTML page containing package links.
rW   )r   rP   )r9   r   rh   r&   fetch_responseZLinkCollector.fetch_response  s     "(LLAAr(   c                s,   < V ^8  d   QhRS[ RS[RS[/# )r   project_namecandidates_from_pager!   )r"   r   r   r3   r5   r&   r'   r     s)     ,
 ,
,
 1,
 
	,
r(   c                s  a aa \         P                  ! VVV 3R  lS P                  P                  S4       4       4      P	                  4       p\         P                  ! VVV 3R lS P
                   4       4      P	                  4       p\        P                  \        P                  4      '       d   \        P                  ! WC4       Uu. uF(  pVf   K	  VP                  f   K  RVP                   2NK*  	  pp\        V4       RS R2.V,           p\        P                  RP                  V4      4       \!        \#        V4      \#        V4      R7      # u upi )c           
   3   n   <"   T F*  p\        VSSP                  P                  R R SR7      x  K,  	  R# 5i)Fr   Zpage_validatorZ
expand_dirr}   r   Nr   rP   Zis_secure_originr   Zlocr   r   r9      & r&   r   0LinkCollector.collect_sources.<locals>.<genexpr>  sD      
4
 P %9#||<< #()  P   25c           
   3   r   )Tr   Nr   r   r   r&   r   r     sB      
5
 ' %9#||<<#')  'r   z* z' location(s) to search for versions of Z:Z
)r   r   )collectionsZOrderedDictr   Zget_index_urls_locationsZvaluesr   rX   ZisEnabledForloggingZDEBUG	itertoolsZchainr   r+   rY   rZ   r   rz   )r9   r   r   Zindex_url_sourcesZfind_links_sourcesZsZliness   fff    r&   collect_sourcesZ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)F)r;   r<   r=   r>   r   r8   Zclassmethodr   Zpropertyr   r   r   r?   r@   rq   rr   r&   r   r     sX         B , ,B B,
 ,
r(   r   r6   )T)Qr   r   Zemail.messager`   r   r   r   r   r   Zurllib.parserQ   Zurllib.requestZdataclassesr    Zhtml.parserr   Zoptparser   Ztypingr   r   r   r   r   r   r	   r
   r   r   r   Zpip._vendorr   Zpip._vendor.requestsr   Zpip._vendor.requests.exceptionsr   r   Zpip._internal.exceptionsr   Zpip._internal.models.linkr   Z!pip._internal.models.search_scoper   Zpip._internal.network.sessionr   Zpip._internal.network.utilsr   Zpip._internal.utils.filetypesr   Zpip._internal.utils.miscr   Zpip._internal.vcsr   Zsourcesr   r   r   Z	getLoggerr;   rX   r"   r^   r.   r   r/   rM   rN   rU   r\   ra   rb   rs   r   r   rd   r   r   r   r   r   r   rO   r(   r&   <module>r      sB         	   ! "     ! ) @ ; * 9 4 8 9 9 ! A A			8	$ c*)Y )@,	y 	$<~	# 	#D D(  8 $. . .(Z 8@
:z/z /
h
 h
r(   