
    i$                     X   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j0                  e      Z ed      Zej9                  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j9                  dddg      	 d0dee dz   ej<                  d      f   ddfd       Z!de dz  fdZ"ej9                  dd d!g      	 	 d1dee dz   ej<                  d"      f   dee ej<                  d      f   ddfd#       Z#ej9                  d$d%g      d2d&       Z$ej9                  dd'd(g      d2d)       Z%ej9                  d*d+d,g      ejL                  fd-eddfd.       Z'y)3a  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)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      i/var/www/vps2.regionflexible.com/Desarrollo/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_namer4   ^   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   )r4   r)   typerExitr   )r   r   s     r   auth_switch_cmdr9   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   zhf auth tokenz8hf auth token | xargs curl -H 'Authorization: Bearer {}'c                      t               } | +t        j                  d       t        j                  d      t        |        t        j                  d       y)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      s@     KE}		=>jja  	%LHHOPr   r   zhf auth whoamizhf auth whoami --format jsonformatc                     t               }|+t        j                  d       t        j                  d      t        |      }dj                  d |d   D              xs d}t        dk7  rt        nd}t        j                  d	|d
   ||       y)z;Find out which huggingface.co account you are logged in as.NzNot logged inr   r>   ,c              3   &   K   | ]	  }|d      yw)nameNr;   ).0orgs     r   	<genexpr>zauth_whoami.<locals>.<genexpr>   s     8CCK8s   orgszhttps://huggingface.coz	Logged inrF   )userrJ   endpoint)	r   r   r(   r7   r8   r   joinr   result)rB   r   inforJ   rL   s        r   auth_whoamirP      sv     KE}		/"jja  %=D8884<88@DD#'??xTHJJ{fD8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 X X  
		H	% LM 
    	 	aa$g	
	a <	
	a 
aa& 
 FG   		"d
34	6"
 
"	"JC$J J0 
 FG   	 	Id
1	
	I %g	
	I 
I	I. 
+(89 :
 
'_6p$qrQ sQ 
(&68V%WX 4 9 9MM	M YMr   