
    ai%                     *   d Z ddlZddlmZmZ ddlZddl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  ed	      Z ed
	      Z ed	      Zej1                  ed       ej1                  ed        G d deej4                        Zej9                  dd	      ej:                  dddddfdededeee    ej<                  d	      f   dededee ej<                  d	      f   deee    ej<                  d	      f   ddfd       Z ej9                  d d!	      ej:                  ddfdededed"ee ej<                  d#	      f   ddf
d$       Z!ej9                  d%d&	      dej:                  fd'ed(edededdf
d)       Z"ej9                  d*d+	      dddej:                  fded,eee    ej<                  d-	      f   deee    ej<                  d.	      f   dededdfd/       Z#ej9                  dd0	      ddej:                  dfdedee ejH                  d1	      f   d2edededee ej<                  d3	      f   ddfd4       Z%ej9                  d d5	      dej:                  fdedee ejH                  d6	      f   dededdf
d7       Z&ej9                  dd8	      dddej:                  fdedee ejH                  d9	      f   d:eee    ej<                  d;d<d=	      f   d2edededdfd>       Z'ej9                  d?d@	      dej:                  fdedededdfdA       Z(ej9                  d dB	      ddej:                  fdedee ejH                  dC	      f   dDee ej<                  dEdFdG	      f   dededdfdH       Z)y)Ia  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)	AnnotatedOptional)HfHubHTTPErrorRepositoryNotFoundErrorRevisionNotFoundError)ANSI   )
PrivateOpt	RepoIdArgRepoTypeRepoTypeOptRevisionOptTokenOpt
get_hf_apityper_factoryzManage repos on the Hub.)helpz"Manage tags for a repo on the Hub.z&Manage branches for a repo on the Hub.tag)namebranchc                       e Zd ZdZdZdZy)GatedChoicesautomanualfalseN)__name__
__module____qualname__r   r   r        b/home/obispo/Crisostomo_bridge/mision_env/lib/python3.12/site-packages/huggingface_hub/cli/repo.pyr   r   *   s    DFEr   r   createzCreate a new repo on the Hub.Frepo_id	repo_type	space_sdkzEHugging Face Spaces SDK type. Required when --type is set to 'space'.privatetokenexist_okz-Do not raise an error if repo already exists.resource_group_idzoResource group in which to create the repo. Resource groups is only available for Enterprise Hub organizations.returnc           	          t        |      }|j                  | |j                  |||||      }t        dt	        j
                  |j                         d       t        dt	        j
                  |              y )Nr&   )r"   r#   r%   r&   r'   r(   r$   Successfully created  on the Hub.zYour repo is now available at )r   create_repovalueprintr   boldr"   )	r"   r#   r$   r%   r&   r'   r(   apirepo_urls	            r    repo_creater4   0   sx    2 5
!C//+  H 
!$))H,<,<"=!>l
KL	*499X+>*?
@Ar   deletez>Delete a repo from the Hub. this is an irreversible operation.
missing_okz=If set to True, do not raise an error if repo does not exist.c                     t        |      }|j                  | |j                  |       t        dt	        j
                  |        d       y )Nr+   )r"   r#   r6   Successfully deleted r-   )r   delete_repor/   r0   r   r1   )r"   r#   r&   r6   r2   s        r    repo_deleter:   W   sJ     5
!COO//  
 
!$))G"4!5\
BCr   movez8Move a repository from a namespace to another namespace.from_idto_idc                     t        |      }|j                  | ||j                         t        dt	        j
                  |        dt	        j
                  |       d       y )Nr+   )r<   r=   r#   zSuccessfully moved z to r-   )r   	move_repor/   r0   r   r1   )r<   r=   r&   r#   r2   s        r    	repo_mover@   l   sZ     5
!CMM//  
 
		' 234		%8H7I
VWr   settingsz$Update the settings of a repository.gatedz$The gated status for the repository.z)Whether the repository should be private.c                     t        |      }|j                  | |r|j                  nd ||j                         t        dt	        j
                  |        d       y )Nr+   )r"   rB   r%   r#   z%Successfully updated the settings of r-   )r   update_repo_settingsr/   r0   r   r1   )r"   rB   r%   r&   r#   r2   s         r    repo_settingsrE   |   sW    $ 5
!C#u{{//	   
1$))G2D1E\
RSr   z*Create a new branch for a repo on the Hub.z!The name of the branch to create.revisionz?If set to True, do not raise an error if branch already exists.c           
          t        |      }|j                  | |||j                  |       t        dt	        j
                  |       d|j                   dt	        j
                  |               y )Nr+   )r"   r   rF   r#   r'   r,    branch on  )r   create_branchr/   r0   r   r1   )r"   r   rF   r&   r#   r'   r2   s          r    branch_createrK      sp    & 5
