+
    :1jB%                       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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IHt ^RIHtHtHtH t H!t!H"t" ]
'       d   ^ RI#t#^RI$H%t% ^RIH&t& ]PN                  ! ](4      t)R t*]R 4       t+R R lt,RR R llt-R R lt. ! R R]/4      t0R R lt1 ! R R] 4      t2R# )zZstd interface for repodata.)annotationsN)contextmanager)TYPE_CHECKING)	HTTPError)REPODATA_FN)context)json)mask_anaconda_token)
deprecated)disable_ssl_verify_warning)get_session)URL_KEYRepodataOnDiskRepodataStateRepoInterfaceResponse304ContentUnchangedconda_http_errors)Session)RepodataCachec                0    \         P                  ! RW4      # )zChange file extension in URL.z(\.\w+)$)resub)urlexts   &&<lib/python3.14/site-packages/conda/gateways/repodata/zstd.pywithextr   *   s    66+s((    c              #     "   \         P                  ! 4       pRx  \         P                  ! 4       p\        P                  RWV,
          4       R# 5i)z&Context manager for timing operations.Nz%sTook %0.02fs)time	monotoniclogdebug)messagebeginends   &  r   timemer%   /   s5      NNE	
..
CIIu5s   AAc                    V ^8  d   QhRRRR/# )   	json_pathpathlib.Pathstater    )formats   "r   __annotate__r-   8   s      \ - r   c                p    / pV P                  4       '       d   VP                  R4      pV'       d   W2R&   V# )z+Build caching headers for a path and state._etagzif-none-match)existsget)r(   r*   headersetags   &&  r   build_headersr4   8   s4    Gyy!'+O$Nr   c               (    V ^8  d   QhRRRRRRRR/# )	r'   r(   r)   sessionr   r*   zRepodataState | None	dest_pathzpathlib.Path | Noner+   )r,   s   "r   r-   r-   B   s2     ( (( (  	( #(r   c                j   Vf   TpT;'       g    \        4       p\        W4      p\        P                  \        P                  3pVP                  V RWvR7      p\        P                  RWP                  4       VP                  4        ^ p	VP                  ^8X  d   V'       d9   \        P                  ! 4       p
V
P                  VP                  R4      RR7      pMVP                  R4      pT;_uu_ 4       pVP                  R
R7       F  pVP!                  V4       K  	  RRR4       VP"                  '       dH    \%        VP                  R,          4      p	\        P-                  R	WP"                  P                  4       V#   + '       g   i     Lk; i  \&        \(        \*        3 d     LWi ; i)zDownload url to dest_path, optionally decompressing zstd.

json_path: Path of old cached data (ignore etag if not exists).
dest_path: Path to write new data.
NT)streamtimeoutr2   z%s %swb)closefd)
chunk_sizezContent-LengthzDownload %d bytes %ri @  )r   r4   r   remote_connect_timeout_secsremote_read_timeout_secsr1   r    r!   r2   raise_for_statusstatus_code	zstandardZstdDecompressorstream_writeropeniter_contentwriterequestintKeyError
ValueErrorAttributeErrorinfo)r   r(   r6   r*   is_zstr7   r2   r:   responselengthdecompressorwriterrepodatablocks   &&&&&&        r   download_repodatarU   B   sh    	$$]_EI-G1173S3SSG{{3tW{NHIIgs,,-Fs"$557L!//t$ 0 F
 ^^D)FVx!..'.Bu% C  	))*:;<F 	'1A1A1I1IJO V *n5 		s   8+F>F F	F21F2c                    V ^8  d   QhRRRR/# )r'   er   returnboolr+   )r,   s   "r   r-   r-   m   s     ; ;Y ;4 ;r   c                    V P                   f   R# V P                   P                  pRTu;8*  ;'       d    R8  Mu ;'       d    VR8g  # )z4Determine if HTTP error is a 4xx error (except 416).Fi  i  i  )rO   rA   )rW   rA   s   & r   _is_http_error_most_400_codesr[   m   s>    zz**((K+###::s(::r   c                      ] tR t^utRtRtR# )ZstSkipz#Exception to skip zst format check.r+   N)__name__
__module____qualname____firstlineno____doc____static_attributes__r+   r   r   r]   r]   u   s    -r   r]   c          
     ,    V ^8  d   QhRRRRRRRRR	R
/# )r'   r*   r   r6   r   cacher   	temp_pathr)   rX   dict | Noner+   )r,   s   "r   r-   r-   y   sC     N NN 	N
 N N Nr   c               J   VP                   pRp\        RV  R24      ;_uu_ 4         \        \        V R4      VVVVRR7      pRRR4       XP                  P                  R4      VR&   VP                  P                  R4      VR&   VP                  P                  R4      VR&   VP                  R8X  d   \!        4       hVP                  ^8X  db   V'       d   R# VP#                  R4      ;_uu_ 4       p	\$        P&                  ! V	P)                  4       P+                  R4      4      p
RRR4       V
# R#   \        \
        P                  3 d   p\        T\
        P                  4      '       d+   \        P                  R\        \        T R4      4      T4       \        T\        4      '       d   \        T4      '       g   h TP                  RR4       Rp\        \        T R	4      TTTTR
7      p Rp?ELRp?ii ; i  + '       g   i     EL; i  + '       g   i     X
# ; i)a  
Download .json.zst file and return parsed JSON.

Args:
    url: URL to download from
    state: Repodata state
    session: Session object
    cache: Repodata cache
    temp_path: Temporary path to write json to
Returns:
    dict | None: Parsed JSON or None if error
