Ë
    çÍ:jz)  ã                   ó,  — d 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 ddl	m
Z
 ddlmZmZ dd	lmZmZmZ dd
lmZ ddlmZ  ej,                  e«      Z G d„ de«      Z G d„ d«      Z G d„ d«      Z G d„ de«      Z G d„ de«      Z G d„ de«      Zy)a  Contains commands to interact with repositories on the Hugging Face Hub.

Usage:
    # create a new dataset repo on the Hub
    hf repo create my-cool-dataset --repo-type=dataset

    # create a private model repo on the Hub
    hf repo create my-cool-model --private
é    N)Ú_SubParsersAction)ÚOptional)Ú	HTTPError)ÚBaseHuggingfaceCLICommand)ÚANSI)Ú
REPO_TYPESÚSPACES_SDK_TYPES)ÚHfHubHTTPErrorÚRepositoryNotFoundErrorÚRevisionNotFoundError)ÚHfApi)Úloggingc                   ó"   — e Zd Zedefd„«       Zy)ÚRepoCommandsÚparserc                 óØ  ‡— | j                  dd¬«      Š‰j                  d¬«      }‰j                  ˆfd„¬«       |j                  dd¬«      }|j                  d	t        d
¬«       |j                  dt        d¬«       |j                  dt        dt
        ¬«       |j                  ddd¬«       |j                  dt        d¬«       |j                  ddd¬«       |j                  dt        d¬«       |j                  d„ ¬«       |j                  dd¬«      }|j                  ddd ¬!«      }|j                  dd"¬«      }|j                  d	t        d#¬«       |j                  dt        d$¬«       |j                  d%d&t        d'¬«       |j                  d(t        d)¬«       |j                  dt        d*¬«       |j                  dg d+¢d,d-¬.«       |j                  d/„ ¬«       |j                  d0d1¬«      }|j                  d	t        d2¬«       |j                  dt        d*¬«       |j                  dg d+¢d,d-¬.«       |j                  d3„ ¬«       |j                  d4d5¬«      }|j                  d	t        d6¬«       |j                  dt        d7¬«       |j                  d8d9dd:¬«       |j                  dt        d*¬«       |j                  dg d+¢d,d-¬.«       |j                  d;„ ¬«       y )<NÚrepozManage repos on the Hub.)Úhelpz%huggingface.co repos related commandsc                 ó$   •— ‰j                  «       S ©N)Ú
