Ë
    Q^(h +  ã                   óº  — d Z ddlZddlmZ ddl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 ddlmZ d	d
lmZmZmZmZmZmZmZmZ d	dlmZmZmZ ddlm Z   ejB                  e"«      Z#	 ddl$m%Z% ddl&m'Z' dZ( G d„ de
«      Z* G d„ d«      Z+ G d„ de+«      Z, G d„ de+«      Z- G d„ de+«      Z. G d„ de+«      Z/ G d„ de+«      Z0 G d „ d!e+«      Z1y# e)$ r dZ(Y Œaw xY w)"aª  Contains commands to authenticate to the Hugging Face Hub and interact with your repositories.

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

    # switch between tokens
    huggingface-cli auth switch

    # list all tokens
    huggingface-cli auth list

    # logout from a specific token, if no token-name is provided, all tokens will be deleted from your machine.
    huggingface-cli logout --token-name=your_token_name

    # find out which huggingface.co account you are logged in as
    huggingface-cli whoami

    # create a new dataset repo on the Hub
    huggingface-cli repo create mydataset --type=dataset

é    N)Ú_SubParsersAction)ÚListÚOptional)Ú	HTTPError)ÚBaseHuggingfaceCLICommand)ÚENDPOINTÚ
REPO_TYPESÚREPO_TYPES_URL_PREFIXESÚSPACES_SDK_TYPES)ÚHfApié   )ÚNOTEBOOK_LOGIN_PASSWORD_HTMLÚNOTEBOOK_LOGIN_TOKEN_HTML_ENDÚNOTEBOOK_LOGIN_TOKEN_HTML_STARTÚ	auth_listÚauth_switchÚloginÚlogoutÚnotebook_login)Úget_stored_tokensÚ	get_tokenÚloggingé   )ÚANSI)Úinquirer)ÚChoiceTFc                   ó"   — e Zd Zedefd„«       Zy)ÚUserCommandsÚparserc                 ó4  — | j                  dd¬«      }|j                  dt        d¬«       |j                  ddd	¬
«       |j                  d„ ¬«       | j                  dd¬«      }|j                  d„ ¬«       | j                  dd¬«      }|j                  dt        d¬«       |j                  d„ ¬«       | j                  dd¬«      }|j	                  d¬«      }|j                  dd¬«      }|j                  dt        d¬«       |j                  ddd	¬
«       |j                  d„ ¬«       |j                  dd¬«      }|j                  d„ ¬«       | j                  dd ¬«      }|j	                  d!¬«      }	|	j                  d"d#¬«      }
|
j                  d$t        d%¬«       |
j                  d&t        d'¬«       |
j                  d(t        d)¬«       |
j                  d*t        d+t
        ¬,«       |