FzDownload complete  z	.json.zstT)r6   r*   r7   rN   z9Could not decompress %s as zstd. Fall back to .json. (%s)zstz.json)r6   r*   r7   Nzlast-modified_modr3   r/   zcache-control_cache_controli0  rbzutf-8)cache_path_jsonr%   rU   r   r   rB   	ZstdError
isinstancer    warningr	   r[   set_has_formatr2   r1   rA   r   rE   r   loadsreaddecode)r   r*   r6   re   rf   r(   is_fallbackrO   rW   frepodata_jsons   &&$$$      r   request_url_zstd_statery   y   s   ( %%IK	$SE+	,	,	([)#H 
-B $$((9E&M%%))&1E'N&..22?CE
 s")++ s"  ^^D!!Q JJqvvxw'?@M "  Y 9../ 	!Y0011O'[(AB
 !Y''0Ma0P0P   .K(W%#H	 
-	,	,b "! s;   G=D444H4G:B G5/G=5G::G==H	H"	c                      ] tR t^tR R lt]]! RR4      R 4       4       t]]! RR4      R 4       4       tR R lt	R	 R
 lt
R R ltRtR# )ZstdRepoInterfacec               (    V ^8  d   QhRRRRRRRR/# )	r'   r   strrepodata_fn
str | Nonere   r   rX   Noner+   )r,   s   "r   r-   ZstdRepoInterface.__annotate__   s2     7 77  7
 7 
7r   c               	    \         P                  R V P                  P                  4       W0n        Wn        T;'       g    \        V n        R# )zUsing %sN)r    r!   	__class__r^   _cache_urlr   _repodata_fn)selfr   r~   re   kwargss   &&&$,r   __init__ZstdRepoInterface.__init__   s6     			*dnn556	'66;r   z26.9z27.3c                	    \         # )N)r    r   s   &r   _logZstdRepoInterface._log   s	     
r   c                	.    \         P                  ! R 4      # )zconda.stderrlog)logging	getLoggerr   s   &r   
_stderrlogZstdRepoInterface._stderrlog   s       !233r   c                    V ^8  d   QhRRRR/# )r'   r*   dict | RepodataStaterX   r   r+   )r,   s   "r   r-   r      s      2 z r   c                8    V P                  V4       \        4       h)zL
Fetch newest repodata if necessary.

Always writes to ``cache_path_json``.
)repodata_parsedr   r   r*   s   &&r   rS   ZstdRepoInterface.repodata   s     	U#r   c                    V ^8  d   QhRRRR/# )r'   r*   r   rX   rg   r+   )r,   s   "r   r-   r      s     9) 9)%9 9)k 9)r   c           
        \        V P                  4      p\        P                  '       g   \	        4        V P                   RV P
                   2pV P                  V4      pV P                  P                  V P                  P                   R\        P                  ! ^4      P                  4        R2,          p \        V P                  V P
                  4      ;_uu_ 4        \        VVVV P                  VR7      pVP                  V4       V P                  V\         &   V P                  P"                  P                  V4       RRR4       VP%                  4       '       d   V P                  P'                  V4        TP+                  4        Xf   \/        4       hT#   + '       g   i     Lb; i  \(         d    h i ; i  \,         d     L@i ; i   TP+                  4        i   \,         d     i i ; i; i)z
Use this to avoid a redundant parse when repodata is updated.

When repodata is not updated, it doesn't matter whether this function or
the caller reads from a file.
/.z.tmp)r6   re   rf   N)r   r   r   
ssl_verifyr   r   _repodata_state_copyr   	cache_dirnameosurandomhexr   ry   updater   r*   r0   replacer   unlinkOSErrorr   )r   r*   r6   repodata_urlstate_rf   repodata_json_or_nones   &&     r   r   !ZstdRepoInterface.repodata_parsed   s    dii(!!!&())Ad&7&7%89 **51
 KK!!t{{'7'7&8"**Q-:K:K:M9Nd$SS 		"499d.?.?@@(> #++')% V$!%g!!((/! A$ !!##I.  " !( ""((E A@( + 		    " sm   <(F5 $A$F"F5 &F5 G "F2	-F5 5GG GGG:G)(G:)G74G:6G77G:c                    V ^8  d   QhRRRR/# )r'   r*   r   rX   r   r+   )r,   s   "r   r-   r   (  s      *> = r   c                   \        V\        4      '       d7   \        VP                  VP                  VP                  \        V4      R7      # \        V P                  P                  V P                  P                  V P                  VR7      # )z<Create a copy of state to avoid modifying the caller's dict.)rn   cache_path_stater~   dict)rp   r   rn   r   r~   r   r   r   r   s   &&r   r   &ZstdRepoInterface._repodata_state_copy(  ss    e]++  % 5 5!&!7!7!--%[	  ! $ ; ;!%!=!= --	 r   )r   r   r   N)r^   r_   r`   ra   r   propertyr
   r   r   rS   r   r   rc   r+   r   r   r{   r{      sb    7     4   49)v r   r{   )FN)3rb   
__future__r   r   r   r   r   
contextlibr   typingr   rB   requestsr   base.constantsr   base.contextr   common.serializer   
common.urlr	   deprecationsr
   connection.downloadr   connection.sessionr    r   r   r   r   r   r   pathlib
connectionr   r   r   r^   r    r   r%   r4   rU   r[   	Exceptionr]   ry   r{   r+   r   r   <module>r      s    # "  	 	  %     ) # $ - & < ,  $!)
 6 6(V;.i .Nbm mr   