+
    i?                       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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.H/t/ ^ RI0H1t1 ^ RI2H3t3 ^RI4H5t5H6t6H7t7 ]	Pp                  ! ]94      t:]];];3,          t<R R lt= ! R R]>4      t?R R lt@ ! R R]>4      tAR R ltBR R  ltCR! R" ltD ! R# R$4      tE ! R% R&]4      tFR' R( ltG]GR) R* l4       tH]! R+R,7       ! R- R.4      4       tI ! R/ R0]4      tJR;R1 R2 lltKR<R3 R4 lltLR5 R6 ltM ! R7 R8]4      tN ! R9 R:4      tOR# )=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)url_to_path)vcs)CandidatesFromPage
LinkSourcebuild_sourcec                    V ^8  d   QhRRRR/# )   urlstrreturn
str | None )formats   "c/Users/ahmad/.openclaw/workspace/venv/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__r2   r3   )selfr2   r3   	__class__s   &&&r%   r9   _NotAPIContent.__init__:   s    4((r'   )r2   r3   )__name__
__module____qualname____firstlineno__r9   __static_attributes____classcell__r;   s   @r%   r0   r0   9   s    ) )r'   r0   c                    V ^8  d   QhRRRR/# )r   responser   r!   r4   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+   r0   requestmethod)rE   r2   content_type_ls   &  r%   _ensure_api_headerrO   @   s^     ##''	BL!'')N  	
  	
