
    AF[i%                     R   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mZ ddlmZmZmZmZmZmZmZmZ  ej,                  e      Z ed	      Z ed
	      Z ed	      Zej9                  ed       ej9                  ed        G d deej<                        ZejA                  dd	      ejB                  dddddfdededeee    ejD                  d	      f   dededee# ejD                  d	      f   deee    ejD                  d	      f   ddfd       Z$ejA                  d d!	      ejB                  ddfdededed"ee# ejD                  d#	      f   ddf
d$       Z%ejA                  d%d&	      dejB                  fd'ed(edededdf
d)       Z&ejA                  d*d+	      dddejB                  fded,eee    ejD                  d-	      f   deee#    ejD                  d.	      f   dededdfd/       Z'ejA                  dd0	      ddejB                  dfdedee ejP                  d1	      f   d2edededee# ejD                  d3	      f   ddfd4       Z)ejA                  d d5	      dejB                  fdedee ejP                  d6	      f   dededdf
d7       Z*ejA                  dd8	      dddejB                  fdedee ejP                  d9	      f   d:eee    ejD                  d;d<d=	      f   d2edededdfd>       Z+ejA                  d?d@	      dejB                  fdedededdfdA       Z,ejA                  d dB	      ddejB                  fdedee ejP                  dC	      f   dDee# ejD                  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logging   )
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        a/var/www/html/chatbot/moweb-chatbot/venv/lib/python3.12/site-packages/huggingface_hub/cli/repo.pyr   r   5   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_creater5   ;   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$   r7   Successfully deleted r.   )r   delete_repor0   r1   r   r2   )r#   r$   r'   r7   r3   s        r!   repo_deleter;   b   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_repor0   r1   r   r2   )r=   r>   r'   r$   r3   s        r!   	repo_moverA   w   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#   rC   r&   r$   z%Successfully updated the settings of r.   )r   update_repo_settingsr0   r1   r   r2   )r#   rC   r&   r'   r$   r3   s         r!   repo_settingsrF      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   rG   r$   r(   r-    branch on  )r   create_branchr0   r1   r   r2   )r#   r   rG   r'   r$   r(   r3   s          r!   branch_createrL      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$   r9   rI   rJ   )r   delete_branchr0   r1   r   r2   )r#   r   r'   r$   r3   s        r!   branch_deleterO      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 rJ   )r#   r   tag_messagerG   r$    not found.r
   codez	Revision i  Tag z already exists on z created on )r0   r   r1   r   r2   
create_tagr   
capitalizetyperExitr   strr   responsestatus_code)	r#   r   rP   rG   r'   r$   repo_type_strr3   es	            r!   
tag_createra      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$   rJ   rT   r
   rU   r   zNo tags foundz	Tags for :)r0   r   list_repo_refsr   r1   rY   r   r2   rZ   r[   r   redr]   textlentagsr   )r#   r'   r$   r_   r3   refsr`   ts           r!   tag_listrl      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 rR   rJ   zProceed? [Y/n] ) yrm   Abortr,   )r#   r   r$   rT   r
   rU   rW   z not found on z deleted on )r0   r1   r   r2   inputlowerrZ   r[   r   
delete_tagr   rY   r   )r#   r   rm   r'   r$   r_   choicer3   s           r!   
tag_deleterv     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   rZ   huggingface_hub.errorsr   r   r   huggingface_hub.utilsr   r	   
_cli_utilsr   r   r   r   r   r   r   r   
get_loggerr   loggerrepo_clitag_cli
branch_cli	add_typerr\   Enumr   commandmodelOptionboolr5   r;   rA   rF   ArgumentrL   rO   ra   rl   rv   r   r    r!   <module>r      s[    &  a a /	 	 	 
		H	%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    