j                  d-d.dd/¬
«       |
j                  d0„ ¬«       y )1Nr   z8Log in using a token from huggingface.co/settings/tokens)Úhelpz--tokenz;Token generated from https://huggingface.co/settings/tokens)Útyper!   z--add-to-git-credentialÚ
store_truez.Optional: Save token to git credential helper.)Úactionr!   c                 ó   — t        | «      S ©N)ÚLoginCommand©Úargss    ú[/var/www/skyplay_api_hub/venv/lib/python3.12/site-packages/huggingface_hub/commands/user.pyú<lambda>z2UserCommands.register_subcommand.<locals>.<lambda>V   s   € ´LÀÓ4F€ ó    )ÚfuncÚwhoamiz;Find out which huggingface.co account you are logged in as.c                 ó   — t        | «      S r&   )ÚWhoamiCommandr(   s    r*   r+   z2UserCommands.register_subcommand.<locals>.<lambda>X   ó   € ´]À4Ó5H€ r,   r   zLog outz--token-namez3Optional: Name of the access token to log out from.c                 ó   — t        | «      S r&   )ÚLogoutCommandr(   s    r*   r+   z2UserCommands.register_subcommand.<locals>.<lambda>`   r1   r,   Úauthz%Other authentication related commandszAuthentication subcommandsÚswitchzSwitch between access tokensz0Optional: Name of the access token to switch to.c                 ó   — t        | «      S r&   )ÚAuthSwitchCommandr(   s    r*   r+   z2UserCommands.register_subcommand.<locals>.<lambda>o   ó   € Ô:KÈDÓ:Q€ r,   ÚlistzList all stored access tokensc                 ó   — t        | «      S r&   )ÚAuthListCommandr(   s    r*   r+   z2UserCommands.register_subcommand.<locals>.<lambda>q   s   € ¼ÈÓ8M€ r,   Úrepoz={create} Commands to interact with your huggingface.co repos.z%huggingface.co repos related commandsÚcreatez#Create a new repo on huggingface.coÚnamezPName for your repo. Will be namespaced under your username to build the repo id.z--typezbOptional: repo_type: set to "dataset" or "space" if creating a dataset or space, default is model.z--organizationz!Optional: organization namespace.z--space_sdkzOOptional: Hugging Face Spaces SDK type. Required when --type is set to "space".)r"   r!   Úchoicesz-yz--yesz"Optional: answer Yes to the promptc                 ó   — t        | «      S r&   )ÚRepoCreateCommandr(   s    r*   r+   z2UserCommands.register_subcommand.<locals>.<lambda>�   r8   r,   )Ú
add_parserÚadd_argumentÚstrÚset_defaultsÚadd_subparsersr   )r   Úlogin_parserÚwhoami_parserÚlogout_parserÚauth_parserÚauth_subparsersÚauth_switch_parserÚauth_list_parserÚrepo_parserÚrepo_subparsersÚrepo_create_parsers              r*   Úregister_subcommandz UserCommands.register_subcommandI   ss  € à×(Ñ(¨Ð7qÐ(ÓrˆØ×!Ñ!ØÜØNð 	"ô 	
ð
 	×!Ñ!Ø%ØØAð 	"ô 	
ð
 	×!Ñ!Ñ'FÐ!ÔGØ×)Ñ)¨(Ð9vÐ)ÓwˆØ×"Ñ"Ñ(HÐ"ÔIà×)Ñ)¨(¸Ð)ÓCˆØ×"Ñ"ØÜØFð 	#ô 	
ð
 	×"Ñ"Ñ(HÐ"ÔIà×'Ñ'¨Ð5\Ð'Ó]ˆØ%×4Ñ4Ð:VÐ4ÓWˆØ,×7Ñ7¸ÐGeÐ7ÓfÐØ×'Ñ'ØÜØCð 	(ô 	
ð
 	×'Ñ'Ø%ØØAð 	(ô 	
ð
 	×'Ñ'Ñ-QÐ'ÔRØ*×5Ñ5°fÐCbÐ5ÓcÐØ×%Ñ%Ñ+MÐ%ÔNà×'Ñ'¨Ð5tÐ'ÓuˆØ%×4Ñ4Ð:aÐ4ÓbˆØ,×7Ñ7¸ÐGlÐ7ÓmÐØ×'Ñ'ØÜØcð 	(ô 	
ð
 	×'Ñ'ØÜØuð 	(ô 	
ð
 	×'Ñ'Ð(8¼sÐIlÐ'ÔmØ×'Ñ'ØÜØbÜ$ð	 	(ô 	
ð 	×'Ñ'ØØØØ5ð	 	(ô 	
ð 	×'Ñ'Ñ-QÐ'ÕRr,   N)Ú__name__Ú
__module__Ú__qualname__Ústaticmethodr   rQ   © r,   r*   r   r   H   s"   „ ØðCSÐ$5ò CSó ñCSr,   r   c                   ó   — e Zd Zd„ Zy)ÚBaseUserCommandc                 ó0   — || _         t        «       | _        y r&   )r)   r   Ú_api)Úselfr)   s     r*   Ú__init__zBaseUserCommand.__init__‘   s   € ØˆŒ	Ü“Gˆ�	r,   N)rR   rS   rT   r\   rV   r,   r*   rX   rX   �   s   „ ór,   rX   c                   ó   — e Zd Zd„ Zy)r'   c                 ó–   — t        j                  «        t        | j                  j                  | j                  j
                  ¬«       y )N)ÚtokenÚadd_to_git_credential)r   Úset_verbosity_infor   r)   r_   r`   ©r[   s    r*   ÚrunzLoginCommand.run—   s.   € Ü×"Ñ"Ô$ÜØ—)‘)—/‘/Ø"&§)¡)×"AÑ"Aö	
r,   N©rR   rS   rT   rc   rV   r,   r*   r'   r'   –   s   „ ó
r,   r'   c                   ó   — e Zd Zd„ Zy)r3   c                 ól   — t        j                  «        t        | j                  j                  ¬«       y )N)Ú
token_name)r   ra   r   r)   rg   rb   s    r*   rc   zLogoutCommand.run    s    € Ü×"Ñ"Ô$Ü˜$Ÿ)™)×.Ñ.Ö/r,   Nrd   rV   r,   r*   r3   r3   Ÿ   s   „ ó0r,   r3   c                   ó@   — e Zd Zd„ Zdee   fd„Zdee   dee   fd„Zy)r7   c                 óì   — t        j                  «        | j                  j                  }|€| j	                  «       }|€t        d«       t        «        t        || j                  j                  ¬«       y )Nz!No token name provided. Aborting.)r`   )	r   ra   r)   rg   Ú_select_token_nameÚprintÚexitr   r`   )r[   rg   s     r*   rc   zAuthSwitchCommand.run¦   sY   € Ü×"Ñ"Ô$Ø—Y‘Y×)Ñ)ˆ
ØÐØ×0Ñ0Ó2ˆJàÐÜÐ5Ô6ÜŒFÜ�J°d·i±i×6UÑ6UÖVr,   Úreturnc                 óä  — t        t        «       j                  «       «      }|st        j	                  d«       y t
        r| j                  |«      S 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.)r9   r   ÚkeysÚloggerÚerrorÚ_inquirer_py_availableÚ_select_token_name_tuirk   Ú	enumerateÚinputÚlowerÚintÚlenÚ