!C//   
!$))F"3!4K	?PPQRVR[R[\cRdQe
fgr   z'Delete a branch from a repo on the Hub.z!The name of the branch to delete.c           
          t        |      }|j                  | ||j                         t        dt	        j
                  |       d|j                   dt	        j
                  |               y )Nr+   )r"   r   r#   r8   rH   rI   )r   delete_branchr/   r0   r   r1   )r"   r   r&   r#   r2   s        r    branch_deleterN      sj     5
!C//  
 
!$))F"3!4K	?PPQRVR[R[\cRdQe
fgr   zCreate a tag for a repo.zThe name of the tag to create.messagez-mz	--messagez%The description of the tag to create.c           
      h   |j                   }t        |      }t        dt        j                  |       d| dt        j                  |               	 |j                  | ||||       t        dt        j                  |       dt        j                  |               y # t        $ rI t        |j                          dt        j                  |        d       t        j                  d      t        $ rB t        d	t        j                  t        |             d       t        j                  d      t        $ rm}|j                  j                  d
k(  rMt        dt        j                  |       dt        j                  |               t        j                  d      |d }~ww xY w)Nr+   zYou are about to create tag  on rI   )r"   r   tag_messagerF   r#    not found.r	   codez	Revision i  Tag z already exists on z created on )r/   r   r0   r   r1   
create_tagr   
capitalizetyperExitr   strr   responsestatus_code)	r"   r   rO   rF   r&   r#   repo_type_strr2   es	            r    
tag_creater`      sd   * OOM
5
!C	(3(8]O1TYYW^M_L`
abwCWxcpq 
D3 TYYw-?,@
AB # !))+,Adii.@-AMNjja    !	$))CM23;?@jja   ::!!S(D3((;DIIg<N;OPQ**!$$	s   B" "B"F1A(F,,F1listzList tags for a repo.c                    |j                   }t        |      }	 |j                  | |      }t        |j                        dk(  r!t	        d       t        j                  d      t	        d	| dt        j                  |        d
       |j                  D ]  }t	        |j                           y # t        $ rI t	        |j                          dt        j                  |        d       t        j                  d      t        $ rX}t	        |       t	        t        j                  |j                  j                               t        j                  d      d }~ww xY w)Nr+   )r"   r#   rI   rS   r	   rT   r   zNo tags foundz	Tags for :)r/   r   list_repo_refsr   r0   rX   r   r1   rY   rZ   r   redr\   textlentagsr   )r"   r&   r#   r^   r2   refsr_   ts           r    tag_listrk      s    OOM
5
!C!!!']!K 499~ojja  	Im_Adii&8%9
;<YY aff # !))+,Adii.@-AMNjja   !adhhqzz'(jja  !s   B2 2AE#AEE#zDelete a tag for a repo.zThe name of the tag to delete.yesz-yz--yesz"Answer Yes to prompt automaticallyc           
         |j                   }t        dt        j                  |       d| dt        j                  |               |s<t	        d      j                         }|dvrt        d       t        j                         t        |      }	 |j                  | ||       t        dt        j                  |       dt        j                  |               y # t        $ rI t        |j                          dt        j                  |        d	       t        j                  d
      t        $ rN t        dt        j                  |       dt        j                  |               t        j                  d
      w xY w)NzYou are about to delete tag rQ   rI   zProceed? [Y/n] ) yrl   Abortr+   )r"   r   r#   rS   r	   rT   rV   z not found on z deleted on )r/   r0   r   r1   inputlowerrY   rZ   r   
delete_tagr   rX   r   )r"   r   rl   r&   r#   r^   choicer2   s           r    
tag_deleteru     sC   ( OOM	(3(8]O1TYYW^M_L`
ab()//1))'N**,
5
!C!wC=I 
D3 TYYw-?,@
AB # !))+,Adii.@-AMNjja    !TYYs^$N499W3E2FGHjja  !s   C B'F)*__doc__enumtypingr   r   rY   huggingface_hub.errorsr   r   r   huggingface_hub.utilsr   
_cli_utilsr
   r   r   r   r   r   r   r   repo_clitag_cli
branch_cli	add_typerr[   Enumr   commandmodelOptionboolr4   r:   r@   rE   ArgumentrK   rN   r`   rk   ru   r   r   r    <module>r      sC    &  a a & v v v 89
A
B HI
   7  '   :H  -3		  
(!@A &^^ 	 	 	-#B#B#B X	
	#B #B #B @	
	#B" ! C	
	##B. 
/#B B#BL 
(!ab &^^ 	DDD D P	
		D 
D cD( 
&YZ %^^	XXX X 	X
 
X [X 
*#IJ 	 	%^^TT7	
	T <	
	T T T  
!T KT6 H#OP !%^^ 	!hh4	
	h h h h R	
	h" 
#h Qh: H#LM %^^hh4	
	h h h 
h Nh( 	 :;  	 %^^%$C$C	1	
	
$C 8	
	$C  !$C" #$C$ %$C& 
'$C <$CN 	56 %^^  
	 70 	 :;  	%^^##C#C	1	
	
#C 
5	
	
#C  !#C" ##C$ 
%#C <#Cr   