
    RX9iz)                     ,   S r SSKrSSKJr  SSKJr  SSKJr  SSKJr  SSK	J
r
  SSKJrJr  SS	KJrJrJr  SS
KJr  SSKJr  \R,                  " \5      r " S S\5      r " S S5      r " S S5      r " S S\5      r " S S\5      r " S S\5      rg)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                   ,    \ rS rSr\S\4S j5       rSrg)RepoCommands)   parserc                   ^ U R                  SSS9mTR                  SS9nTR                  U4S jS9  UR                  SSS9nUR                  S	[        S
S9  UR                  S[        SS9  UR                  S[        S[
        S9  UR                  SSSS9  UR                  S[        SS9  UR                  SSSS9  UR                  S[        SS9  UR                  S S9  UR                  SSS9nUR                  SSS S!9nUR                  SS"S9nUR                  S	[        S#S9  UR                  S[        S$S9  UR                  S%S&[        S'S9  UR                  S([        S)S9  UR                  S[        S*S9  UR                  S/ S+QS,S-S.9  UR                  S/ S9  UR                  S0S1S9nUR                  S	[        S2S9  UR                  S[        S*S9  UR                  S/ S+QS,S-S.9  UR                  S3 S9  UR                  S4S5S9nUR                  S	[        S6S9  UR                  S[        S7S9  UR                  S8S9SS:S9  UR                  S[        S*S9  UR                  S/ S+QS,S-S.9  UR                  S; S9  g )<NrepozManage repos on the Hub.)helpz%huggingface.co repos related commandsc                 $   > TR                  5       $ N)
print_help)argsrepo_parsers    X/var/www/html/land-doc-ocr/venv/lib/python3.13/site-packages/huggingface_hub/cli/repo.py<lambda>2RepoCommands.register_subcommand.<locals>.<lambda>0   s    ;3I3I3K    )funccreatez#Create a new repo on huggingface.corepo_idzThe 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                     [        U 5      $ r   )RepoCreateCommandr   s    r   r   r   X   s
    :KD:Qr   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                     [        U 5      $ r   )RepoTagCreateCommandr(   s    r   r   r   o   
    9Md9Sr   listzList tags for a repo.z@The ID of the repo to list tags for (e.g. `username/repo-name`).c                     [        U 5      $ r   )RepoTagListCommandr(   s    r   r   r      s
    7I$7Or   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                     [        U 5      $ r   )RepoTagDeleteCommandr(   s    r   r   r      r3   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_subcommand RepoCommands.register_subcommand*   s{   ''5O'P%44:a4b 	  &K L -77Gl7m'' [ 	( 	

 	''j 	( 	

 	''b$	 	( 	
 	''{ 	( 	

 	''_ 	( 	

 	''@ 	( 	

 	''! C 	( 	

 	''-Q'R *44UAe4f(77]Q]hl7m +55hE_5`&&C&^ 	' 	
 	&&u3=]&^&&t[sIp&q&&|#D^&_&&C&r 	' 	
 	&&1I	 	' 	
 	&&,S&T )33FAX3Y$$C&h 	% 	
 	$$C&r 	% 	
 	$$1I	 	% 	
 	$$*O$P +55hE`5a&&C&n 	' 	
 	&&u3=]&^&&tW\Pv&w&&C&r 	' 	
 	&&1I	 	' 	
 	&&,S&Tr    N)__name__
__module____qualname____firstlineno__staticmethodr   rF   __static_attributes__rH   r   r   r   r   )   s"    fU$5 fU fUr   r   c                   <    \ rS rSrS\R
                  4S jrS rSrg)r'      r   c                    UR                   U l         UR                  U l        UR                  U l        UR                  U l        UR                  U l        UR
                  U l        UR                  U l        [        5       U l        g r   )	r!   	repo_type	space_sdkprivatetokenexist_okresource_group_idr   _apiselfr   s     r   __init__RepoCreateCommand.__init__   s[     LL(,(,!\\$(JJ
"mm040F0FG	r   c           
      l   U R                   R                  U R                  U R                  U R                  U R
                  U R                  U R                  U R                  S9n[        S[        R                  " UR                  5       S35        [        S[        R                  " U5       35        g )N)r!   rR   rT   rU   rV   rW   rS   zSuccessfully created z on the Hub.zYour repo is now available at )rX   create_repor!   rR   rT   rU   rV   rW   rS   printr   bold)rZ   repo_urls     r   runRepoCreateCommand.run   s    99((LLnnLL**]]"44nn ) 
 	%dii0@0@&A%B,OP.tyy/B.CDEr   )rX   rV   rT   r!   rR   rW   rS   rU   N)	rI   rJ   rK   rL   argparse	Namespacer[   rb   rN   rH   r   r   r'   r'      s    X// Fr   r'   c                       \ rS rSrS rSrg)RepoTagCommand   c                     Xl         [        [        USS 5      S9U l        UR                  U l        [        USS5      U l        U R
                  [        ;  a  [        S5        [        S5        g g )NrU   )rU   rR   r-   zInvalid repo --repo-type   )	r   r   getattrapir!   rR   r   r_   exitrY   s     r   r[   RepoTagCommand.__init__   sX    	wtWd;<|| {G<>>+,-G ,r   )rl   r   r!   rR   N)rI   rJ   rK   rL   r[   rN   rH   r   r   rg   rg      s    r   rg   c                       \ rS rSrS rSrg)r2      c                    [        S[        R                  " [        U R                  R
                  5      5       SU R                   S[        R                  " U R                  5       35         U R                  R                  U R                  U R                  R
                  [        U R                  SS 5      [        U R                  SS 5      U R                  S9  [        S[        R                  " [        U R                  R
                  5      5       S[        R                  " U R                  5       35        g ! [         aU    [        U R                  R                  5        S[        R                  " U R                  5       S35        [        S5         N[         aP    [        S	[        R                  " [        [        U R                  SS 5      5      5       S35        [        S5         GN[         a  nUR                   R"                  S
:X  ak  [        S[        R                  " [        U R                  R
                  5      5       S[        R                  " U R                  5       35        [        S5        UeS nAff = f)NzYou are about to create tag  on  messagerevision)r!   r)   tag_messageru   rR    not found.rj   z	Revision i  Tag z already exists on z created on )r_   r   r`   r>   r   r)   rR   r!   rl   
create_tagrk   r   
capitalizerm   r   r
   responsestatus_code)rZ   es     r   rb   RepoTagCreateCommand.run   s   *499S5G+H*IdnnM]]^_c_h_himiuiu_v^wx	
	HHIIMM#DIIy$? J=..   $ 	TYYs499==123<		$,,@W?XYZ ' 	T^^..01499T\\3J2K;WXG$ 	IdiiGDIIz4,P(QRSS^_`G 	zz%%,TYYs499=='9:;;NtyyY]YeYeOfNghiQG		s(   /A/D? ?AJ
AJ
5	J
>BJJ
rH   NrI   rJ   rK   rL   rb   rN   rH   r   r   r2   r2      s    [r   r2   c                       \ rS rSrS rSrg)r6      c                      U R                   R                  U R                  U R                  S9n[        WR                  5      S:X  a  [        S5        [        S5        [        SU R                   S[        R                  " U R                  5       S35        UR                   H  n[        UR                   5        M     g ! [         aU    [        U R                  R                  5        S[        R                  " U R                  5       S35        [        S5         N[         aT  n[        U5        [        [        R                  " UR                  R                  5      5        [        S5         S nAGNHS nAff = f)	N)r!   rR   rs   rw   rj   r   zNo tags foundz	Tags for :)rl   list_repo_refsr!   rR   r   r_   rz   r   r`   rm   r   redr{   textlentagsname)rZ   refsr}   r)   s       r   rb   RepoTagListCommand.run   s   	88**.. + D tyy>Q/"G	$..)499T\\+B*C1EF99C#((O  ' 	T^^..01499T\\3J2K;WXG 	!H$((1::??+,GG	s   .C AE= 	E=)A	E88E=rH   Nr   rH   r   r   r6   r6      s    r   r6   c                       \ rS rSrS rSrg)r9      c           
      B   [        S[        R                  " U R                  R                  5       SU R
                   S[        R                  " U R                  5       35        [        U R                  SS5      (       d4  [        S5      R                  5       nUS;  a  [        S5        [        5          U R                  R                  U R                  U R                  R                  U R
                  S	9  [        S[        R                  " U R                  R                  5       S[        R                  " U R                  5       35        g ! [         aU    [        U R
                  R                  5        S[        R                  " U R                  5       S
35        [        S5         N[         af    [        S[        R                  " U R                  R                  5       S[        R                  " U R                  5       35        [        S5         GN$f = f)NzYou are about to delete tag rr   rs   yesFzProceed? [Y/n] ) yr   Abort)r!   r)   rR   rw   rj   rx   z not found on z deleted on )r_   r   r`   r   r)   rR   r!   rk   inputlowerrm   rl   
delete_tagr   rz   r   )rZ   choices     r   rb   RepoTagDeleteCommand.run   s{   ,TYYtyy}}-E,Fd4>>JZZ[\`\e\efjfrfr\s[tuvtyy%//,-335F--g	HH$))--SWSaSab 	TYYtyy}}-.l499T\\;R:STU ' 	T^^..01499T\\3J2K;WXG$ 	D499==12.4<<AX@YZ[G	s   6AE AH/A+HHrH   Nr   rH   r   r   r9   r9      s    Vr   r9   )__doc__rd   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_loggerrI   loggerr   r'   rg   r2   r6   r9   rH   r   r   <module>r      s     &  ) > 4 B a a ( ) 
		H	%hU, hUVF F2 [> [6 ,V> Vr   