
    RX9i                         S r SSKrSSKJrJr  SSKJrJr  SSKJ	r	  SSK
Jr  SSKJr  SSKJr  SS	KJrJr  \	R&                  " \5      r " S
 S\5      rg)a_  Contains command to download files from the Hub with the CLI.

Usage:
    hf download --help

    # Download file
    hf download gpt2 config.json

    # Download entire repo
    hf download fffiloni/zeroscope --repo-type=space --revision=refs/pr/78

    # Download repo with filters
    hf download gpt2 --include="*.safetensors"

    # Download with token
    hf download Wauplin/private-model --token=hf_***

    # Download quietly (no progress bar, no warnings, only the returned path)
    hf download gpt2 config.json --quiet

    # Download to local dir
    hf download gpt2 --local-dir=./models/gpt2
    N)	Namespace_SubParsersAction)ListOptional)logging)snapshot_download)BaseHuggingfaceCLICommand)hf_hub_download)disable_progress_barsenable_progress_barsc                   V    \ rS rSr\S\4S j5       rS\SS4S jrSS jr	S\
4S	 jrS
rg)DownloadCommand5   parserc                 8   U R                  SSS9nUR                  S[        SS9  UR                  S[        SS	S
9  UR                  S/ SQSSS9  UR                  S[        SS9  UR                  SS[        SS9  UR                  SS[        SS9  UR                  S[        SS9  UR                  S[        SS9  UR                  SSSS9  UR                  S[        S S9  UR                  S!SS"S9  UR                  S#[        S$S%S&9  UR	                  [
        S'9  g )(NdownloadzDownload files from the Hub)helprepo_idz<ID of the repo to download from (e.g. `username/repo-name`).)typer   	filenames*z>Files to download (e.g. `config.json`, `data/metadata.jsonl`).)r   nargsr   z--repo-type)modeldatasetspacer   z4Type of repo to download from (defaults to 'model').)choicesdefaultr   z
--revisionzPAn optional Git revision id which can be a branch name, a tag, or a commit hash.z	--includez)Glob patterns to match files to download.)r   r   r   z	--excludez0Glob patterns to exclude from files to download.z--cache-dirz9Path to the directory where to save the downloaded files.z--local-dirzIf set, the downloaded file will be placed under this directory. Check out https://huggingface.co/docs/huggingface_hub/guides/download#download-files-to-local-folder for more details.z--force-download
store_truezFIf True, the files will be downloaded even if they are already cached.)actionr   z--tokenzIA User Access Token generated from https://huggingface.co/settings/tokensz--quietzWIf True, progress bars are disabled and only the path to the download files is printed.z--max-workers   zEMaximum number of workers to use for downloading files. Default is 8.)r   r   r   )func)
add_parseradd_argumentstrintset_defaultsr   )r   download_parsers     \/var/www/html/land-doc-ocr/venv/lib/python3.13/site-packages/huggingface_hub/cli/download.pyregister_subcommand#DownloadCommand.register_subcommand6   s    ++J=Z+[$$C&d 	% 	
 	$$c3s 	% 	
 	$$1G	 	% 	
 	$$c 	% 	

 	$$s3^ 	% 	
 	$$s3e 	% 	
 	$$*e 	% 	
 	$$	 	% 	
 	$$Y 	% 	

 	$$C&q 	% 	
 	$$j 	% 	

 	$$X	 	% 	
 	$$/$:    argsreturnNc                    UR                   U l         UR                  U l        UR                  U l        UR                  U l        UR                  U l        UR
                  U l        UR                  U l        UR                  U l        UR                  U l        UR                  U l	        UR                  U l
        UR                  U l        g )N)tokenr   r   	repo_typerevisionincludeexclude	cache_dir	local_dirforce_downloadquietmax_workers)selfr,   s     r(   __init__DownloadCommand.__init__q   s    ZZ
 LL$(NN"nn'+}},0LL,0LL(,(,$($7$7::
 $ 0 0r+   c                    U R                   (       ab  [        5         [        R                  " 5          [        R                  " S5        [        U R                  5       5        S S S 5        [        5         g [        R                  " 5         [        U R                  5       5        [        R                  " 5         g ! , (       d  f       N]= f)Nignore)r7   r   warningscatch_warningssimplefilterprint	_downloadr   r   set_verbosity_infoset_verbosity_warning)r9   s    r(   runDownloadCommand.run   su    ::!#((*%%h/dnn&' + !"&&($.."#))+ +*s   0B88
Cc                 d   [        U R                  5      S:  ax  U R                  b/  [        U R                  5      S:  a  [        R                  " S5        U R
                  b/  [        U R
                  5      S:  a  [        R                  " S5        [        U R                  5      S:X  ad  [        U R                  U R                  U R                  U R                  S   U R                  U R                  U R                  U R                  SS9	$ [        U R                  5      S:X  a  U R                  nU R
                  nOU R                  nS n[        U R                  U R                  U R                  UUU R                  U R                  U R                  U R                  SU R                  S9$ )Nr   z?Ignoring `--include` since filenames have being explicitly set.z?Ignoring `--exclude` since filenames have being explicitly set.   zhuggingface-cli)	r   r0   r1   filenamer4   r6   r/   r5   library_name)r   r0   r1   allow_patternsignore_patternsr6   r4   r/   r5   rJ   r8   )lenr   r2   r>   warnr3   r
   r   r0   r1   r4   r6   r/   r5   r   r8   )r9   rK   rL   s      r(   rB   DownloadCommand._download   sH   t~~"||'C,=,A_`||'C,=,A_` t~~!#"..*..#22jj...
 
  A%!\\N"llO!^^N"O LLnn]])+..nn**nn*((
 	
r+   )r4   r3   r   r6   r2   r5   r8   r7   r   r0   r1   r/   )r-   N)__name__
__module____qualname____firstlineno__staticmethodr   r)   r   r:   rE   r$   rB   __static_attributes__ r+   r(   r   r   5   sA    8;$5 8; 8;t1Y 14 1
,*
3 *
r+   r   )__doc__r>   argparser   r   typingr   r   huggingface_hubr   "huggingface_hub._snapshot_downloadr   huggingface_hub.commandsr	   huggingface_hub.file_downloadr
   huggingface_hub.utilsr   r   
get_loggerrP   loggerr   rV   r+   r(   <module>ra      sE   0  1 ! # @ > 9 M 
		H	%@
/ @
r+   