o
    i%                     @   s  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eZedd	Zed
d	Zedd	Zejedd ejedd G dd deejZej ddd	ej!dddddfdededeee ej"dd	f dededee#ej"dd	f deee ej"dd	f ddfdd Z$ej d!d"d	ej!ddfdededed#ee#ej"d$d	f ddf
d%d&Z%ej d'd(d	dej!fd)ed*edededdf
d+d,Z&ej d-d.d	dddej!fded/eee ej"d0d	f deee# ej"d1d	f dededdfd2d3Z'ej dd4d	ddej!dfdedeeej(d5d	f d6edededee#ej"d7d	f ddfd8d9Z)ej d!d:d	dej!fdedeeej(d;d	f dededdf
d<d=Z*ej dd>d	dddej!fdedeeej(d?d	f d@eee ej"dAdBdCd	f d6edededdfdDdEZ+ej dFdGd	dej!fdedededdfdHdIZ,ej d!dJd	ddej!fdedeeej(dKd	f dLee#ej"dMdNdOd	f dededdfdPdQZ-dS )Ra  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                   @   s   e Zd ZdZdZdZdS )GatedChoicesautomanualfalseN)__name__
__module____qualname__r   r   r    r   r   ^/var/www/html/karishye-ai-python/venv/lib/python3.10/site-packages/huggingface_hub/cli/repo.pyr   5   s    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           	   	   C   sT   t |d}|j| |j|||||d}tdt|j d tdt|  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_urlr   r   r   repo_create;   s   
	r1   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                 C   s6   t |d}|j| |j|d tdt|  d d S )Nr(   )r    r!   r3   Successfully deleted r*   )r   delete_repor,   r-   r   r.   )r    r!   r$   r3   r/   r   r   r   repo_deleteb   s   
r6   movez8Move a repository from a namespace to another namespace.from_idto_idc                 C   sB   t |d}|j| ||jd tdt|  dt| d d S )Nr(   )r8   r9   r!   zSuccessfully moved z to r*   )r   	move_repor,   r-   r   r.   )r8   r9   r$   r!   r/   r   r   r   	repo_movew   s   
&r;   settingsz$Update the settings of a repository.gatedz$The gated status for the repository.z)Whether the repository should be private.c                 C   sB   t |d}|j| |r|jnd ||jd tdt|  d d S )Nr(   )r    r=   r#   r!   z%Successfully updated the settings of r*   )r   update_repo_settingsr,   r-   r   r.   )r    r=   r#   r$   r!   r/   r   r   r   repo_settings   s   
r?   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              	   C   sL   t |d}|j| |||j|d tdt| d|j dt|   d S )Nr(   )r    r   r@   r!   r%   r)    branch on  )r   create_branchr,   r-   r   r.   )r    r   r@   r$   r!   r%   r/   r   r   r   branch_create   s   
,rD   z'Delete a branch from a repo on the Hub.z!The name of the branch to delete.c              	   C   sH   t |d}|j| ||jd tdt| d|j dt|   d S )Nr(   )r    r   r!   r4   rA   rB   )r   delete_branchr,   r-   r   r.   )r    r   r$   r!   r/   r   r   r   branch_delete   s   
,rF   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           	   
   C   s0  |j }t|d}tdt| d| dt|   z|j| ||||d W n^ tyC   t|  dt|  d tj	dd t
y\   td	tt| d tj	dd ty } z|jjd
krtdt| dt|   tj	dd|d }~ww tdt| dt|   d S )Nr(   zYou are about to create tag  on rB   )r    r   tag_messager@   r!    not found.r	   codez	Revision i  Tag z already exists on z created on )r,   r   r-   r   r.   
create_tagr   
capitalizetyperExitr   strr   responsestatus_code)	r    r   rG   r@   r$   r!   repo_type_strr/   er   r   r   
tag_create   s&   
& $rW   listzList tags for a repo.c              
   C   s   |j }t|d}z	|j| |d}W n: ty-   t|  dt|  d tj	dd t
yK } zt| tt|jj tj	ddd }~ww t|jdkr]td tj	ddtd	| dt|  d
 |jD ]}t|j qnd S )Nr(   )r    r!   rB   rJ   r	   rK   r   zNo tags foundz	Tags for :)r,   r   list_repo_refsr   r-   rO   r   r.   rP   rQ   r   redrS   textlentagsr   )r    r$   r!   rU   r/   refsrV   tr   r   r   tag_list   s(   

ra   zDelete a tag for a repo.zThe name of the tag to delete.yesz-yz--yesz"Answer Yes to prompt automaticallyc              
   C   s  |j }tdt| d| dt|   |s*td }|dvr*td t t|d}z
|j	| ||d W n8 t
yU   t|  dt|  d	 tjd
d tyq   tdt| dt|   tjd
dw tdt| dt|   d S )NzYou are about to delete tag rH   rB   zProceed? [Y/n] ) yrb   Abortr(   )r    r   r!   rJ   r	   rK   rM   z not found on z deleted on )r,   r-   r   r.   inputlowerrP   rQ   r   
delete_tagr   rO   r   )r    r   rb   r$   r!   rU   choicer/   r   r   r   
tag_delete  s$   &
 $rj   ).__doc__enumtypingr   r   rP   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_typerrR   Enumr   commandmodelOptionboolr1   r6   r;   r?   ArgumentrD   rF   rW   ra   rj   r   r   r   r   <module>   s  
(



	
&
		
		
'