
    o i%                        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                    ed           e                    ed            G d deej                  Ze                     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                     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                     d%d&	          dej!        fd'ed(edededdf
d)            Z&e                     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                     dd0	          ddej!        dfdedee ej(        d1	          f         d2edededee# ej"        d3	          f         ddfd4            Z)e                     d d5	          dej!        fdedee ej(        d6	          f         dededdf
d7            Z*e                     dd8	          dddej!        fdedee ej(        d9	          f         d:eee          ej"        d;d<d=	          f         d2edededdfd>            Z+e                     d?d@	          dej!        fdedededdfdA            Z,e                     d dB	          ddej!        fdedee ej(        dC	          f         dDee# ej"        dEdFdG	          f         dededdfdH            Z-dS )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dS )GatedChoicesautomanualfalseN)__name__
__module____qualname__r   r   r        X/var/www/html/auto_sub_bot/venv/lib/python3.11/site-packages/huggingface_hub/cli/repo.pyr   r   5   s        DFEEEr    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        |||||          }t          dt	          j        |j                   d           t          dt	          j        |                      d S )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   ;   s    2 5
!
!
!C/+   H 

K$)H,<"="=
K
K
KLLL	
@49X+>+>
@
@AAAA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        |           t          dt	          j        |            d           d S )Nr,   )r#   r$   r7   Successfully deleted r.   )r   delete_repor0   r1   r   r2   )r#   r$   r'   r7   r3   s        r!   repo_deleter;   b   sf     5
!
!
!COO/    
 

B$)G"4"4
B
B
BCCCCCr    movez8Move a repository from a namespace to another namespace.from_idto_idc                     t          |          }|                    | ||j                   t          dt	          j        |            dt	          j        |           d           d S )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   sx     5
!
!
!CMM/    
 

V	' 2 2
V
V	%8H8H
V
V
VWWWWWr    settingsz$Update the settings of a repository.gatedz$The gated status for the repository.z)Whether the repository should be private.c                     t          |          }|                    | |r|j        nd ||j                   t          dt	          j        |            d           d S )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      sv    $ 5
!
!
!C#-u{{/	     

R$)G2D2D
R
R
RSSSS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        |           t          dt	          j        |           d|j         dt	          j        |                       d S )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      s    & 5
!
!
!C/     

f$)F"3"3
f
f	
f
fRVR[\cRdRd
f
fgggggr    z'Delete a branch from a repo on the Hub.z!The name of the branch to delete.c           
          t          |          }|                    | ||j                   t          dt	          j        |           d|j         dt	          j        |                       d S )Nr,   )r#   r   r$   r9   rI   rJ   )r   delete_branchr0   r1   r   r2   )r#   r   r'   r$   r3   s        r!   branch_deleterO      s     5
!
!
!C/    
 

f$)F"3"3
f
f	
f
fRVR[\cRdRd
f
fgggg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           
         |j         }t          |          }t          dt          j        |           d| dt          j        |                       	 |                    | ||||           n# t          $ rO t          |                                 dt          j        |            d           t          j	        d          t          $ rH t          d	t          j        t          |                     d           t          j	        d          t          $ re}|j        j        d
k    rNt          dt          j        |           dt          j        |                       t          j	        d          |d }~ww xY wt          dt          j        |           dt          j        |                       d S )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      s   * OM
5
!
!
!C	
a3
a
a]
a
aTYW^M_M_
a
abbbwCWxcpqqqq" ! ! !))++MMdi.@.@MMMNNNja      ! ! !?$)CMM22???@@@ja       :!S((P3PPDIg<N<NPPQQQ*!$$$$	
 

A3
A
ATYw-?-?
A
ABBBBBs   A1 1B1F"A FFlistzList tags for a repo.c                    |j         }t          |          }	 |                    | |          }n# t          $ rO t	          |                                 dt          j        |            d           t          j	        d          t          $ rT}t	          |           t	          t          j        |j        j                             t          j	        d          d }~ww xY wt          |j                  dk    r$t	          d           t          j	        d          t	          d	| dt          j        |            d
           |j        D ]}t	          |j                   d S )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      sy    OM
5
!
!
!C!!!']!KK" ! ! !))++MMdi.@.@MMMNNNja     ! ! !adhqz''(((ja    ! 49~~oja    	
;m
;
;di&8&8
;
;
;<<<Y  af s   1 A!C&AC!!C&zDelete a tag for a repo.zThe name of the tag to delete.yesz-yz--yesz"Answer Yes to prompt automaticallyc           
      J   |j         }t          dt          j        |           d| dt          j        |                       |sGt	          d                                          }|dvr"t          d           t          j                    t          |          }	 |	                    | ||           n# t          $ rO t          |                                 dt          j        |            d	           t          j        d
          t          $ rO t          dt          j        |           dt          j        |                       t          j        d
          w xY wt          dt          j        |           dt          j        |                       d S )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     s   ( OM	
a3
a
a]
a
aTYW^M_M_
a
abbb ())//11)))'NNN*,,
5
!
!
!C!wC=IIII" ! ! !))++MMdi.@.@MMMNNNja      ! ! !GTYs^^GG49W3E3EGGHHHja    ! 

A3
A
ATYw-?-?
A
ABBBBBs   B7 7B0E').__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      sz     & & & & & & & &  a a a a a a a a a a / / / / / / / /	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 
	H	%	%=8999
-A
B
B
B] HIII
   7  ' ' '   :H  - - -    3	    
(!@AA &^ 	 	 	-#B #B#B#B X	
 	
 	
	#B #B #B @	
 	
 	
	#B" ! C	
 	
 	
	##B. 
/#B #B #B BA#BL 
(!abb &^ 	D DDD D P	
 	
 	
		D 
D D D cbD( 
&YZZ %^	X XXX X 	X
 
X X X [ZX 
*#IJJ 	 	%^T TT7	
 	
 	
	T <	
 	
 	
	T T T  
!T T T KJT6 H#OPP !%^ 	!h hh4	
 	
 	
	h h h h R	
 	
 	
	h" 
#h h h QPh: H#LMM %^h hh4	
 	
 	
	h h h 
h h h NMh( 	 :;;  	 %^%$C $C$C	1	
 	
 	
	
$C 8	
 	
 	
	$C  !$C" #$C$ %$C& 
'$C $C $C <;$CN 	566 %^   
	   760 	 :;;  	%^##C #C#C	1	
 	
 	
	
#C 
5	
 	
 	
	
#C  !#C" ##C$ 
%#C #C #C <;#C #C #Cr    