'7'7'>'>
??r'   c                      ] tR t^VtRtR# )_NotHTTPr#   N)r=   r>   r?   r@   rA   r#   r'   r%   rQ   rQ   V   s    r'   rQ   c               $    V ^8  d   QhRRRRRR/# )r   r   r    sessionr   r!   r4   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urlsplitrQ   headr   rO   )r   rS   r-   netlocpathqueryfragmentresps   &&      r%   _ensure_api_responsera   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    rS   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.
rS   zGetting page %sAcceptz, zCache-Controlz	max-age=0)rJ   zFetched page %s as %srG   rH   )rI   z*application/vnd.pypi.simple.v1+html; q=0.1ztext/html; q=0.01)r   r   filenamera   loggerdebugr   rK   joinr   rO   rJ   )r   rS   r`   s   && r%   _get_simple_responserj   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   rJ   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.rG   zcontent-typecharsetN)emailmessageMessage	get_paramr    )rJ   mrn   s   &  r%   _get_encoding_from_headersrt      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!   r4   r#   )r$   s   "r%   r&   !CacheablePageContent.__annotate__   s      \ d r'   c                	:    VP                   '       g   Q hWn        R # r7   )cache_link_parsingrx   r:   rx   s   &&r%   r9   CacheablePageContent.__init__   s    &&&&&	r'   c                    V ^8  d   QhRRRR/# )r   otherobjectr!   boolr#   )r$   s   "r%   r&   rz      s     Q QF Qt Qr'   c                	    \        V\        V 4      4      ;'       d.    V P                  P                  VP                  P                  8H  # r7   )
isinstancetyperx   r   )r:   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&   rz      s     # ## #r'   c                	@    \        V P                  P                  4      # r7   )hashrx   r   r:   s   &r%   __hash__CacheablePageContent.__hash__   s    DIIMM""r'   )rx   N)r=   r>   r?   r@   r9   r   r   rA   r#   r'   r%   rv   rv      s    Q# #r'   rv   c                  "    ] tR t^tR R ltRtR# )
ParseLinksc                    V ^8  d   QhRRRR/# r   rx   ry   r!   zIterable[Link]r#   )r$   s   "r%   r&   ParseLinks.__annotate__   s    AA\AnAr'   c                	    R # r7   r#   r}   s   &&r%   __call__ParseLinks.__call__   s    cr'   r#   N)r=   r>   r?   r@   r   rA   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_pagerv   r!   
list[Link]r#   )r$   s   "r%   r&   /with_cached_index_content.<locals>.__annotate__   s     - - 4 - -r'   c                :   < \        S! V P                  4      4      # r7   )listrx   )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   rx   ry   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      # r7   )r|   rv   r   )rx   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.
rI   filesNzutf-8)page_urlbase_url)r2   r*   r+   jsonloadscontentrK   r   	from_jsonr   HTMLLinkParserencodingfeeddecoder   anchorsfrom_element)
rx   rN   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# )ry   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    r2   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      # r7   )r   r   r   s   &r%   __str__IndexContent.__str__  s    #DHH--r'   r#   N)	r=   r>   r?   r@   __doc____annotations__r|   r   rA   r#   r'   r%   ry   ry      s4     N	H##. .r'   ry   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!   r4   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)r8   r9   r   r   r   )r:   r   r;   s   &&r%   r9   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!   r4   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)r:   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#   )r:   r   namevalues   &&  r%   r   HTMLLinkParser.get_href!  s     KDv~ ! r'   )r   r   r   )
r=   r>   r?   r@   r   r9   r   r   rA   rB   rC   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!   r4   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)rg   rh   )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   rE   r   r|   r   r!   ry   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      # )rG   )r   r   r|   )rt   rJ   ry   r   r   )rE   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   rS   r   r!   IndexContent | Noner#   )r$   s   "r%   r&   r&   ?  s"     9 9T 9z 9>Q 9r'   c                  V P                   P                  R ^4      ^ ,          p\        V4      pV'       d   \        P	                  RVV 4       R# VP                  R4      '       d   \        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\!        W@P"                  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\/        Y4        Rp?R# Rp?i\0         d   p\/        Y4        Rp?R# Rp?i\2         d;   pRpT\5        T4      ,          p\/        Y\        P6                  R7        Rp?R# Rp?i\8        P:                   d   p\/        T RT 24        Rp?R# Rp?i\8        P<                   d    \/        T R4        R# i ; i)#zICannot look at %s URL %s because it does not support lookup as web pages.Nzfile:/z
index.htmlz# file: URL is directory, getting %srd   )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.   rg   warningr+   osr]   isdirr   endswithrX   rY   urljoinrh   rj   r   r|   rQ   r0   r3   r2   r   r   r   r   r    infor   ConnectionErrorTimeout)r   rS   r   
vcs_schemer`   excr   s   &$     r%   _get_index_contentr   ?  s   
((..a
 
#C #3'JW	

  ~~g277==S1A#B#B ||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   ,D !I2I;I<,E..I;I<FIIF,,I9I:/G//IIHI3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   rA   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   rS   r   search_scoper   r!   r4   r#   )r$   s   "r%   r&   LinkCollector.__annotate__  s(       " 
	r'   c                	    W n         Wn        R # r7   r  rS   )r:   rS   r  s   &&&r%   r9   LinkCollector.__init__  s    
 )r'   c               (    V ^8  d   QhRRRRRRRR/# )	r   rS   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r7   r   ).0r   s   & r%   	<genexpr>'LinkCollector.create.<locals>.<genexpr>  s     Ijs-c22js   )r   r   no_index)rS   r  )
	index_urlextra_index_urlsr  rg   rh   ri   r   r   creater   )clsrS   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                  # r7   )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.
rd   )r   rS   )r:   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   rS   is_secure_originr  locr   r  r:   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   rg   isEnabledForloggingDEBUG	itertoolschainr   r,   rh   ri   r   r   )r:   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   r9   classmethodr  propertyr   r  r<  rA   r#   r'   r%   r   r     sE      B , ,B,
 ,
r'   r   r7   )T)Pr   
__future__r   r/  email.messagero   r   r6  r   r4  r   urllib.parserX   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.utils.urlsr   pip._internal.vcsr   sourcesr   r   r   	getLoggerr=   rg   r    rl   r.   	Exceptionr0   rO   rQ   ra   rj   rt   rv   r   r   r   ry   r   r   r   r   r   r   r#   r'   r%   <module>rW     sA   #       	  > > ! "   ! ) @ ; * 9 4 8 9 9 0 ! A A			8	$ c*)Y )@,	y 	$<~	# 	#B B(  8 $. . .(Z 8@
9x,z ,
h
 h
r'   