
    "j$                        d Z ddlmZ ddlZddlmZ ddlmZ ddlm	Z	m
Z
mZmZ ddlmZmZmZ d	d
lmZmZmZmZ d	dlmZ  ej        e          Z ed          Ze                    dg d          	 	 	 d0dedee ej        d          f         dee ej        d          f         ddfd            Ze                    dddg          	 d1dee dz   ej        d          f         ddfd            Z!de dz  fdZ"e                    d d!d"g          	 	 d2dee dz   ej        d#          f         dee ej        d          f         ddfd$            Z#e                    d%d&g          d3d'            Z$e                    dd(d)g          d3d*            Z%e                    d+d,d-g          ej&        fd.eddfd/            Z'dS )4a  Contains commands to authenticate to the Hugging Face Hub and interact with your repositories.

Usage:
    # login and save token locally.
    hf auth login --token=hf_*** --add-to-git-credential

    # switch between tokens
    hf auth switch

    # list all tokens
    hf auth list

    # logout from all tokens
    hf auth logout

    # check which account you are logged in as
    hf auth whoami
    )	AnnotatedN)ENDPOINT)whoami   )	auth_listauth_switchloginlogout)get_stored_tokens	get_tokenlogging   )FormatWithAutoOptOutputFormatWithAutoTokenOpttyper_factory)outz,Manage authentication (login, logout, etc.).)helpr	   )zhf auth loginzhf auth login --token $HF_TOKENz7hf auth login --token $HF_TOKEN --add-to-git-credentialzhf auth login --force)examplesFtokenadd_to_git_credentialzTSave to git credential helper. Useful only if you plan to run git commands directly.forcez)Force re-login even if already logged in.returnc                 ,    t          | ||            dS )z8Login using a token from huggingface.co/settings/tokens.)r   r   skip_if_logged_inN)r	   )r   r   r   s      b/lsinfo/ai/hellotax_ai/base_platform/venv/lib/python3.11/site-packages/huggingface_hub/cli/auth.py
auth_loginr   4   s$    2 
-BZ_V_``````    r
   zhf auth logoutz$hf auth logout --token-name my-token
token_namezName of token to logoutc                 &    t          |            dS )zLogout from a specific token.r   N)r
   r!   s    r   auth_logoutr"   P   s     j!!!!!!r   c                  .   t          t                                                                } | st                              d           d S t          d           t          | d          D ]\  }}t          | d|            	 	 t          d          }|                                dk    rd S t          |          dz
  }d|cxk    rt          |           k     rn n| |         S t          d	           n# t          $ r t          d
           Y nw xY w)Nz+No stored tokens found. Please login first.zAvailable stored tokens:r   z. Tz=Enter the number of the token to switch to (or 'q' to quit): qr   z$Invalid selection. Please try again.z4Invalid input. Please enter a number or 'q' to quit.)listr   keysloggererrorprint	enumerateinputlowerintlen
ValueError)token_namesir   choiceindexs        r   _select_token_namer4   ^   sO   (**//1122K BCCCt	
$%%%";22 $ $:""j""####J
	JZ[[F||~~$$tKK!OEE,,,,C,,,,,,,"5))<==== 	J 	J 	JHIIIII	JJs   'C7 06C7 'C7 7DDswitchzhf auth switchz$hf auth switch --token-name my-tokenzName of the token to switch toc                     | t                      } | "t          d           t          j                    t	          | |           dS )zSwitch between access tokens.Nz!No token name provided. Aborting.)r   )r4   r)   typerExitr   )r   r   s     r   auth_switch_cmdr9   v   sP    & '))
1222jll
2GHHHHHHr   z	list | lszhf auth listc                  "    t                       dS )zList all stored access tokens.N)r    r   r   auth_list_cmdr<      s     KKKKKr   zhf auth tokenz8hf auth token | xargs curl -H 'Authorization: Bearer {}'c                      t                      } | )t          j        d           t          j        d          t          |            t          j        d           dS )z)Print the current access token to stdout.Nz)Not logged in. Run `hf auth login` first.r   codez@Run `hf auth whoami` to see which account this token belongs to.)r   r   r(   r7   r8   r)   hint)r   s    r   
auth_tokenrA      sX     KKE}	=>>>ja    	%LLLHOPPPPPr   r   zhf auth whoamizhf auth whoami --format jsonformatc                 H   t                      }|)t          j        d           t          j        d          t          |          }d                    d |d         D                       pd}t          dk    rt          nd}t          j        d	|d
         ||           dS )z;Find out which huggingface.co account you are logged in as.NzNot logged inr   r>   ,c              3   &   K   | ]}|d          V  dS )nameNr;   ).0orgs     r   	<genexpr>zauth_whoami.<locals>.<genexpr>   s&      88CCK888888r   orgszhttps://huggingface.coz	Logged inrF   )userrJ   endpoint)	r   r   r(   r7   r8   r   joinr   result)rB   r   inforJ   rL   s        r   auth_whoamirP      s     KKE}	/"""ja    %==D88884<88888@DD#'???xxTHJ{fD8LLLLLLr   )NFF)N)NF)r   N)(__doc__typingr   r7   huggingface_hub.constantsr   huggingface_hub.hf_apir   _loginr   r   r	   r
   utilsr   r   r   
_cli_utilsr   r   r   r   _outputr   
get_logger__name__r'   auth_clicommandboolOptionr   strr"   r4   r9   r<   rA   autorP   r;   r   r   <module>ra      s   &        . . . . . . ) ) ) ) ) ) : : : : : : : : : : : : 9 9 9 9 9 9 9 9 9 9 X X X X X X X X X X X X       
	H	%	% =LMMM 
       	 	a aa$g	
 	
 	
	a <	
 	
 	
	a 
a a a a& 
 FG    		" "d
3444	6"
 
" " "	 "JC$J J J J J0 
 FG    	 	I Id
1	
 	
 	
	I %g	
 	
 	
	I 
I I I	 I. 
+(899   :9
 
'_6p$qrrQ Q Q srQ 
(&68V%WXX 4 9M MM	M M M YXM M Mr   