
    Li|                     $   d Z ddlZddlmZ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mZ d	d
lmZmZmZmZ  ej2                  e      Z ed      Zej;                  dg d      	 	 	 d+dedee ej>                  d      f   dee ej>                  d      f   ddfd       Z ej;                  dddg      	 d,deee!    ej>                  d      f   ddfd       Z"dee!   fdZ#ej;                  ddd g      	 	 d-deee!    ej>                  d!      f   dee ej>                  d      f   ddfd"       Z$ej;                  d#d$g      d.d%       Z%ej;                  d&d'd(g      ejL                  fd)eddfd*       Z'y)/a  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
    N)	AnnotatedOptional)ENDPOINT)whoami   )	auth_listauth_switchloginlogout)ANSIget_stored_tokens	get_tokenlogging   )	FormatOptOutputFormatTokenOpttyper_factoryz,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)examples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        | ||        y)z8Login using a token from huggingface.co/settings/tokens.)r   r   skip_if_logged_inN)r
   )r   r   r   s      ^/var/www/html/lcp-python-backend/venv/lib/python3.12/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        |        y)zLogout from a specific token.r    N)r   r"   s    r   auth_logoutr#   P   s     j!r   c                     t        t               j                               } | st        j	                  d       y t        d       t        | d      D ]  \  }}t        | d|         	 	 t        d      }|j                         dk(  ry t        |      dz
  }d|cxk  rt        |       k  rn n| |   S t        d       	 W# t        $ r t        d	       Y w xY w)
Nz+No stored tokens found. Please login first.zAvailable stored tokens:r   z. z=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_namer5   ^   s    (*//12KBC	
$%";2 $:2j\"#$

	JZ[F||~$K!OEE,C,,"5))<=   	JHI	Js   +C 
)C 4C CCswitchzhf auth switchz$hf auth switch --token-name my-tokenzName of the token to switch toc                 x    | 
t               } | t        d       t        j                         t	        | |       y)zSwitch between access tokens.Nz!No token name provided. Aborting.)r   )r5   r*   typerExitr	   )r    r   s     r   auth_switch_cmdr:   v   s8    & ')
12jjl
2GHr   z	list | lszhf auth listc                      t                y)zList all stored access tokens.N)r    r   r   auth_list_cmdr=      s	     Kr   r   zhf auth whoamizhf auth whoami --format jsonformatc                    t               }|f| t        j                  k(  r4t        t        j                  ddi             t        j                         t        d       t        j                         t        |      }| t        j                  k(  r&t        t        j                  |dt                     yt        t        j                  d      |d          |d   D cg c]  }|d   	 }}|r.t        t        j                  d	      d
j                  |             t        dk7  rt        dt                yyc c}w )z;Find out which huggingface.co account you are logged in as.Nr)   zNot logged inr   )indentdefaultzuser: nameorgszorgs: ,zhttps://huggingface.coz(Authenticated through private endpoint: )r   r   jsonr*   dumpsr8   r9   r   strr   boldjoinr   )r>   r   infoorgrC   s        r   auth_whoamirL      s    
 KE}\&&&$**g789 jjl /"jjl%=D"""djja56dii!4<0'+F|4F44$))H%sxx~6//<XJGH 0	 5s    D;)NFF)N)NF)r   N)(__doc__rE   typingr   r   r8   huggingface_hub.constantsr   huggingface_hub.hf_apir   _loginr   r	   r
   r   utilsr   r   r   r   
_cli_utilsr   r   r   r   
get_logger__name__r(   auth_clicommandboolOptionr   rG   r#   r5   r:   r=   tablerL   r<   r   r   <module>r[      ss  &  &  . ) : : ? ? H H 
		H	% LM 
    	 	aa$g	
	a <	
	a 
aa& 
 FG   		"34	6"
 
"	"JHSM J0 
 FG   	 	I1	
	I %g	
	I 
I	I. 
+(89 :
 
(&68V%WX$**II	I YIr   