
    $TXge                         d Z ddlZddlZddlmZ ddlmZmZmZ ddl	m
Z
mZ ddlmZ ddlmZmZ d	d
lmZ  ee      Zd Zd Zd Zd Zd Zedk(  r e e              yy)z<Anaconda-client (binstar) token management for CondaSession.    N)	getLogger)isdirisfilejoin)S_IREADS_IWRITE)user_config_dir   )
quote_plusunquote_plus   )rm_rfc                 4    t        j                  dd| d      S )Nz([./])api([./]|$)z	\1conda\2r   )count)resub)urls    >lib/python3.12/site-packages/conda/gateways/anaconda_client.pyreplace_first_api_with_condar      s    66&cCC    c                      dt         j                  v r1t         j                  j                  t         j                  d   d      S t	        dd      S )NBINSTAR_CONFIG_DIRdatabinstarContinuumIO)appname	appauthor)osenvironpathr   r	    r   r   _get_binstar_token_directoryr"      s:    rzz)ww||BJJ';<fEEyMJJr   c                     i } t               }t        |      s| S t        j                  |      D ]  }|j                  dd  dk7  rt        j                  ddt        |j                              }t        |j                        5 }|j                         }d d d        x| |<   | t        |      <    | S # 1 sw Y    xY w)Ni.tokenz\.token$ )r"   r   r   scandirnamer   r   r   openr    readr   )tokens	token_dir	tkn_entryr   ftokens         r   read_binstar_tokensr/      s    F,.IZZ	*	>>"#(*ff["l9>>&BC)..!QFFHE "BGGsf9#>? + M "!s   B44B=	c                 n   t               }t        |      st        j                  |       t	        |t        |        d      }t        |      rt        j                  |       t        |d      5 }|j                  |       d d d        t        j                  |t        t        z         y # 1 sw Y   +xY w)Nr$   w)r"   r   r   makedirsr   r   r   unlinkr(   writechmodr   r   )r   r.   r+   	tokenfilefds        r   set_binstar_tokenr8   /   s    ,.I
IY:c?"36 :;Ii
		)	i	
 
HHY7*+ 
	s   /B++B4c                 ^    t               }t        |t        |        d      }t        |       y )Nr$   )r"   r   r   r   )r   r+   r6   s      r   remove_binstar_tokenr:   =   s*    ,.IY:c?"36 :;I	)r   __main__)__doc__r   r   loggingr   os.pathr   r   r   statr   r   platformdirsr	   
common.urlr   r   disk.deleter   __name__logr   r"   r/   r8   r:   printr!   r   r   <module>rF      sf    C 	 	  ' ' " ( 1 D
K , z	

  r   