
    o i              
           d 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
 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  ej        e          Z ed          Ze                    dd          	 	 d&dedee ej        d          f         ddfd            Ze                    dd          	 d'deee           ej        d          f         ddfd            Z!dee          fdZ"e                    dd          	 	 d&deee           ej        d          f         dee ej        d          f         ddfd            Z#e                    d d!          d(d"            Z$e                    d#d$          d(d%            Z%dS ))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
    )	AnnotatedOptionalN)ENDPOINT)HfHubHTTPError)whoami   )	auth_listauth_switchloginlogout)ANSIget_stored_tokens	get_tokenlogging   )TokenOpttyper_factoryz,Manage authentication (login, logout, etc.).)helpr   z7Login using a token from huggingface.co/settings/tokensFtokenadd_to_git_credentialzTSave to git credential helper. Useful only if you plan to run git commands directly.returnc                 (    t          | |           d S )Nr   r   )r   r   s     X/var/www/html/auto_sub_bot/venv/lib/python3.11/site-packages/huggingface_hub/cli/auth.py
auth_loginr   4   s     
-BCCCCCC    r   zLogout from a specific token
token_namezName of token to logoutc                 &    t          |            d S )Nr   )r   r   s    r   auth_logoutr    A   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_namer2   M   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Switch between access tokenszName of the token to switch toc                     | t                      } | "t          d           t          j                    t	          | |           d S )Nz!No token name provided. Aborting.)r   )r2   r'   typerExitr
   )r   r   s     r   auth_switch_cmdr7   e   sP     '))
1222jll
2GHHHHHHr   r#   zList all stored access tokensc                  "    t                       d S N)r	    r   r   auth_list_cmdr;   |   s    KKKKKr   r   z;Find out which huggingface.co account you are logged in as.c                  v   t                      } | "t          d           t          j                    	 t	          |           }t          t          j        d          |d                    d |d         D             }|r5t          t          j        d          d                    |                     t          dk    rt          d	t                      d S d S # t          $ rT}t          |           t          t          j
        |j        j                             t          j        d
          d }~ww xY w)NzNot logged inzuser: namec                     g | ]
}|d          S )r=   r:   ).0orgs     r   
<listcomp>zauth_whoami.<locals>.<listcomp>   s    444F444r   orgszorgs: ,zhttps://huggingface.coz(Authenticated through private endpoint: r   )code)r   r'   r5   r6   r   r   boldjoinr   r   redresponsetext)r   inforB   es       r   auth_whoamirL      s%   KKE}ojll!e}}di!!4<00044tF|444 	7$)H%%sxx~~666///GXGGHHHHH 0/ ! ! !adhqz''(((ja    !s   B"C 
D8$AD33D8)NFr9   )r   N)&__doc__typingr   r   r5   huggingface_hub.constantsr   huggingface_hub.errorsr   huggingface_hub.hf_apir   _loginr	   r
   r   r   utilsr   r   r   r   
_cli_utilsr   r   
get_logger__name__r%   auth_clicommandboolOptionr   strr    r2   r7   r;   rL   r:   r   r   <module>r\      sK   & ' & & & & & & &  . . . . . . 1 1 1 1 1 1 ) ) ) ) ) ) : : : : : : : : : : : : ? ? ? ? ? ? ? ? ? ? ? ? / / / / / / / / 
	H	%	% =LMMM 
' YZZ 		D 	D	D$g	
 	
 	
		D 
	D 	D 	D [Z	D 
(!?@@ 	" "*	
 	
 	
	" 
" " " A@"JHSM J J J J0 
(!?@@ 	 	I I1	
 	
 	
	I %g	
 	
 	
	I 
I I I A@I, 
&>??   @? 
(!^__! ! ! `_! ! !r   