ValueError)r[   Útoken_namesÚirg   ÚchoiceÚindexs         r*   rj   z$AuthSwitchCommand._select_token_name±   sï   € ÜÔ,Ó.×3Ñ3Ó5Ó6ˆáÜ�L‰LÐFÔGØå!Ø×.Ñ.¨{Ó;Ð;äÐ(Ô)Ü& {°AÓ6ò 	(‰MˆAˆzÜ�Q�C�r˜*˜Ð&Õ'ð	(àð
NÜÐ^Ó_�Ø—<‘<“> SÒ(ØÜ˜F› a™�Ø˜Ô0¤ KÓ 0Õ0Ø& uÑ-Ð-äÐ@ÕAð øô ò NÜÐLÖMðNús   ÂC Â!)C ÃC ÃC/Ã.C/r{   c                 óÖ   — |D �cg c]  }t        ||¬«      ‘Œ }}	 t        j                  d|d ¬«      j                  «       S c c}w # t        $ r t
        j                  d«       Y y w xY w)N)r>   zSelect a token to switch to:)Úmessager?   ÚdefaultzToken selection cancelled.)r   r   ÚselectÚexecuteÚKeyboardInterruptrq   Úinfo)r[   r{   rg   r?   s       r*   rt   z(AuthSwitchCommand._select_token_name_tuiË   sk   € ØITÖU¸:”6˜*¨:Ö6ÐUˆÐUð	Ü—?‘?Ø6ØØô÷ ‰g‹ið	ùò Vøô !ò 	Ü�K‰KÐ4Ô5Ùð	ús   …Aœ%A ÁA(Á'A(N)	rR   rS   rT   rc   r   rD   rj   r   rt   rV   r,   r*   r7   r7   ¥   s5   „ ò	WðN H¨S¡Mó Nð4
°$°s±)ð 
ÀÈÁô 
r,   r7   c                   ó   — e Zd Zd„ Zy)r;   c                 ó@   — t        j                  «        t        «        y r&   )r   ra   r   rb   s    r*   rc   zAuthListCommand.runÙ   s   € Ü×"Ñ"Ô$Ü�r,   Nrd   rV   r,   r*   r;   r;   Ø   s   „ ór,   r;   c                   ó   — e Zd Zd„ Zy)r0   c                 ó"  — t        «       }|€t        d«       t        «        	 | j                  j	                  |«      }t        |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 # t        $ rR}t        |«       t        t        j                  |j                  j                  «      «       t        d«       Y d }~y d }~ww xY w)	NúNot logged inr>   Úorgszorgs: ú,zhttps://huggingface.coz(Authenticated through private endpoint: r   )r   rk   rl   rZ   r.   r   ÚboldÚjoinr   r   ÚredÚresponseÚtext)r[   r_   r…   Úorgr‹   Úes         r*   rc   zWhoamiCommand.runß   s×   € Ü“ˆØˆ=Ü�/Ô"ÜŒFð	Ø—9‘9×#Ñ# EÓ*ˆDÜ�$�v‘,ÔØ+/°©<Ö8 C�C˜“KÐ8ˆDÐ8ÙÜ”d—i‘i Ó)¨3¯8©8°D«>Ô:äÐ3Ò3ÜÐ@ÄÀ
ÐKÕLð 4ùò	 9øô ò 	Ü�!ŒHÜ”$—(‘(˜1Ÿ:™:Ÿ?™?Ó+Ô,Ü��G‰Gûð	ús+   £0B3 ÁB.ÁAB3 Â.B3 Â3	DÂ<AD	Ä	DNrd   rV   r,   r*   r0   r0   Þ   s   „ ór,   r0   c                   ó   — e Zd Zd„ Zy)rA   c                 óÀ  — t        «       }|€t        d«       t        d«       	 t        j                  ddg«      j                  d«      }t        t        j                  |j                  «       «      «       	 t        j                  ddg«      j                  d«      }t        t        j                  |j                  «       «      «       t        d	«       | j                  j                  |«      d
   }| j                  j                  �| j                  j                  n|}|› d| j                  j                  › �}| j                  j                   t"        vrt        d«       t        d«       | j                  j                   t$        v r!t$        | j                  j                      |z   }n|}t        dt        j&                  |«      › �«       | j                  j(                  s=t+        d«      j-                  «       }|d	k(  s|dk(  s|dk(  st        d«       t        «        	 | j                  j/                  ||| j                  j                   | j                  j0                  ¬«      }t        d«       t        dt        j&                  «      › �«       t        d«       t        d|› �«       t        d	«       y # t        $ r t        d«       Y �ŒZw xY w# t        $ r" t        t        j                  d«      «       Y �Œ5w xY w# t2        $ rR}	t        |	«       t        t        j                  |	j4                  j6                  «      «       t        d«       Y d }	~	Œðd }	~	ww xY w)NrŠ   r   Úgitz	--versionzutf-8z9Looks like you do not have git installed, please install.zgit-lfsz«Looks like you do not have git-lfs installed, please install. You can install from https://git-lfs.github.com/. Then run `git lfs install` (you only have to do this once).Ú r>   ú/zInvalid repo --typezYou are about to create zProceed? [Y/n] ÚyÚyesÚAbort)Úrepo_idr_   Ú	repo_typeÚ	space_sdkz
