
    iGg                     *   d dl Z d dlmZ d dlmZ d dlmZmZmZ d dl	m
Z ddlmZ ddlmZmZmZmZ  ed	d
      Z ed      ZdZed        Zed        Zed        Zed        Zedd       Zedd       Zedd       Zedk(  r e e              yy)    N)
namedtuple)environ)
expanduserisfilejoin)	constants   __version__)_debug_random_token_saved_tokencachedTokens)versionclientsessionenvironmentsystemz~/.conda	org_tokenc                      t         S )zQ
    Returns the version token, which is just the
    version string itself.
    r
        :lib/python3.12/site-packages/anaconda_anon_usage/tokens.pyversion_tokenr      s
     r   c                     t         j                  D ]  } | j                  d      s| j                  d      }|d   j	                  d      r$t        j                  |d   dd       |d<   |d   s^t        |d<   dj                  |      } t        |       s	 t        d|        t        |       5 }|j                         j                         cddd       c S  t        d
       y# 1 sw Y   nxY w# t        $ r t        d	       Y  yw xY w)a\  
    Returns the system/organization token. Unlike the other
    tokens, it is desirable for this token to be stored in
    a read-only/system location, presumably installed
    The system/organization token can be stored anywhere
    in the standard conda search path. Ideally, an MDM system
    would place it in a read-only system location.
    z	/.condarc/r   $r	   NzReading system token: %szUnable to read system tokenzNo system token found)c_constantsSEARCH_PATHendswithsplit
startswithr   getORG_TOKEN_NAMEr   r   r   openreadstrip	Exception)pathpartsfps      r   system_tokenr.      s     '' }}[)

38s#{{58AB<0E!H8"b	xx$<148$Z2779??,  Z (( "#  ZZ 45s*   C1-C$	C1$C-	)C11D	D	c                  :    t        t        d      } t        | d      S )z
    Returns the client token. If a token has not yet
    been generated, an attempt is made to do so. If
    that fails, an empty string is returned.
    	aau_tokenr   )r   
CONFIG_DIRr   )fpaths    r   client_tokenr3   B   s     [)Ex((r   c                      t        d      S )z^
    Returns the session token, generated randomly for each
    execution of the process.
    r   )r   r   r   r   session_tokenr5   M   s     ##r   c                 Z    | t         j                  } t        | dd      }t        |d|       S )z
    Returns the environment token for the given prefix, or
    sys.prefix if one is not supplied. If a token has not
    yet been generated, an attempt is made to do so. If that
    fails, an empty string is returned.
    etcr0   r   )sysprefixr   r   )r9   r2   s     r   environment_tokenr:   V   s/     ~,E}f55r   c                 r    t        t               t               t               t	        |       t                     S )zv
    Returns the token set, in the form of a Tokens namedtuple.
    Fields: version, client, session, environment
    )r   r   r3   r5   r:   r.   )r9   s    r   
all_tokensr<   d   s-     &! r   c                    dt         z   g}|rt        |       }|j                  r|j                  d|j                  z          |j                  r|j                  d|j                  z          |j
                  r|j                  d|j
                  z          |j                  r*|j                  d|j                  z          nt        d       dj                  |      }t        d|       |S )	zh
    Returns the token set, formatted into the string that is
    appended to the conda user agent.
    zaau/zc/zs/ze/zo/z&anaconda_anon_usage disabled by config zFull client token: %s)	r   r<   r   appendr   r   r   r   r   )r9   enabledr,   valuesresults        r   token_stringrC   s   s     k!"EF#==LL-.>>LL./LL 2 223==LL-.78XXe_F
"F+Mr   __main__)N)NT)r8   collectionsr   osr   os.pathr   r   r   
conda.baser   r     r   utilsr   r   r   r   r   r1   r&   r   r.   r3   r5   r:   r<   rC   __name__printr   r   r   <module>rM      s     "  , , /  > >	HW	X
#
   $ $D ) ) $ $ 
6 
6    . z	,. r   