+
    WGj]&                       R t ^ RIH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HtHt ^ RIHt ^ RIHtHt ^ RIHt ^ R	IHt R(t]P0                  ! ]4      t ! R
 R]4      t ! R R]4      t ! R R]	4      tR R ltR R lt R R lt!R R lt"R)R R llt#R*R R llt$R*R R llt%R R lt&R*R  R! llt'R" R# lt(R$ R% lt)R& R' lt*R# )+z7Collect links from simple index or find links location.)annotationsN)datetime)
HTMLParser)IterableMapping
NamedTuple)parse)FetcherResponse)Link)is_archive_filec                      ] tR t^tRtR# )LinkCollectError N)__name__
__module____qualname____firstlineno____static_attributes__r       1lib/python3.14/site-packages/unearth/collector.pyr   r      s    r   r   c                  @    ] tR t^t$ R]R&   R]R&   R]R&   R]R&   R	tR
# )	IndexPager   linkbytescontentz
str | Noneencodingstrcontent_typer   N)r   r   r   r   __annotations__r   r   r   r   r   r      s    
JNr   r   c                  :   a  ] tR t^%tR V 3R lltR R ltRtV ;t# )IndexHTMLParserc                   V ^8  d   QhRR/# )   returnNoner   )formats   "r   __annotate__IndexHTMLParser.__annotate__&   s     7 7$ 7r   c                	@   < \         SV `  4        R V n        . V n        R # N)super__init__base_urlanchors)self	__class__s   &r   r,   IndexHTMLParser.__init__&   s    $(46r   c               $    V ^8  d   QhRRRRRR/# )r#   tagr   attrszlist[tuple[str, str | None]]r$   r%   r   )r&   s   "r   r'   r(   +   s#     - -3 -/K -PT -r   c                	    VR 8X  d7   V P                   f)   \        V4      P                  R4      pVe	   W0n         R# R# VR8X  d'   V P                  P	                  \        V4      4       R# R# )baseNhrefa)r-   dictgetr.   append)r/   r3   r4   r-   s   &&& r   handle_starttagIndexHTMLParser.handle_starttag+   sV    &=T]]2E{v.H# ( $CZLLU, r   )r.   r-   )r   r   r   r   r,   r<   r   __classcell__)r0   s   @r   r!   r!   %   s    7 7
- -r   r!   c               $    V ^8  d   QhRRRRRR/# )r#   allowedr   actualr$   boolr   )r&   s   "r   r'   r'   4   s!     / /# /s /t /r   c                $    V R 8H  ;'       g    W8H  # )*r   )r@   rA   s   &&r   _compare_origin_partrE   4   s    c>..W..r   c               $    V ^8  d   QhRRRRRR/# )r#   fetcherr	   locationr   r$   rB   r   )r&   s   "r   r'   r'   8   s!        g    $  r   c                V   VP                   P                  P                  R4      w   r#VP                   P                  ;'       g    RVP                   P                  rTV P                  4        Fr  w  rgp\        Wc4      '       g   K   \        P                  ! V4      p	\        P                  ! V4      p
W9  d   KN   \        Yf   RM
\        V4      4      '       g   Kq   R# 	  \        P                  RVP                  4       R#   \         d    \        Yt4      '       g    K   Lji ; i)z_
Determine if the origin is a trusted host.

Args:
    location (Link): The location to check.
