
    g;                         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j        e          Z G d d          Z G 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                       e Zd ZddZddZdS )DeleteFilesSubCommandreturnNc                 
   || _         |j        | _        |j        | _        |j        | _        t	          |j        d          | _        |j        | _        |j        | _        |j	        | _	        |j
        | _
        |j        | _        d S )Nzhuggingface-cli)tokenlibrary_name)argsrepo_id	repo_typerevisionr   r   apipatternscommit_messagecommit_description	create_pr)selfr   s     _/var/www/html/ai-engine/env/lib/python3.11/site-packages/huggingface_hub/commands/repo_files.py__init__zDeleteFilesSubCommand.__init__1   sp    	 L(,'+}dj?PQQQ#'=-1-@151H#~$(J


    c           	          t          j                     | j                            | j        | j        | j        | j        | j        | j	        | j
                  }t          d| d           t          j                     d S )N)delete_patternsr   r   r   r   r   r   z+Files correctly deleted from repo. Commit: .)r   set_verbosity_infor   delete_filesr   r   r   r   r   r   r   printset_verbosity_warning)r   urls     r   runzDeleteFilesSubCommand.run=   s    "$$$h## MLn].#6n $ 
 
 	BCBBBCCC%'''''r   )r   N)__name__
__module____qualname__r   r$    r   r   r
   r
   0   s<        
/ 
/ 
/ 
/( ( ( ( ( (r   r
   c                   *    e Zd Zedefd            ZdS )RepoFilesCommandparserc                    |                      dd          }|                    dt          d           |                    dd	          }|                     d
d          }|                    d            |                    ddt          d           |                    dg ddd           |                    dt          d           |                    dt          d           |                    dt          d           |                    ddd            |                    d!t          d"           |                    t
                     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                      t          |           S )N)r
   )r   s    r   <lambda>z6RepoFilesCommand.register_subcommand.<locals>.<lambda>[   s    8Md8S8S r   )funcr   +z'Glob patterns to match files to delete.)nargsr.   r-   z--repo-type)modeldatasetspacer6   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+   repo_files_parserrepo_files_subparsersdelete_subparsers       r   register_subcommandz$RepoFilesCommand.register_subcommandM   s   "--lAd-ee&&C&a 	' 	
 	
 	
 !2 @ @7 !A !
 !
 1;;6 < 
 
 	%%+S+S%TTT%%:	 	& 	
 	
 	
 	%%111B	 	& 	
 	
 	
 	%%_	 	& 	
 	
 	
 	%%S/j 	& 	
 	
 	
 	%%"3] 	& 	
 	
 	
 	%%,5n 	& 	
 	
 	
 	&&\ 	' 	
 	
 	
 	&&,<&=====r   N)r%   r&   r'   staticmethodr   rE   r(   r   r   r*   r*   L   s:        2>$5 2> 2> 2> \2> 2> 2>r   r*   N)__doc__argparser   typingr   r   huggingface_hubr   huggingface_hub.commandsr   huggingface_hub.hf_apir   
get_loggerr%   loggerr
   r*   r(   r   r   <module>rO      s    , ' & & & & & ! ! ! ! ! ! ! ! # # # # # # > > > > > > ( ( ( ( ( ( 
	H	%	%( ( ( ( ( ( ( (84> 4> 4> 4> 4>0 4> 4> 4> 4> 4>r   