+
    Bi9?                       R t ^ RIH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HtHt ^ RIHt ^ RIHt ^ RIHt ^ RI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-H.t. ^ RI/H0t0 ^ RI1H2t2 ^RI3H4t4H5t5H6t6 ]	Pn                  ! ]84      t9]]:]:3,          t;R R lt< ! R R]=4      t>R R lt? ! R R]=4      t@R R ltAR R ltBR  R! ltC ! R" R#4      tD ! R$ R%]4      tER& R' ltF]FR( R) l4       tG]! R*R+7       ! R, R-4      4       tH ! R. R/]4      tIR:R0 R1 lltJR;R2 R3 lltKR4 R5 ltL ! R6 R7]4      tM ! R8 R94      tNR# )<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                    V ^8  d   QhRRRR/# )   urlstrreturn
str | None )formats   "B/usr/lib/python3.14/site-packages/pip/_internal/index/collector.py__annotate__r%   .   s      3 :     c                    \         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   schemeslower
startswithlen)r   schemes   & r$   _match_vcs_schemer-   .   sC    
 ++99;!!&))c#f+.>$.FM  r&   c                  .   a  ] tR t^9tR V 3R lltRtV ;t# )_NotAPIContentc               $    V ^8  d   QhRRRRRR/# )r   content_typer   request_descr    Noner"   )r#   s   "r$   r%   _NotAPIContent.__annotate__:   s!     ) )S ) ) )r&   c                	>   < \         SV `  W4       Wn        W n        R # N)super__init__r1   r2   )selfr1   r2   	__class__s   &&&r$   r8   _NotAPIContent.__init__:   s    4((r&   )r1   r2   )__name__
__module____qualname____firstlineno__r8   __static_attributes____classcell__r:   s   @r$   r/   r/   9   s    ) )r&   r/   c                    V ^8  d   QhRRRR/# )r   responser   r    r3   r"   )r#   s   "r$   r%   r%   @   s     @ @ @d @r&   c                    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/   requestmethod)rD   r1   content_type_ls   &  r$   _ensure_api_headerrN   @   s^     ##''	BL!'')N  	
  	
'7'7'>'>
??r&   c                      ] tR t^VtRtR# )_NotHTTPr"   N)r<   r=   r>   r?   r@   r"   r&   r$   rP   rP   V   s    r&   rP   c               $    V ^8  d   QhRRRRRR/# )r   r   r   sessionr   r    r3   r"   )r#   s   "r$   r%   r%   Z   s!      c J 4 r&   c                    \         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)allow_redirectsN>   httphttps)urllibparseurlsplitrP   headr   rN   )r   rR   r,   netlocpathqueryfragmentresps   &&      r$   _ensure_api_responser`   Z   sR     -3LL,A,A#,F)FD&&j<<T<2DTtr&   c               $    V ^8  d   QhRRRRRR/# )r   r   r   rR   r   r    r   r"   )r#   s   "r$   r%   r%   l   s!     < <c <J <8 <r&   c                   \        \        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.
rR   zGetting page %sAcceptz, zCache-Controlz	max-age=0)rI   zFetched page %s as %srF   rG   )rH   z*application/vnd.pypi.simple.v1+html; q=0.1ztext/html; q=0.01)r   r   filenamer`   loggerdebugr   rJ   joinr   rN   rI   )r   rR   r_   s   && r$   _get_simple_responseri   l   s     tCy))**S2
LL"$8$=>;;dii( [+
  D4 T t
LLS!3 Kr&   c                    V ^8  d   QhRRRR/# )r   rI   ResponseHeadersr    r!   r"   )r#   s   "r$   r%   r%      s       J r&   c                    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.rF   zcontent-typecharsetN)emailmessageMessage	get_paramr   )rI   mrm   s   &  r$   _get_encoding_from_headersrs      sK    >W,MM!!##N3.++i(w<r&   c                  :    ] tR t^tR R ltR R ltR R ltRtR# )	CacheablePageContentc                    V ^8  d   QhRRRR/# )r   pageIndexContentr    r3   r"   )r#   s   "r$   r%   !CacheablePageContent.__annotate__   s      \ d r&   c                	:    VP                   '       g   Q hWn        R # r6   )cache_link_parsingrw   r9   rw   s   &&r$   r8   CacheablePageContent.__init__   s    &&&&&	r&   c                    V ^8  d   QhRRRR/# )r   otherobjectr    boolr"   )r#   s   "r$   r%   ry      s     Q QF Qt Qr&   c                	    \        V\        V 4      4      ;'       d.    V P                  P                  VP                  P                  8H  # r6   )
isinstancetyperw   r   )r9   r   s   &&r$   __eq__CacheablePageContent.__eq__   s0    %d,PP%**..1PPr&   c                   V ^8  d   QhRR/# )r   r    intr"   )r#   s   "r$   r%   ry      s     # ## #r&   c                	@    \        V P                  P                  4      # r6   )hashrw   r   r9   s   &r$   __hash__CacheablePageContent.__hash__   s    DIIMM""r&   )rw   N)r<   r=   r>   r?   r8   r   r   r@   r"   r&   r$   ru   ru      s    Q# #r&   ru   c                  "    ] tR t^tR R ltRtR# )
ParseLinksc                    V ^8  d   QhRRRR/# r   rw   rx   r    zIterable[Link]r"   )r#   s   "r$   r%   ParseLinks.__annotate__   s    AA\AnAr&   c                	    R # r6   r"   r|   s   &&r$   __call__ParseLinks.__call__   s    cr&   r"   N)r<   r=   r>   r?   r   r@   r"   r&   r$   r   r      s    AAr&   r   c                    V ^8  d   QhRRRR/# )r   fnr   r    r"   )r#   s   "r$   r%   r%      s      *  r&   c                   a a \         P                  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`.
c                    V ^8  d   QhRRRR/# )r   cacheable_pageru   r    
list[Link]r"   )r#   s   "r$   r%   /with_cached_index_content.<locals>.__annotate__   s     - - 4 - -r&   c                :   < \        S! V P                  4      4      # r6   )listrw   )r   r   s   &r$   wrapper*with_cached_index_content.<locals>.wrapper   s    B~**+,,r&   c                    V ^8  d   QhRRRR/# )r   rw   rx   r    r   r"   )r#   s   "r$   r%   r      s      l z r&   c                l   < V P                   '       d   S! \        V 4      4      # \        S! V 4      4      # r6   )r{   ru   r   )rw   r   r   s   &r$   wrapper_wrapper2with_cached_index_content.<locals>.wrapper_wrapper   s.    """/566BtH~r&   )	functoolscachewraps)r   r   r   s   f @r$   with_cached_index_contentr      sE     __- - __R  
 r&   c                    V ^8  d   QhRRRR/# r   r"   )r#   s   "r$   r%   r%      s      l ~ r&   c              #    "   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.