+ rD   TzHSkipping %s for not being trusted, please add it to `trusted_hosts` listF)parsedscheme
rpartitionhostnameportiter_secure_originsrE   	ipaddress
ip_address
ip_network
ValueErrorr   loggerwarningredacted)rG   rH   _rM   hostrP   secure_schemesecure_hostsecure_portaddrnetworks   &&         r   is_secure_originr`   8   s    ??))44S9LAq))//R1E1E$3:3N3N3P/K#M::		''-D**;7G " # $K#d)TT# 4Q& NNR #  	':: ;	s   ,DD('D(c                    V ^8  d   QhRRRR/# r#   pager   r$   Iterable[Link]r   )r&   s   "r   r'   r'   [   s     
 
) 
 
r   c           	   #  t  "   \        4       pTP                  V P                  P                  V P                  ;'       g    R4      4       VP
                  ;'       g    V P                  P                  pVP                   F  pVP                  R4      pVf   K  \        P                  ! W$4      pVP                  R4      pVP                  R4      pVP                  RVP                  R4      4      pRp	V'       d#   VP                  R4      w  rpV'       d   W/p	MR	p	\        VVVVV	R
7      x  K  	  R# 5i)zPEP 503 simple index APIutf-8r7   Nzdata-requires-pythonzdata-yankedzdata-core-metadatadata-dist-info-metadata=T)yank_reasonrequires_pythondist_info_metadata)r!   feedr   decoder   r-   r   url_without_fragmentr.   r:   r   urljoin	partitionr   )rc   parserr-   anchorr7   urlrj   ri   metadata_hashrk   	hash_namehas_hash
hash_values   &            r   parse_html_pagerx   [   s
    F
KK##DMM$<$<W=>@@$))"@"@H..zz&!<mmH+ **%;<jj/

 &**-F"G
 <@.;.E.Ec.J+I&/%<"%)"#+1
 	
# !s   AD8CD8c                    V ^8  d   QhRRRR/# rb   r   )r&   s   "r   r'   r'   z   s     
 
i 
N 
r   c              #  p  "   \         P                  ! V P                  4      pV P                  P                  pVP                  R. 4       F  pVP                  R4      pV'       g   K  \        P                  ! W$4      pVP                  R4      pVP                  R4      ;'       g    RpVP                  RVP                  R4      4      pVP                  R4      p\        TTTTTTVP                  R	4      ;p	'       d'   \        P                  ! V	P                  R
R4      4      MRR7      x  K  	  R# 5i)zPEP 691 JSON simple APIfilesrs   zrequires-pythonyankedNzcore-metadatarg   hasheszupload-timeZz+00:00)ri   rj   rk   r}   upload_time)jsonloadsr   r   rn   r:   r   ro   r   r   fromisoformatreplace)
rc   datar-   filers   rj   ri   rk   r}   r   s
   &         r   parse_json_responser   z   s    ::dll#Dyy--H"%hhuommH*&*hh/@&A"&((8"4"<"<;?88TXX&?@<
 )-(:#+1#xx666 !..{/B/B3/QR

 
	
 &s   B%D6(BD6c          
     ,    V ^8  d   QhRRRRRRRRR	R
/# )r#   sessionr	   rH   r   expandrB   headersMapping[str, str] | Noner$   rd   r   )r&   s   "r   r'   r'      sA     %@ %@%@%@ %@ &	%@
 %@r   c              #    "   \         P                  RVP                  4       VP                  '       Ed   VP                  pVP                  4       '       d   V'       dh   VP                  4        FQ  pVP                  4       p\        V4      '       d!   \        V \        V4      V4       Rj  xL
  KD  \        V4      x  KS  	  R# \        VP                  R4      P                  4       4      p\        WV4       Rj  xL
  R# \        \        V4      4      '       d   \        WV4       Rj  xL
  R# Vx  R# \        W4      '       d   VP                  '       g   Vx  \        W4       Rj  xL
  R#  L Lz LL L5i)a  Collect package links from a remote URL or local path.

If the path is a directory and expand is True, collect links from all HTML files
as well as local artifacts. Otherwise, collect links from $dir/index.html.
If the path is a file, parse it and collect links from it.
zCollecting links from %sNz
index.html)rV   debugrX   is_file	file_pathis_diriterdiras_uri_is_html_file_collect_links_from_indexr   joinpathr   r`   is_vcs)r   rH   r   r   pathchildfile_url
index_htmls   &&&&    r   collect_links_from_locationr      s!     LL+X->->?!!;;==!\\^E$||~H$X..#<#T(^W$   #8n, , "$--"="D"D"FG
4W'RRRSY''4WPPP G..xN,W???# S Q 	@s\   AE?E? AE?-E7.AE?>E9?/E?.E;/.E?E?0E=1E?9E?;E?=E?c               (    V ^8  d   QhRRRRRRRR/# )	r#   r   r	   rH   r   r   r   r$   r   r   )r&   s   "r   r'   r'      s,       $/Gr   c                f   VP                   '       d   \        R 4      h\        WV4      p\        VRR4      pV'       d   RMRp\        P                  RVP                  V4       \        \        \        VP                  4      4      VP                  VP                  VP                  R,          4      # )zIt is a VCS link.
from_cacheFz (from cache)rK   zFetching HTML page %s%sContent-Type)r   r   _get_html_responsegetattrrV   r   rX   r   r   r   rs   r   r   r   )r   rH   r   respr   
cache_texts   &&&   r   
fetch_pager      s     233g9D|U3J$.BJ
LL*H,=,=zJS]T\\4==$,,~:V r   c               (    V ^8  d   QhRRRRRRRR/# )	r#   r   r	   rH   r   r   r   r$   rd   r   )r&   s   "r   r'   r'      s,     ) )) $)/G))r   c                F   \        W4      '       g   . #  \        WV4      pVP                  P                  4       pVP	                  R 4      '       d   \        V4      # \        V4      #   \         d.   p\        P                  RTP                  T4       . u Rp?# Rp?ii ; i)#application/vnd.pypi.simple.v1+jsonz#Failed to collect links from %s: %sN)r`   r   r   lower
startswithr   rx   r   rV   rW   rX   )r   rH   r   rc   content_type_les   &&&   r   r   r      s     G..	
)'W5
 **002$$%JKK&t,,"4((  <h>O>OQRS	s   A( (B 3"BB B c                    V ^8  d   QhRRRR/# )r#   r   r   r$   rB   r   )r&   s   "r   r'   r'      s     J JC JD Jr   c                F    \         P                  ! V R R7      ^ ,          R8H  # )F)strict	text/html)	mimetypes