print_help)ÚargsÚrepo_parsers    €úm/home/mcse/projects/srt_converter/srt-converter-venv/lib/python3.12/site-packages/huggingface_hub/cli/repo.pyú<lambda>z2RepoCommands.register_subcommand.<locals>.<lambda>0   s   ø€ °;×3IÑ3IÓ3K€ ó    )ÚfuncÚcreatez#Create a new repo on huggingface.coÚrepo_idz‡The ID of the repo to create to (e.g. `username/repo-name`). The username is optional and will be set to your username if not provided.)Útyper   z--repo-typezWOptional: set to "dataset" or "space" if creating a dataset or space, default is model.z--space_sdkzOOptional: Hugging Face Spaces SDK type. Required when --type is set to "space".)r    r   Úchoicesz	--privateÚ
store_truezhWhether to create a private repository. Defaults to public unless the organization's default is private.)Úactionr   z--tokenzLHugging Face token. Will default to the locally saved token if not provided.z
--exist-okz-Do not raise an error if repo already exists.z--resource-group-idzoResource group in which to create the repo. Resource groups is only available for Enterprise Hub organizations.c                 ó   — t        | «      S r   )ÚRepoCreateCommand©r   s    r   r   z2RepoCommands.register_subcommand.<locals>.<lambda>X   s   € Ô:KÈDÓ:Q€ r   Útagz"Manage tags for a repo on the Hub.zTag actionsÚ
tag_actionT)r   ÚdestÚrequiredzCreate a tag for a repo.z6The ID of the repo to tag (e.g. `username/repo-name`).zThe name of the tag to create.z-mz	--messagez%The description of the tag to create.z
--revisionzThe git revision to tag.zJA User Access Token generated from https://huggingface.co/settings/tokens.)ÚmodelÚdatasetÚspacer+   z6Set the type of repository (model, dataset, or space).)r!   Údefaultr   c                 ó   — t        | «      S r   )ÚRepoTagCreateCommandr&   s    r   r   z2RepoCommands.register_subcommand.<locals>.<lambda>o   ó   € Ô9MÈdÓ9S€ r   ÚlistzList tags for a repo.z@The ID of the repo to list tags for (e.g. `username/repo-name`).c                 ó   — t        | «      S r   )ÚRepoTagListCommandr&   s    r   r   z2RepoCommands.register_subcommand.<locals>.<lambda>   s   € Ô7IÈ$Ó7O€ r   ÚdeletezDelete a tag from a repo.zFThe ID of the repo to delete the tag from (e.g. `username/repo-name`).zThe name of the tag to delete.z-yz--yesz$Answer Yes to prompts automatically.c                 ó   — t        | «      S r   )ÚRepoTagDeleteCommandr&   s    r   r   z2RepoCommands.register_subcommand.<locals>.<lambda>‘   r1   r   )Ú
add_parserÚadd_subparsersÚset_defaultsÚadd_argumentÚstrr	   )	r   Úrepo_subparsersÚrepo_create_parserÚrepo_tag_parserÚtag_subparsersÚtag_create_parserÚtag_list_parserÚtag_delete_parserr   s	           @r   Úregister_subcommandz RepoCommands.register_subcommand*   s{  ø€ à×'Ñ'¨Ð5OÐ'ÓPˆØ%×4Ñ4Ð:aÐ4Óbˆð 	× Ñ Ó&KÐ ÔLð -×7Ñ7¸ÐGlÐ7ÓmÐØ×'Ñ'ØÜð [ð 	(ô 	
ð
 	×'Ñ'ØÜØjð 	(ô 	
ð
 	×'Ñ'ØÜØbÜ$ð	 	(ô 	
ð 	×'Ñ'ØØØ{ð 	(ô 	
ð
 	×'Ñ'ØÜØ_ð 	(ô 	
ð
 	×'Ñ'ØØØ@ð 	(ô 	
ð
 	×'Ñ'Ø!Üð Cð 	(ô 	
ð
 	×'Ñ'Ñ-QÐ'ÔRð *×4Ñ4°UÐAeÐ4ÓfˆØ(×7Ñ7¸]ÐQ]ÐhlÐ7Ómˆð +×5Ñ5°hÐE_Ð5Ó`ÐØ×&Ñ&ØœCÐ&^ð 	'ô 	
ð 	×&Ñ& u´3Ð=]Ð&Ô^Ø×&Ñ& t¨[¼sÐIpÐ&ÔqØ×&Ñ& |¼#ÐD^Ð&Ô_Ø×&Ñ&ØœCÐ&rð 	'ô 	
ð 	×&Ñ&ØÚ1ØØIð	 	'ô 	
ð 	×&Ñ&Ñ,SÐ&ÔTð )×3Ñ3°FÐAXÐ3ÓYˆØ×$Ñ$ØœCÐ&hð 	%ô 	
ð 	×$Ñ$ØœCÐ&rð 	%ô 	
ð 	×$Ñ$ØÚ1ØØIð	 	%ô 	
ð 	×$Ñ$Ñ*OÐ$ÔPð +×5Ñ5°hÐE`Ð5ÓaÐØ×&Ñ&ØœCÐ&nð 	'ô 	
ð 	×&Ñ& u´3Ð=]Ð&Ô^Ø×&Ñ& t¨W¸\ÐPvÐ&ÔwØ×&Ñ&ØœCÐ&rð 	'ô 	
ð 	×&Ñ&ØÚ1ØØIð	 	'ô 	
ð 	×&Ñ&Ñ,SÐ&ÕTr   N)Ú__name__Ú
__module__Ú__qualname__Ústaticmethodr   rD   © r   r   r   r   )   s"   „ ØðfUÐ$5ò fUó ñfUr   r   c                   ó2   — e Zd Zdej                  fd„Zd„ Zy)r%   r   c                 ó  — |j                   | _         |j                  | _        |j                  | _        |j                  | _        |j                  | _        |j
                  | _        |j                  | _        t        «       | _        y r   )	r   Ú	repo_typeÚ	space_sdkÚprivateÚtokenÚexist_okÚresource_group_idr   Ú_api©Úselfr   s     r   Ú__init__zRepoCreateCommand.__init__•   s[   € Ø ŸL™LˆŒØ(,¯©ˆŒØ(,¯©ˆŒØ!Ÿ\™\ˆŒØ$(§J¡JˆŒ
Ø"Ÿm™mˆŒØ04×0FÑ0FˆÔÜ“Gˆ�	r   c           	      ón  — | j                   j                  | j                  | j                  | j                  | j
                  | j                  | j                  | j                  ¬«      }t        dt        j                  |j                  «      › d�«       t        dt        j                  |«      › �«       y )N)r   rL   rN   rO   rP   rQ   rM   zSuccessfully created z on the Hub.zYour repo is now available at )rR   Úcreate_repor   rL   rN   rO   rP   rQ   rM   Úprintr   Úbold)rT   Úrepo_urls     r   ÚrunzRepoCreateCommand.runŸ   sŒ   € Ø—9‘9×(Ñ(Ø—L‘LØ—n‘nØ—L‘LØ—*‘*Ø—]‘]Ø"×4Ñ4Ø—n‘nð )ó 
ˆô 	Ð%¤d§i¡i°×0@Ñ0@Ó&AÐ%BÀ,ÐOÔPÜÐ.¬t¯y©y¸Ó/BÐ.CÐDÕEr   N)rE   rF   rG   ÚargparseÚ	NamespacerU   r[   rI   r   r   r%   r%   ”   s   „ ð˜X×/Ñ/ó óFr   r%   c                   ó   — e Zd Zd„ Zy)ÚRepoTagCommandc                 óâ   — || _         t        t        |dd «      ¬«      | _        |j                  | _        t        |dd«      | _        | j
                  t        vrt        d«       t        d«       y y )NrO   )rO   rL   r+   zInvalid repo --repo-typeé   )	r   r   ÚgetattrÚapir   rL   r   rX   ÚexitrS   s     r   rU   zRepoTagCommand.__init__®   sZ   € ØˆŒ	Üœw t¨W°dÓ;Ô<ˆŒØ—|‘|ˆŒÜ   {°GÓ<ˆŒØ�>‰>¤Ñ+ÜÐ,Ô-Ü��Gð ,r   N)rE   rF   rG   rU   rI   r   r   r_   r_   ­   s   „ ór   r_   c                   ó   — e Zd Zd„ Zy)r0   c                 ó  — t        dt        j                  t        | j                  j
                  «      «      › d| j                  › dt        j                  | j                  «      › �«       	 | j                  j                  | j                  | j                  j
                  t        | j                  dd «      t        | j                  dd «      | j                  ¬«       t        dt        j                  t        | j                  j
                  «      «      › dt        j                  | j                  «      › �«       y # t        $ rT t        | j                  j                  «       › dt        j                  | j                  «      › d�«       t        d«       Y Œ»t        $ rO t        d	t        j                  t        t        | j                  dd «      «      «      › d�«       t        d«       Y �Œt        $ r‰}|j                   j"                  d
k(  rit        dt        j                  t        | j                  j
                  «      «      › dt        j                  | j                  «      › �«       t        d«       |‚d }~ww xY w)NzYou are about to create tag ú on ú ÚmessageÚrevision)r   r'   Útag_messagerj   rL   ú not found.ra   z	Revision i™  úTag z already exists on z created on )rX   r   rY   r<   r   r'   rL   r   rc   Ú
create_tagrb   r   Ú
capitalizerd   r   r
   ÚresponseÚstatus_code)rT   Úes     r   r[   zRepoTagCreateCommand.run¹   sÍ  € ÜØ*¬4¯9©9´S¸¿¹¿¹Ó5GÓ+HÐ*IÈÈdÏnÉnÐM]Ð]^Ô_c×_hÑ_hÐim×iuÑiuÓ_vÐ^wÐxô	
ð	Ø�H‰H×ÑØŸ™Ø—I‘I—M‘MÜ# D§I¡I¨y¸$Ó?Ü  §¡¨J¸Ó=ØŸ.™.ð  ô ô$ 	�”T—Y‘Yœs 4§9¡9§=¡=Ó1Ó2Ð3°<ÄÇ	Á	È$Ï,É,Ó@WÐ?XÐYÕZøô 'ò 	Ü�T—^‘^×.Ñ.Ó0Ð1°´4·9±9¸T¿\¹\Ó3JÐ2KÈ;ÐWÔXÜ�ŽGÜ$ò 	Ü�IœdŸi™i¬¬G°D·I±I¸zÈ4Ó,PÓ(QÓRÐSÐS^Ð_Ô`Ü��GÜò 	Ø�z‰z×%Ñ%¨Ò,Ü˜œTŸY™Y¤s¨4¯9©9¯=©=Ó'9Ó:Ð;Ð;NÌtÏyÉyÐY]×YeÑYeÓOfÐNgÐhÔiÜ�Q”ØˆGûð		ús(   Á-A2D> Ä>AJÆAJÇ0JÇ8BI<É<JN©rE   rF   rG   r[   rI   r   r   r0   r0   ¸   s   „ ó[r   r0   c                   ó   — e Zd Zd„ Zy)r4   c                 óö  — 	 | j                   j                  | j                  | j                  ¬«      }t        j                  «      dk(  rt        d«       t        d«       t        d| j                  › dt        j                  | j                  «      › d�«       |j                  D ]  }t        |j                   «       Œ y # t        $ rT t        | j                  j                  «       › dt        j                  | j                  «      › d�«       t        d«       Y Œêt        $ rS}t        |«       t        t        j                  |j                  j                  «      «       t        d«       Y d }~�Œ@d }~ww xY w)	N)r   rL   rh   rl   ra   r   zNo tags foundz	Tags for ú:)rc   Úlist_repo_refsr   rL   r   rX   ro   r   rY   rd   r   Úredrp   ÚtextÚlenÚtagsÚname)rT   Úrefsrr   r'   s       r   r[   zRepoTagListCommand.runÔ   s  € ð	Ø—8‘8×*Ñ*ØŸ™ØŸ.™.ð +ó ˆDô ˆt�y‰y‹>˜QÒÜ�/Ô"Ü�ŒGÜ�	˜$Ÿ.™.Ð)¨¬4¯9©9°T·\±\Ó+BÐ*CÀ1ÐEÔFØ—9‘9ò 	ˆCÜ�#—(‘(�Oñ	øô 'ò 	Ü�T—^‘^×.Ñ.Ó0Ð1°´4·9±9¸T¿\¹\Ó3JÐ2KÈ;ÐWÔXÜ�ŽGÜò 	Ü�!ŒHÜ”$—(‘(˜1Ÿ:™:Ÿ?™?Ó+Ô,Ü��GŠGûð	ús   ‚1C ÃAE8ÄE8Ä%AE3Å3E8Nrs   rI   r   r   r4   r4   Ó   s   „ ór   r4   c                   ó   — e Zd Zd„ Zy)r7   c           
      ó(  — t        dt        j                  | j                  j                  «      › d| j
                  › dt        j                  | j                  «      › �«       t        | j                  dd«      s2t        d«      j                  «       }|dvrt        d«       t        «        	 | j                  j                  | j                  | j                  j                  | j
                  ¬	«       t        dt        j                  | j                  j                  «      › dt        j                  | j                  «      › �«       y # t        $ rT t        | j
                  j                  «       › dt        j                  | j                  «      › d
�«       t        d«       Y Œ²t        $ rd t        dt        j                  | j                  j                  «      › dt        j                  | j                  «      › �«       t        d«       Y �Œw xY w)NzYou are about to delete tag rg   rh   ÚyesFzProceed? [Y/n] )Ú Úyr€   ÚAbort)r   r'   rL   rl   ra   rm   z not found on z deleted on )rX   r   rY   r   r'   rL   r   rb   ÚinputÚlowerrd   rc   Ú
delete_tagr   ro   r   )rT   Úchoices     r   r[   zRepoTagDeleteCommand.runê   sx  € ÜÐ,¬T¯Y©Y°t·y±y·}±}Ó-EÐ,FÀdÈ4Ï>É>ÐJZÐZ[Ô\`×\eÑ\eÐfj×frÑfrÓ\sÐ[tÐuÔvÜ�t—y‘y %¨Ô/ÜÐ,Ó-×3Ñ3Ó5ˆFØÐ-Ñ-Ü�g”Ü”ð	Ø�H‰H×Ñ¨¯©¸$¿)¹)¿-¹-ÐSW×SaÑSaÐÔbô 	�”T—Y‘Y˜tŸy™yŸ}™}Ó-Ð.¨l¼4¿9¹9ÀTÇ\Á\Ó;RÐ:SÐTÕUøô 'ò 	Ü�T—^‘^×.Ñ.Ó0Ð1°´4·9±9¸T¿\¹\Ó3JÐ2KÈ;ÐWÔXÜ�ŽGÜ$ò 	Ü�DœŸ™ 4§9¡9§=¡=Ó1Ð2°.ÄÇÁÈ4Ï<É<ÓAXÐ@YÐZÔ[Ü��Gð	ús   Â-AE	 Å	AHÆ%A(HÈHNrs   rI   r   r   r7   r7   é   s   „ óVr   r7   )Ú__doc__r\   r   Útypingr   Úrequests.exceptionsr   Úhuggingface_hub.commandsr   Ú#huggingface_hub.commands._cli_utilsr   Úhuggingface_hub.constantsr   r	   Úhuggingface_hub.errorsr
   r   r   Úhuggingface_hub.hf_apir   Úhuggingface_hub.utilsr   Ú
get_loggerrE   Úloggerr   r%   r_   r0   r4   r7   rI   r   r   ú<module>r“      s‘   ðñó Ý &Ý å )å >Ý 4ß Bß aÑ aÝ (Ý )ð 
ˆ×	Ñ	˜HÓ	%€ôhUÐ,ô hU÷VFñ F÷2ñ ô[˜>ô [ô6˜ô ô,V˜>õ Vr   