Your repo now lives at:z  zK
You can clone it locally with the command below, and commit/push as usual.z
  git clone )r   rk   rl   Ú
subprocessÚcheck_outputÚdecoder   ÚgrayÚstripÚFileNotFoundErrorr�   rZ   r.   r)   Úorganizationr>   r"   r	   r
   r�   rš   rv   rw   Úcreate_reporž   r   r�   r‘   )
r[   r_   ÚstdoutÚuserÚ	namespacerœ   Úprefixed_repo_idr}   Úurlr“   s
             r*   rc   zRepoCreateCommand.runô   sš  € Ü“ˆØˆ=Ü�/Ô"Ü�ŒGð	OÜ×,Ñ,¨e°[Ð-AÓB×IÑIÈ'ÓRˆFÜ”$—)‘)˜FŸL™L›NÓ+Ô,ð
	Ü×,Ñ,¨i¸Ð-EÓF×MÑMÈgÓVˆFÜ”$—)‘)˜FŸL™L›NÓ+Ô,ô 	ˆbŒ	à�y‰y×Ñ Ó& vÑ.ˆØ.2¯i©i×.DÑ.DÐ.P�D—I‘I×*Ò*ÐVZˆ	à�K˜q §¡§¡Ð 0Ð1ˆà�9‰9�>‰>¤Ñ+ÜÐ'Ô(Ü�ŒGà�9‰9�>‰>Ô4Ñ4Ü6°t·y±y·~±~ÑFÈÑPÑà&ÐäÐ(¬¯©Ð3CÓ)DÐ(EÐFÔGà�y‰y�}Š}ÜÐ,Ó-×3Ñ3Ó5ˆFØ˜b’L F¨c¢M°V¸u²_Ü�g”Ü”ð
	Ø—)‘)×'Ñ'ØØØŸ)™)Ÿ.™.ØŸ)™)×-Ñ-ð	 (ó ˆCô 	Ð)Ô*Ü�”4—9‘9˜S“>Ð"Ð#Ô$ÜÐ\Ô]Ü�˜s˜eÐ$Ô%Üˆb�	øôi !ò 	OÜÐM×Nð	Oûô !ò 	ÜÜ—‘ðSó÷ð	ûôL ò 	Ü�!ŒHÜ”$—(‘(˜1Ÿ:™:Ÿ?™?Ó+Ô,Ü��G‰Gûð	ús?   ¤AJ9 Á7AK È!AL Ê9KËKË'K?Ë>K?Ì	MÌAMÍMNrd   rV   r,   r*   rA   rA   ó   s   „ ó<r,   rA   )2Ú__doc__rŸ   Úargparser   Útypingr   r   Úrequests.exceptionsr   Úhuggingface_hub.commandsr   Úhuggingface_hub.constantsr   r	   r
   r   Úhuggingface_hub.hf_apir   Ú_loginr   r   r   r   r   r   r   r   Úutilsr   r   r   Ú
_cli_utilsr   Ú
get_loggerrR   rq   Ú
InquirerPyr   ÚInquirerPy.base.controlr   rs   ÚImportErrorr   rX   r'   r3   r7   r;   r0   rA   rV   r,   r*   ú<module>rº      sà   ðñó. Ý &ß !å )å >ß eÓ eÝ (÷	÷ 	ó 	÷ :Ñ 9Ý ð 
ˆ×	Ñ	˜HÓ	%€ð#Ý#Ý.à!Ðô
ESÐ,ô ES÷Pñ ô
�?ô 
ô0�Oô 0ô0˜ô 0ôf�oô ô�Oô ô*=˜õ =øð_ ò #Ø"Òð#ús   Á*C ÃCÃC