guess_type)r   s   &r   r   r      s    7:kIIr   c               (    V ^8  d   QhRRRRRRRR/# )	r#   r   r	   rH   r   r   r   r$   r
   r   )r&   s   "r   r'   r'      s,       $/Gr   c                    \        VP                  4      '       d   \        W4       T P                  VP                  R RP                  . RO4      /T;'       g    / CR7      p\        V4       \        V4       V# )Accept, )r   )r   z*application/vnd.pypi.simple.v1+html; q=0.1ztext/html; q=0.01)r   filename_ensure_index_responser:   
normalizedjoin_check_for_status_ensure_index_content_type)r   rH   r   r   s   &&& r   r   r      sz     x(()) 	w1;;dii	
 }}"	
  D dt$Kr   c               $    V ^8  d   QhRRRRRR/# )r#   r   r	   rH   r   r$   r%   r   )r&   s   "r   r'   r'      s!     	% 	%G 	%t 	% 	%r   c                    VP                   P                  R9  d   \        R4      hV P                  VP                  4      p\        V4       \        V4       R# )httpzaNotHTTP: the file looks like an archive but its content-type cannot be checked by a HEAD request.N>   r   https)rL   rM   r   headrs   r   r   )r   rH   r   s   && r   r   r      sK    %663
 	

 <<%Ddt$r   c                    V ^8  d   QhRRRR/# r#   r   r
   r$   r%   r   )r&   s   "r   r'   r'     s     N NH N Nr   c                   \        V R 4      '       d   V P                  pMV P                  p\        V\        4      '       d    VP                  R4      pRV P                  u;8:  d   R8  d   M M\        RV P                   RV 24      hRV P                  u;8:  d   R8  d    M R	# \        RV P                   RV 24      hR	#   \         d    TP                  R4      p Li ; i)
reasonrf   z
iso-8859-1i  i  zClient Error(z): iX  zServer Error(N)	hasattrr   reason_phrase
isinstancer   rm   UnicodeDecodeErrorstatus_coder   )r   r   s   & r   r   r     s    tX##&%  	1]]7+F d$$t/?/?.@F8LMM
d$$$t/?/?.@F8LMM % " 	1]]<0F	1s   C C$#C$c                    V ^8  d   QhRRRR/# r   r   )r&   s   "r   r'   r'     s     
 
X 
$ 
r   c                    V P                   P                  R R4      pVP                  4       pVP                  \        4      '       d   R# \        RV RRP                  \        4       R24      h)r   UnknownNzContent-Type unsupported: z. The only supported are r   .)r   r:   r   r   SUPPORTED_CONTENT_TYPESr   r   )r   r   r   s   &  r   r   r     sl    <<##NI>L!'')N  !899

$\N 3""&)),C"D!EQ	H r   )r   z#application/vnd.pypi.simple.v1+htmlr   )FNr*   )+__doc__
__future__r   rR   r   loggingr   r   html.parserr   typingr   r   r   urllibr   unearth.fetchersr	   r
   unearth.linkr   unearth.utilsr   r   	getLoggerr   rV   	Exceptionr   r   r!   rE   r`   rx   r   r   r   r   r   r   r   r   r   r   r   r   <module>r      s    = "      " 0 0  .  ) 
 
		8	$	y 	
 -j -/ F
>
8%@P)$J4	%N$
r   