o
    vZh;                     @   sp   d Z ddlmZ ddlmZmZ ddlmZ ddlm	Z	 ddl
mZ eeZG dd dZG d	d
 d
e	ZdS )a  Contains command to update or delete files in a repository using the CLI.

Usage:
    # delete all
    huggingface-cli repo-files <repo_id> delete "*"

    # delete single file
    huggingface-cli repo-files <repo_id> delete file.txt

    # delete single folder
    huggingface-cli repo-files <repo_id> delete folder/

    # delete multiple
    huggingface-cli repo-files <repo_id> delete file.txt folder/ file2.txt

    # delete multiple patterns
    huggingface-cli repo-files <repo_id> delete file.txt "*.json" "folder/*.parquet"

    # delete from different revision / repo-type
    huggingface-cli repo-files <repo_id> delete file.txt --revision=refs/pr/1 --repo-type=dataset
    )_SubParsersAction)ListOptional)logging)BaseHuggingfaceCLICommand)HfApic                   @   s    e Zd ZdddZdddZdS )DeleteFilesSubCommandreturnNc                 C   sZ   || _ |j| _|j| _|j| _t|jdd| _|j| _|j| _|j	| _	|j
| _
|j| _d S )Nzhuggingface-cli)tokenZlibrary_name)argsrepo_id	repo_typerevisionr   r
   apipatternscommit_messagecommit_description	create_pr)selfr    r   R/var/www/auris/lib/python3.10/site-packages/huggingface_hub/commands/repo_files.py__init__1   s   zDeleteFilesSubCommand.__init__c              	   C   sL   t   | jj| j| j| j| j| j| j	| j
d}td| d t   d S )N)Zdelete_patternsr   r   r   r   r   r   z+Files correctly deleted from repo. Commit: .)r   Zset_verbosity_infor   Zdelete_filesr   r   r   r   r   r   r   printZset_verbosity_warning)r   urlr   r   r   run=   s   	zDeleteFilesSubCommand.run)r	   N)__name__
__module____qualname__r   r   r   r   r   r   r   0   s    
r   c                   @   s   e Zd ZedefddZdS )RepoFilesCommandparserc                 C   s   | j ddd}|jdtdd |jddd	}|j d
dd}|jdd d |jddtdd |jdg dddd |jdtdd |jdtdd |jdtdd |jddd d! |jd"td#d |jtd d S )$Nz
repo-filesz!Manage files in a repo on the Hub)helpr   z9The ID of the repo to manage (e.g. `username/repo-name`).)typer!   z$Action to execute against the files.T)r!   requireddeletez#Delete files from a repo on the Hubc                 S   s   t | S )N)r   )r   r   r   r   <lambda>[   s    z6RepoFilesCommand.register_subcommand.<locals>.<lambda>)funcr   +z'Glob patterns to match files to delete.)nargsr"   r!   z--repo-type)modelZdatasetspacer)   z/Type of the repo to upload to (e.g. `dataset`).)choicesdefaultr!   z
--revisionzAn optional Git revision to push to. It can be a branch name or a PR reference. If revision does not exist and `--create-pr` is not set, a branch will be automatically created.z--commit-messagez9The summary / title / first line of the generated commit.z--commit-descriptionz(The description of the generated commit.z--create-pr
store_truez7Whether to create a new Pull Request for these changes.)actionr!   z--tokenzIA User Access Token generated from https://huggingface.co/settings/tokens)
add_parseradd_argumentstradd_subparsersset_defaultsr   )r    Zrepo_files_parserZrepo_files_subparsersZdelete_subparserr   r   r   register_subcommandM   sZ   	z$RepoFilesCommand.register_subcommandN)r   r   r   staticmethodr   r4   r   r   r   r   r   L   s    r   N)__doc__argparser   typingr   r   Zhuggingface_hubr   Zhuggingface_hub.commandsr   Zhuggingface_hub.hf_apir   Z
get_loggerr   loggerr   r   r   r   r   r   <module>   s   