rH   filesNzutf-8)page_urlbase_url)r1   r)   r*   jsonloadscontentrJ   r   	from_jsonr   HTMLLinkParserencodingfeeddecoder   anchorsfrom_element)
rw   rM   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   B>EAE:ET)frozenc                  ^    ] tR t^t$ RtR]R&   R]R&   R]R&   R]R&   R	tR
]R&   R R ltRtR# )rx   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   r   r1   r!   r   r   Tr   r{   c                   V ^8  d   QhRR/# )r   r    r   r"   )r#   s   "r$   r%   IndexContent.__annotate__  s     . . .r&   c                	,    \        V P                  4      # r6   )r   r   r   s   &r$   __str__IndexContent.__str__  s    #DHH--r&   r"   N)	r<   r=   r>   r?   __doc____annotations__r{   r   r@   r"   r&   r$   rx   rx      s4     N	H##. .r&   rx   c                  J   a  ] tR tRtRtR V 3R lltR R ltR R ltR	tV ;t	# )
r   i  zZ
HTMLParser that keeps the first base HREF and a list of all anchor
elements' attributes.
c                    V ^8  d   QhRRRR/# )r   r   r   r    r3   r"   )r#   s   "r$   r%   HTMLLinkParser.__annotate__  s     7 7C 7D 7r&   c                	P   < \         SV `  R R7       Wn        RV n        . V n        R# )T)convert_charrefsN)r7   r8   r   r   r   )r9   r   r:   s   &&r$   r8   HTMLLinkParser.__init__  s&    $/$(46r&   c               $    V ^8  d   QhRRRRRR/# )r   tagr   attrslist[tuple[str, str | None]]r    r3   r"   )r#   s   "r$   r%   r     s#     - -3 -/K -PT -r&   c                	    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# )baseNa)r   get_hrefr   appenddict)r9   r   r   hrefs   &&& r$   handle_starttagHTMLLinkParser.handle_starttag  sR    &=T]]2=='D $  CZLLU, r&   c                    V ^8  d   QhRRRR/# )r   r   r   r    r!   r"   )r#   s   "r$   r%   r   !  s      : z r&   c                	2    V F  w  r#VR 8X  g   K  Vu # 	  R# )r   Nr"   )r9   r   namevalues   &&  r$   r   HTMLLinkParser.get_href!  s     KDv~ ! r&   )r   r   r   )
r<   r=   r>   r?   r   r8   r   r   r@   rA   rB   s   @r$   r   r     s!    
7 7- r&   r   c               (    V ^8  d   QhRRRRRRRR/# )	r   r   r   reasonzstr | ExceptionmethzCallable[..., None] | Noner    r3   r"   )r#   s   "r$   r%   r%   (  s6     @ @
@@ %@ 
	@r&   c                @    Vf   \         P                  pV! RW4       R # )Nz%Could not fetch URL %s: %s - skipping)rf   rg   )r   r   r   s   &&&r$   _handle_get_simple_failr   (  s    
 |||	0$?r&   c               $    V ^8  d   QhRRRRRR/# )r   rD   r   r{   r   r    rx   r"   )r#   s   "r$   r%   r%   2  s$     
 

,0

r&   c                    \        V P                  4      p\        V P                  V P                  R ,          VV P                  VR7      # )rF   )r   r   r{   )rs   rI   rx   r   r   )rD   r{   r   s   && r$   _make_index_contentr   2  sE     *(*:*:;H(LL- r&   c               $    V ^8  d   QhRRRRRR/# )r   r   r   rR   r   r    IndexContent | Noner"   )r#   s   "r$   r%   r%   ?  s"     : :T :z :>Q :r&   c                  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)#zICannot look at %s URL %s because it does not support lookup as web pages.Nr   /z
index.htmlz# file: URL is directory, getting %src   )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   splitr-   rf   warningrW   rX   urlparseosr\   isdirrK   url2pathnameendswithurljoinrg   ri   r   r{   rP   r/   r2   r1   r   r   r   r   r   infor   ConnectionErrorTimeout)
r   rR   r   
vcs_schemer,   _r\   r_   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 	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                  ,    ] tR tRt$ R]R&   R]R&   RtR# )CollectedSourcesi|  zSequence[LinkSource | None]
find_links
index_urlsr"   N)r<   r=   r>   r?   r   r@   r"   r&   r$   r   r   |  s    ++++r&   r   c                  n    ] tR tRtRtR R lt]RR R ll4       t]R R l4       t	R	 R
 lt
