
    wBf3                       d Z ddlmZ ddlZddlZddlmZ ddlmZ ddl	m
Z
 dd	lmZ d
dlmZmZmZmZmZmZmZmZmZ ddlmZ erd
dlmZ  ej2                  e      Z G d de      Z G d de      Z G d de      Zy)zJLAP interface for repodata.    )annotationsN)TYPE_CHECKING   )context   )disable_ssl_verify_warning)get_session   )	CACHE_CONTROL_KEYETAG_KEYLAST_MODIFIED_KEYURL_KEYRepodataOnDiskRepodataStateRepoInterfaceResponse304ContentUnchangedconda_http_errors   )fetch)RepodataCachec                  <    e Zd Z	 	 	 	 	 	 	 	 ddZddZddZd	dZy)
JlapRepoInterfacec                   t         j                  d| j                  j                         || _        || _        || _        t        j                  t              | _	        t        j                  d      | _
        y )NzUsing %szconda.stderrlog)logdebug	__class____name___cache_url_repodata_fnlogging	getLogger_log
_stderrlog)selfurlrepodata_fncachekwargss        Flib/python3.12/site-packages/conda/gateways/repodata/jlap/interface.py__init__zJlapRepoInterface.__init__"   sW     			*dnn556	'%%h/	!++,=>    c                8    | j                  |       t               )zd
        Fetch newest repodata if necessary.

        Always writes to ``cache_path_json``.
        )repodata_parsedr   r%   states     r*   repodatazJlapRepoInterface.repodata4   s     	U#r,   c                   t        | j                        }t        j                  s
t	                | j                   d| j
                   }| j                  |      }| j                  j                  | j                  j                   dt        j                  d      j                          dz  }	 t        | j                  | j
                        5  t        j                  |||| j                  |      }|j!                  |       | j                  |t"        <   |j%                  di       j%                  d      }|rH|j%                  d      |t&        <   |j%                  d	      |t(        <   |j%                  d
      |t*        <   | j                  j,                  j!                  |       ddd       |j/                         r| j                  j1                  |       	 |j7                          
t;               |S # 1 sw Y   SxY w# t        j2                  $ r t5               w xY w# t8        $ r Y Fw xY w# 	 |j7                          w # t8        $ r Y w w xY wxY w)z
        JLAP has to parse the JSON anyway.

        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.
        /.r
   z.tmp)sessionr(   	temp_pathjlapheadersetagzlast-modifiedzcache-controlN)r	   r   r   
ssl_verifyr   r    _repodata_state_copyr   	cache_dirnameosurandomhexr   r   request_url_jlap_stateupdater   getr   r   r   r0   existsreplaceJlap304NotModifiedr   unlinkOSErrorr   )r%   r0   r5   repodata_urlstate_r6   repodata_json_or_noner8   s           r*   r.   z!JlapRepoInterface.repodata_parsed=   s    dii(!!&())Ad&7&7%89 **51
 KK!!t{{'7'7&8"**Q-:K:K:M9Nd$SS 	$	"499d.?.?@ 0(-(D(D #++')% V$!%g))FB/33 &-kk&&9E(O/6{{?/KE+,/6{{?/KE+,!!((//02 !##I.  " !( ""((S0 06 '' 	0-//	0    " sg   1 H CG<*3H H) <HH H&&H8 )	H54H58I:I
I	IIIIc                    t        |      S )N)dict)r   r/   s     r*   r;   z&JlapRepoInterface._repodata_state_copy   s    %((r,   N)r&   strr'   
str | Noner(   r   returnNone)r0   dict | RepodataStaterP   rO   )r0   rR   rP   zdict | Noner0   rR   )r   
__module____qualname__r+   r1   r.   r;    r,   r*   r   r   !   s>    ??  ?
 ? 
?$B)H)r,   r   c                  D     e Zd ZU ded<    e       d fd
Z fdZ xZS )RepodataStateSkipFormatzset[str]skip_formats)rY   c               D    t        |   |i | t        |      | _        y )N)superr+   setrY   )r%   rY   argsr)   r   s       r*   r+   z RepodataStateSkipFormat.__init__   s"    $)&)-r,   c                @    || j                   v ryt        | 	  |      S )NF)rY   r[   should_check_format)r%   formatr   s     r*   r_   z+RepodataStateSkipFormat.should_check_format   s$    T&&&w*622r,   )r   rT   rU   __annotations__r\   r+   r_   __classcell__)r   s   @r*   rX   rX      s    +.5 .3 3r,   rX   c                      e Zd ZdZddZy)ZstdRepoInterfacezI
    Support repodata.json.zst (if available) without checking .jlap
    c                    t        |dg      S )Nr7   )rM   rY   )rX   r/   s     r*   r;   z&ZstdRepoInterface._repodata_state_copy   s    &EIIr,   NrS   )r   rT   rU   __doc__r;   rV   r,   r*   rd   rd      s    Jr,   rd   )rf   
__future__r   r!   r>   typingr   base.contextr   connection.downloadr   connection.sessionr	    r   r   r   r   r   r   r   r   r   r   r   r"   r   r   r   rX   rd   rV   r,   r*   <module>rm      su    # "  	   $ = -
 
 
  g!a) a)H
3m 
3J) Jr,   