U
    ”Ê¹jš  ã                   @   s˜   d Z ddlZddlmZ ddlmZ ddlmZ ddlmZ ddl	m
Z
 ddlmZ dd	lmZ d
dlmZ e e¡ZG dd„ deƒZG dd„ dƒZdS )a&  Contains commands to interact with repositories on the Hugging Face Hub.

Usage:
    # create a new dataset repo on the Hub
    huggingface-cli repo create my-cool-dataset --repo-type=dataset

    # create a private model repo on the Hub
    huggingface-cli repo create my-cool-model --private
é    N)Ú_SubParsersAction)ÚOptional)ÚBaseHuggingfaceCLICommand)ÚANSI)ÚSPACES_SDK_TYPES)ÚHfApi)Úloggingé   )Úshow_deprecation_warningc                   @   s   e Zd Zeedœdd„ƒZdS )ÚRepoCommands)Úparserc                 C   sà   | j ddd�}|jdd�}|j ddd�}|jdtdd	� |jd
tdd	� |jdtdtd� |jdddd� |jdtdd	� |jdddd� |jdtdd	� |jdtdd	� |jddddd� |jdtdd	� |jd d!„ d"� d S )#NÚrepoz={create} Commands to interact with your huggingface.co repos.)Úhelpz%huggingface.co repos related commandsÚcreatez#Create a new repo on huggingface.coÚrepo_idz‡The 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.z--typez&[Deprecated]: use --repo-type instead.z-yz--yesz[Deprecated] no effect.z--organizationzE[Deprecated] Pass the organization namespace directly in the repo_id.c                 S   s   t | ƒS )N)ÚRepoCreateCommand©Úargs© r   ú\/var/www/html/bwave/python/venv/lib/python3.8/site-packages/huggingface_hub/commands/repo.pyÚ<lambda>`   ó    z2RepoCommands.register_subcommand.<locals>.<lambda>)Úfunc)Ú
add_parserÚadd_subparsersÚadd_argumentÚstrr   Úset_defaults)r   Zrepo_parserZrepo_subparsersZrepo_create_parserr   r   r   Úregister_subcommand)   sp    ýýüýýýýýü  ÿz RepoCommands.register_subcommandN)Ú__name__Ú
__module__Ú__qualname__Ústaticmethodr   r"   r   r   r   r   r   (   s   r   c                   @   s$   e Zd Zejdœdd„Zdd„ ZdS )r   r   c                 C   sž   |j | _ |jp|j| _|j| _|j| _|j| _|j| _|j| _|j| _|j	| _	|jd k	rft
t d¡ƒ | jd k	r~t
t d¡ƒ | jr’t
t d¡ƒ tƒ | _d S )NzcThe --type argument is deprecated and will be removed in a future version. Use --repo-type instead.z‹The --organization argument is deprecated and will be removed in a future version. Pass the organization namespace directly in the repo_id.zfThe --yes argument is deprecated and will be removed in a future version. It does not have any effect.)r   Ú	repo_typer   Ú	space_sdkÚorganizationÚyesÚprivateÚtokenÚexist_okÚresource_group_idÚprintr   Úyellowr   Ú_api)Úselfr   r   r   r   Ú__init__d   s8    
ÿÿ
ÿÿÿÿzRepoCreateCommand.__init__c              	   C   s    t ddƒ | jd k	rHd| jkr4tt d¡ƒ tdƒ | j› d| j› �| _| jj| j| j	| j
| j| j| j| jd�}tdt |j¡› d�ƒ td	t |¡› �ƒ d S )
Nzhuggingface-cli repozhf repoú/zCYou cannot pass both --organization and a repo_id with a namespace.r	   )r   r'   r+   r,   r-   r.   r(   zSuccessfully created z on the Hub.zYour repo is now available at )r
   r)   r   r/   r   ÚredÚexitr1   Zcreate_repor'   r+   r,   r-   r.   r(   Úbold)r2   Úrepo_urlr   r   r   Úrun„   s"    


ù	zRepoCreateCommand.runN)r#   r$   r%   ÚargparseÚ	Namespacer3   r9   r   r   r   r   r   c   s    r   )Ú__doc__r:   r   Útypingr   Zhuggingface_hub.commandsr   Z#huggingface_hub.commands._cli_utilsr   Zhuggingface_hub.constantsr   Zhuggingface_hub.hf_apir   Zhuggingface_hub.utilsr   Z
_cli_utilsr
   Z
get_loggerr#   Úloggerr   r   r   r   r   r   Ú<module>   s   

;