R R ltR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               $    V ^8  d   QhRRRRRR/# )r   rR   r   search_scoper   r    r3   r"   )r#   s   "r$   r%   LinkCollector.__annotate__  s(       " 
	r&   c                	    W n         Wn        R # r6   r  rR   )r9   rR   r  s   &&&r$   r8   LinkCollector.__init__  s    
 )r&   c               (    V ^8  d   QhRRRRRRRR/# )	r   rR   r   optionsr   suppress_no_indexr   r    r  r"   )r#   s   "r$   r%   r    s2         	
 
r&   c                ^   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: %s,c              3  8   "   T F  p\        V4      x  K  	  R # 5ir6   r   ).0r   s   & r$   	<genexpr>'LinkCollector.create.<locals>.<genexpr>  s     Ijs-c22js   )r   r   no_index)rR   r  )
	index_urlextra_index_urlsr  rf   rg   rh   r   r   creater  )clsrR   r	  r
  r   r   r  link_collectors   &&&&    r$   r  LinkCollector.create  s     ''(7+C+CC
$5LL&IjII J ''--2
"))!!%%

 '%
 r&   c                   V ^8  d   QhRR/# )r   r    z	list[str]r"   )r#   s   "r$   r%   r    s     , ,I ,r&   c                	.    V P                   P                  # r6   )r  r   r   s   &r$   r   LinkCollector.find_links  s      +++r&   c                    V ^8  d   QhRRRR/# )r   locationr   r    r   r"   )r#   s   "r$   r%   r    s     B Bt B0C Br&   c                .    \        WP                  R7      # )z.
Fetch an HTML page containing package links.
rc   )r   rR   )r9   r  s   &&r$   fetch_responseLinkCollector.fetch_response  s     "(LLAAr&   c               $    V ^8  d   QhRRRRRR/# )r   project_namer   candidates_from_pager   r    r   r"   )r#   s   "r$   r%   r    s(     ,
 ,
,
 1,
 
	,
r&   c                	  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"  page_validator
expand_dirr{   r!  Nr   rR   is_secure_originr  locr"  r!  r9   s   & r$   r  0LinkCollector.collect_sources.<locals>.<genexpr>  sD      
4
 P %9#||<< #()  P   25c           
   3  n   <"   T F*  p\        VSSP                  P                  R R SR7      x  K,  	  R# 5i)Tr%  Nr(  r*  s   & r$   r  r,    sB      
5
 ' %9#||<<#')  'r-  z* z' location(s) to search for versions of :
)r   r   )collectionsOrderedDictr  get_index_urls_locationsvaluesr   rf   isEnabledForloggingDEBUG	itertoolschainr   r+   rg   rh   r   r   )r9   r!  r"  index_url_sourcesfind_links_sourcessliness   fff    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)F)r<   r=   r>   r?   r   r8   classmethodr  propertyr   r  r>  r@   r"   r&   r$   r  r    sE      B , ,B,
 ,
r&   r  r6   )T)Or   
__future__r   r1  email.messagern   r   r8  r   r6  r   urllib.parserW   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   	getLoggerr<   rf   r   rk   r-   	Exceptionr/   rN   rP   r`   ri   rs   ru   r   r   r   rx   r   r   r   r   r   r  r"   r&   r$   <module>rY     sA   #       	   > > ! "   ! ) @ ; * 9 4 8 9 9 ! A A			8	$ c*)Y )@,	y 	$<~	# 	#B B(  8 $. . .(Z 8@
:z,z ,
h
 h
r&   