
    QЦi              '       0   S r SSKrSSKrSSKrSSKrSSKJr  SSKJrJrJ	r	  SSK
r
SSKJr  SSKJrJrJrJrJrJrJr  SSKJrJrJrJr  SS	KJrJrJrJrJrJ r J!r!J"r"  \RF                  " \$5      r%\"" S
S9r&S\'S\(\'\'4   4S jr)SS\	\*\+4   S\,S\'4S jjr-SS\\   S\,S\'4S jjr.  SS\/\	\\4      S\,S\,S\/\'   4S jjr0   SS\1S\/\'   S\'S\*S\*S\,SS4S jjr2\&Rg                  S/ SQS 9    SS!\\'\
Rh                  " S"S94   S#\\,\
Rj                  " S$S%S94   S&\\,\
Rj                  " S'S(S94   S\S)\SS4S* jj5       r6S\'S\,4S+ jr7\&Rg                  S,/ S-QS 9SSSS\Rp                  SS4S\\\'   \
Rh                  " S.S94   S\\,\
Rj                  " S/S0S1S94   S2\\,\
Rj                  " S3S4S94   S5\\,\
Rj                  " S6S7S8S94   S9\S\S)\SS4S: jj5       r9S;\\'   S\,S2\,S5\,S9\S\,S)\\'   SS4S< jr:S\'S\,S2\,S5\,S9\S\,S)\\'   SS4S= jr;\&Rg                  S>S?S@/S 9  SS!\\'\
Rh                  " SAS94   S\S)\SS4SB jj5       r<\&Rg                  SC/ SDQS 9    SS!\\'\
Rh                  " SAS94   SE\\,\
Rj                  " SFSGSHS94   SI\\,\
Rj                  " SJSKS94   S\S)\SS4SL jj5       r=\&Rg                  SM/ SNQS 9       SS\\'\
Rh                  " SOS94   S5\\,\
Rj                  " S6S7SPS94   SE\\,\
Rj                  " SFSGSHS94   SQ\\,\
Rj                  " SRSSS94   ST\\\/\'      \
Rj                  " SUS94   SV\\\/\'      \
Rj                  " SWS94   S\S)\SS4SX jj5       r>\&Rg                  SY/ SZQS 9 SS[\\'\
Rh                  " S\S94   S]\\'\
Rh                  " S^S94   S)\SS4S_ jj5       r?\&Rg                  S`/ SaQS 9                SSb\\\'   \
Rh                  " ScS94   Sd\\\'   \
Rh                  " SeS94   SC\\,\
Rj                  " SfS94   Sg\\,\
Rj                  " ShSiS94   Sj\\,\
Rj                  " SkSlS94   Sm\\\'   \
Rj                  " SnS94   So\\\'   \
Rj                  " SpS94   SQ\\,\
Rj                  " SRSqS94   ST\\\/\'      \
Rj                  " SrS94   SV\\\/\'      \
Rj                  " SsS94   St\\\'   \
Rj                  " SuS94   Sv\\,\
Rj                  " SwSxS94   Sy\\,\
Rj                  " SzS{S94   S|\\,\
Rj                  " S}S~SS94   S\\,\
Rj                  " SSSS94   S)\SS4"S jj5       r@\&Rg                  S/ SQS 9   SS\\'\
Rh                  " SS94   S\\\'   \
Rh                  " SS94   S\S)\SS4
S jj5       rAg)z7Contains commands to interact with buckets via the CLI.    N)datetime)	AnnotatedOptionalUnion)logging)BUCKET_PREFIX
BucketFileBucketFolderFilterMatcher_is_bucket_path_parse_bucket_path_split_bucket_id_and_prefix)
StatusLineare_progress_bars_disableddisable_progress_barsenable_progress_bars   )	FormatOptOutputFormatQuietOptTokenOptapi_object_to_dict
get_hf_apiprint_list_outputtyper_factoryz"Commands to interact with buckets.)helpargumentreturnc                     U R                  [        5      (       a  [        U 5      $  [        U 5      $ ! [         a    [	        SU  S[         S35      ef = f)zParse a bucket argument accepting both 'namespace/name(/prefix)' and 'hf://buckets/namespace/name(/prefix)'.

Returns:
    tuple: (bucket_id, prefix) where bucket_id is "namespace/bucket_name" and prefix may be empty string.
zInvalid bucket argument: -. Must be in format namespace/bucket_name or znamespace/bucket_name)
startswithr   r   r   
ValueError)r   s    Z/var/www/html/ai-image-ml/venv/lib/python3.13/site-packages/huggingface_hub/cli/buckets.py_parse_bucket_argumentr$   8   se     =))!(++
*844 
'z 2 /!68
 	

s	   
2 !AFsizehuman_readablec                     U(       d  [        U 5      $ S H'  nU S:  a  US:X  a	  U  SU 3s  $ U S SU 3s  $ U S-  n M)     U S S3$ )zFormat a size in bytes.)BKBMBGBTBi  r(    z.1fz PB)str)r%   r&   units      r#   _format_sizer0   I   se    4y-$;s{q''3Zq'' . 3Zs    mtimec                 \    U c  gU(       a  U R                  S5      $ U R                  S5      $ )z0Format mtime datetime to a readable date string. z%b %d %H:%Mz%Y-%m-%d %H:%M:%S)strftime)r2   r&   s     r#   _format_mtimer6   W   s,    }~~m,,>>-..r1   itemsquietc           	      2   0 nU  Hm  nUR                   R                  S5      nUnUSS  H  nXv;  a  S0 0Xg'   Xg   S   nM     US   n[        U[        5      (       a  X;  a  S0 0Xh'   Me  Mg  SU0Xh'   Mo     Sn	Sn
SnU(       d  U  Hp  n[        U[        5      (       d  M  [        UR                  U5      n[        U
[        U5      5      n
[        UR                  U5      n[        U[        U5      5      nMr     U
S:  a  U
S-   U-   n	/ n[        UUSU	U
US	9  U$ )
a  Build a tree representation of files and directories.

Produces ASCII tree with size and date columns before the tree connector.
When quiet=True, only the tree structure is shown (no size/date).

Args:
    items: List of BucketFile/BucketFolder items
    human_readable: Whether to show human-readable sizes and short dates
    quiet: If True, show only the tree structure without sizes/dates

Returns:
    List of formatted tree lines
/N__children____item__r      r4   prefix_widthmax_size_widthr&   )pathsplit
isinstancer
   r	   r0   r%   maxlenr6   r2   _render_tree)r7   r&   r8   treeitempartscurrentpart
final_partr@   rA   max_date_widthsize_strdate_strliness                  r#   _build_treerR   `   sC   & D		$#2JD"!/ 4mN3G 
 2Y
dL))('5r&:# ) $.t"4G   LNND$
++'		>B!$^S]!C(^D!$^S]!C  A)A->L E
!%% Lr1   noderQ   indentr@   rA   c           
      n   [        U R                  5       5      n[        U5       GH  u  nu  pU[        U5      S-
  :H  n
U
(       a  SOSnSU	;   nU	R	                  S0 5      nUS:  a  U(       a  SU-  nOQU	R	                  S5      nUb8  [        UR                  U5      n[        UR                  U5      nUS	U 3 S
U 3nOSU-  nUR                  U S
U U U U(       a  SOS 35        O"UR                  U U U U(       a  SOS 35        U(       d  M  X*(       a  SOS-   n[        UUUUUUS9  GM     g)z:Recursively render a tree structure with size+date prefix.r   u
   └── u
   ├── r<   r   r-   r=   N>  r:   r4   z    u   │   r?   )sortedr7   	enumeraterF   getr0   r%   r6   r2   appendrG   )rS   rQ   rT   r@   rA   r&   r7   inamevalueis_last	connectoris_dirchildrenprefixrI   rO   rP   child_indents                      r#   rG   rG      sE    4::< E%e,=Ds5zA~%$+L	5(99^R0!|+yy,#+DII~FH,TZZHH (>*:(:;2hZHF </FLLF82fXi[fsRT>UVWLLF8I;tfFS4KLM8!wVHEL)--1 -r1   create)zhf buckets create my-bucketz hf buckets create user/my-bucketz-hf buckets create hf://buckets/user/my-bucketz*hf buckets create user/my-bucket --privatez+hf buckets create user/my-bucket --exist-ok)r]   examples	bucket_idzTBucket ID: bucket_name, namespace/bucket_name, or hf://buckets/namespace/bucket_nameprivatez	--privatezCreate a private bucket.exist_okz
--exist-okz3Do not raise an error if the bucket already exists.tokenc                    [        US9nU R                  [        5      (       a8   [        U 5      u  pgU(       a!  [
        R                  " SU  S[         S35      eUn UR                  U U(       a  UOSUS9n	U(       a  [        U	R                  5        g[        SU	R                   SU	R                   S	35        g! [         a$  n[
        R                  " [        U5      5      eSnAff = f)
zCreate a new bucket.rj   Nz-Cannot specify a prefix for bucket creation: . Use namespace/bucket_name or namespace/bucket_name.)rh   ri   zBucket created: z
 (handle: ))r   r!   r   r$   r"   typerBadParameterr.   create_bucketprinthandleurl)
rg   rh   ri   r8   rj   api	parsed_idrc   e
bucket_urls
             r#   re   re      s    F 5
!CM**	- 6y AI $$?	{ K11>?UW  	""" # J
 j   0
:;L;L:MQOP#  	-$$SV,,	-s   B: :
C(C##C(c                 r    U R                  [        5      (       a  U [        [        5      S nSU;   $ U nSU;   $ )zFCheck if argument is a bucket ID (namespace/name) vs just a namespace.Nr:   )r!   r   rF   )r   rB   s     r#   _is_bucket_idr{     sB    =))M*,- $; $;r1   z	list | ls)	zhf buckets listzhf buckets list huggingfacezhf buckets list user/my-bucketz!hf buckets list user/my-bucket -Rz!hf buckets list user/my-bucket -hz%hf buckets list user/my-bucket --treez(hf buckets list user/my-bucket --tree -hz+hf buckets list hf://buckets/user/my-bucketz%hf buckets list user/my-bucket/sub -RzyNamespace (user or org) to list buckets, or bucket ID (namespace/bucket_name(/prefix) or hf://buckets/...) to list files.z--human-readablez-hz$Show sizes in human readable format.as_treez--treez3List files in tree format (only for listing files).	recursivez--recursivez-Rz0List files recursively (only for listing files).formatc           
      |    U SL=(       a    [        U 5      nU(       a  [        U UUUUUUS9  g[        U UUUUUUS9  g)zList buckets or files in a bucket.

When called with no argument or a namespace, lists buckets.
When called with a bucket ID (namespace/bucket_name), lists files in the bucket.
N)r   r&   r|   r}   r~   r8   rj   )	namespacer&   r|   r}   r~   r8   rj   )r{   _list_files_list_buckets)r   r&   r|   r}   r~   r8   rj   is_file_modes           r#   list_cmdr     sX    r 4'CM(,CL)	
 	)	
r1   r   c           	      X  ^ U(       a  [         R                  " S5      eU(       a  [         R                  " S5      eU b=  U R                  [        5      (       a#  U [	        [        5      S n U R                  S5      n [        US9nUR                  U S9 Vs/ s H  n[        U5      PM     n	nU	(       dC  U(       d<  U[        R                  :w  a(  U b  U OUR                  5       S   n
[        SU
 S	35        g/ S
QnS[        S[        [           4U4S jjnSSS.n[!        XX[XS9  gs  snf )zList buckets in a namespace.z'Cannot use --tree when listing buckets.z,Cannot use --recursive when listing buckets.Nr:   rl   )r   r]   z"No buckets found under namespace ''.)idrh   r%   total_files
created_atrI   r   c           	         > SSK Jn  U" U R                  S5      5      U" U R                  S5      5      [        U R                  SS5      TS9U" U R                  S5      5      U" U R                  S	5      5      /$ )
Nr   )_format_cellr   rh   r%   r   r&   r   r   )
_cli_utilsr   rZ   r0   )rI   r   r&   s     r#   row_fn_list_buckets.<locals>.row_fn  sj    , $(),-&!,^L-01,/0
 	
r1   right)r%   r   )r~   r8   headersr   
alignments)rp   rq   r!   r   rF   rstripr   list_bucketsr   r   jsonwhoamirs   dictlistr.   r   )r   r&   r|   r}   r~   r8   rj   rv   bucketresultsresolved_namespacer   r   r   s    `            r#   r   r   a  s      !JKK  !OPP !5!5m!D!Dc-023	$$S)	
5
!C8;8H8HS\8H8]^8]f!&)8]G^<#4#44.7.CV\I]67I6J"MNDG	
T 	
d3i 	
 "':JgESYq- _s   D'c           	         U(       a*  U[         R                  :X  a  [        R                  " S5      e[	        US9n [        U 5      u  p[        UR                  UU	=(       d    SUS95      nU(       d  [        S5        g[        S U 5       5      nU[         R                  :X  a;  U Vs/ s H  n[        U5      PM     nn[        [        R                  " USS95        GOU(       a  [        XUS	9nU H  n[        U5        M     OU(       aN  U HG  n[        U[         5      (       a  [        UR"                   S
35        M2  [        UR"                  5        MI     OU H  n[        U[         5      (       a8  [%        UR&                  U5      n[        SS SUS SUR"                   S
35        MP  [)        UR*                  U5      n[%        UR,                  U5      n[        US SUS SUR"                   35        M     U(       d"  U(       a  [/        5       R1                  S5        ggg! [         a$  n
[        R                  " [        U
5      5      eSn
A
ff = fs  snf )zList files in a bucket.z%Cannot use --tree with --format json.rl   Nrc   r}   z(empty)c              3   B   #    U  H  n[        U[        5      v   M     g 7fN)rD   r
   ).0rI   s     r#   	<genexpr>_list_files.<locals>.<genexpr>  s     KUT*T<88Us   r>   rT   )r&   r8   r:   r4   z>12rW   z>19z!Use -R to list files recursively.)r   r   rp   rq   r   r$   r"   r.   r   list_bucket_treers   anyr   dumpsrR   rD   r
   rB   r6   uploaded_atr0   r%   r2   r   done)r   r&   r|   r}   r~   r8   rj   rv   rg   rc   rx   r7   has_directoriesrI   r   
tree_linesline	mtime_strrO   s                      r#   r   r     s    6\...  !HII
5
!C)28<	
 >T 	 	
E iKUKKO"""8=>%d+>djj+,	 US
D$K 	D$--1o&dii 	  D$--)$*:*:NK	C9S/DII;a@A'		>B)$**nE	#b3r$))EF  => )9W  )  Q(()& ?s   H& )I&
I0IIinfozhf buckets info user/my-bucketz+hf buckets info hf://buckets/user/my-bucketzFBucket ID: namespace/bucket_name or hf://buckets/namespace/bucket_namec                 >   [        US9n [        U 5      u  pEUR                  U5      nU(       a  [        UR                  5        g[        [        R                  " [        U5      SS95        g! [         a$  n[        R                  " [        U5      5      eSnAff = f)zGet info about a bucket.rl   Nr>   r   )r   r$   r"   rp   rq   r.   bucket_infors   r   r   r   r   )rg   r8   rj   rv   rw   _rx   r   s           r#   r   r     s~    $ 5
!C)-i8	 __Y'Ffiidjj+F3A>?  )  Q(()s   A. .
B8BBdelete)z hf buckets delete user/my-bucketz-hf buckets delete hf://buckets/user/my-bucketz&hf buckets delete user/my-bucket --yesz-hf buckets delete user/my-bucket --missing-okyesz--yesz-yzSkip confirmation prompt.
missing_okz--missing-okz3Do not raise an error if the bucket does not exist.c                 \   U R                  [        5      (       a9   [        U 5      u  pVU(       a!  [        R
                  " SU  S[         S35      eUn O'SU ;  a!  [        R
                  " SU  S[         S35      eU(       dA  [        R                  " SU  S	35      nU(       d   [        S
5        [        R                  " 5       e[        US9n	U	R                  XS9  U(       a  [        U 5        g[        SU  35        g! [         a$  n[        R
                  " [        U5      5      eSnAff = f)zwDelete a bucket.

This deletes the entire bucket and all its contents. Use `hf buckets rm` to remove individual files.
Nz-Cannot specify a prefix for bucket deletion: rm   rn   r:   zInvalid bucket ID: r    z(Are you sure you want to delete bucket ''?Aborted.rl   )r   zBucket deleted: )r!   r   r$   r"   rp   rq   r.   confirmrs   Abortr   delete_bucket)
rg   r   r   r8   rj   rw   rc   rx   r   rv   s
             r#   r   r     s)   L M**	- 6y AI $$?	{ K11>?UW  		I	  !) -;;H/I_a
 	

 --"J9+UW XY*++-
5
!Ci7i ,-3  	-$$SV,,	-s   C= =
D+D&&D+zremove | rm)z)hf buckets remove user/my-bucket/file.txtz2hf buckets rm hf://buckets/user/my-bucket/file.txtz.hf buckets rm user/my-bucket/logs/ --recursivez:hf buckets rm user/my-bucket --recursive --include "*.tmp"z8hf buckets rm user/my-bucket/data/ --recursive --dry-runzBucket path: namespace/bucket_name/path or hf://buckets/namespace/bucket_name/path. With --recursive, namespace/bucket_name is also accepted to target all files.z0Remove files recursively under the given prefix.dry_runz	--dry-runz8Preview what would be deleted without actually deleting.includezQInclude only files matching pattern (can specify multiple). Requires --recursive.excludezLExclude files matching pattern (can specify multiple). Requires --recursive.c                     [        U 5      u  pU	S:X  a$  U(       d  [        R                  " SU SU S35      eU(       d  U(       a  U(       d  [        R                  " S5      e[        US9nU(       Gak  [        U(       + S9nUR                  S	5        / nUR                  UU	R                  S
5      =(       d    SSS9 HI  n[        U[        5      (       d  M  UR                  U5        UR                  S[        U5       S35        MK     UR                  S[        U5       S35        U(       d  U(       a>  [        XES9nU Vs/ s H'  nUR!                  UR"                  5      (       d  M%  UPM)     nnOUnU Vs/ s H  nUR"                  PM     nn[%        S U 5       5      n['        USS9nU(       d  U(       d  [)        S5        g[        U5       SU 3nU(       di  U(       db  U(       d  U H  n[)        SU 35        M     [        R*                  " SU SU S35      nU(       d   [)        S5        [        R,                  " 5       eU(       a0  U H  n[)        S[.         U S
U 35        M     [)        SU S35        gUR1                  UUS9  U(       a  U H  n[)        U5        M     gU H  n[)        S[.         U S
U 35        M     [)        SU SU S35        gU	R                  S
5      nU(       d  [        R                  " S5      eU(       a#  [)        S[.         U S
U 35        [)        S 5        gU(       dD  [        R*                  " S!U S"U S35      nU(       d   [)        S5        [        R,                  " 5       eUR1                  UU/S9  U(       a  [)        U5        g[)        S[.         U S
U 35        g! [         a$  n
[        R                  " [	        U
5      5      eSn
A
ff = fs  snf s  snf )#zZRemove files from a bucket.

To delete an entire bucket, use `hf buckets delete` instead.
Nr4   z?No file path specified. To remove files, provide a path (e.g. 'zd/FILE') or use --recursive to remove all files. To delete the entire bucket, use `hf buckets delete z`.z,--include and --exclude require --recursive.rl   )enabledzListing files from remoter:   Tr   zListing files from remote (z files))include_patternsexclude_patternsc              3   8   #    U  H  oR                   v   M     g 7fr   )r%   )r   fs     r#   r   remove.<locals>.<genexpr>  s     7As   r   zNo files to remove.z file(s) totaling rW   zRemove z from 'r   r   zdelete: z
(dry run) z would be removed.)r   zRemoved r   zFile path cannot be empty.z"(dry run) 1 file would be removed.zRemove 'z' from ')r$   r"   rp   rq   r.   r   r   updater   r   rD   r	   r[   rF   r   r   matchesrB   sumr0   rs   r   r   r   batch_bucket_files)r   r}   r   r   r   r   r8   rj   rg   rc   rx   rv   status	all_filesrI   matcherr   matched_files
file_paths
total_sizerO   count_labelrB   r   	file_paths                            r#   remover   7  s   |)28<	 |I   k "DDM;bR
 	
 	7I  !OPP
5
!CI.12&(	((==%- ) 
D
 $
++  & ;C	N;K7ST
 	1#i.1AIJg#WWG(1M	1W__QVV5LQ	MMM%M&34maffm
4777

4@+,Z));H:F7&DBtf+& 'mmgk]')B$OPGj!kkm#"	{!D6BC #J{m+=>?y<"d # #	{!D6BC #H[M2>? MM#&	$$%ABBH]OI;a	{CD67mmhyk)B$OPGj!kkm#y)=)H]OI;a	{CDw  )  Q(()@ N 5s)   N? $O0-O0<O5?
O-	O((O-move)z/hf buckets move user/old-bucket user/new-bucketz/hf buckets move user/my-bucket my-org/my-bucketzIhf buckets move hf://buckets/user/old-bucket hf://buckets/user/new-bucketfrom_idzMSource bucket ID: namespace/bucket_name or hf://buckets/namespace/bucket_nameto_idzRDestination bucket ID: namespace/bucket_name or hf://buckets/namespace/bucket_namec                 *   [        U 5      u  p4U(       a!  [        R                  " SU  S[         S35      e[        U5      u  pVU(       a!  [        R                  " SU S[         S35      e[	        US9nUR                  X5S9  [        SU SU 35        g)	z2Move (rename) a bucket to a new name or namespace.z)Cannot specify a prefix for bucket move: rm   rn   rl   )r   r   zBucket moved:  -> N)r$   rp   rq   r   r   move_bucketrs   )r   r   rj   parsed_from_idfrom_prefixparsed_to_id	to_prefixrv   s           r#   r   r     s    2 #9"AN  7y A--:O;QS
 	
 5U;L  7w ?--:O;QS
 	

 5
!COONO?	N>*$|n
=>r1   sync)z2hf buckets sync ./data hf://buckets/user/my-bucketz2hf buckets sync hf://buckets/user/my-bucket ./dataz;hf buckets sync ./data hf://buckets/user/my-bucket --deletez^hf buckets sync hf://buckets/user/my-bucket ./data --include "*.safetensors" --exclude "*.tmp"zIhf buckets sync ./data hf://buckets/user/my-bucket --plan sync-plan.jsonlz'hf buckets sync --apply sync-plan.jsonlz<hf buckets sync ./data hf://buckets/user/my-bucket --dry-runzChf buckets sync ./data hf://buckets/user/my-bucket --dry-run | jq .sourcezKSource path: local directory or hf://buckets/namespace/bucket_name(/prefix)destzPDestination path: local directory or hf://buckets/namespace/bucket_name(/prefix)z/Delete destination files not present in source.ignore_timesz--ignore-timesz;Skip files only based on size, ignoring modification times.ignore_sizesz--ignore-sizesz<Skip files only based on modification times, ignoring sizes.planz=Save sync plan to JSONL file for review instead of executing.applyz#Apply a previously saved plan file.z5Print sync plan to stdout as JSONL without executing.z6Include files matching pattern (can specify multiple).z6Exclude files matching pattern (can specify multiple).filter_fromz(Read include/exclude patterns from file.existingz
--existingzASkip creating new files on receiver (only update existing files).ignore_existingz--ignore-existingzCSkip updating files that exist on receiver (only create new files).verbosez	--verbosez-vz%Show detailed logging with reasoning.z--quietz-qzMinimal output.c                 P    [        US9nUR                  U UUUUUUUU	U
UUUUUS9  g)z0Sync files between local directory and a bucket.rl   )r   r   r   r   r   r   r   r   r   r   r   r   r   r   r8   N)r   sync_bucket)r   r   r   r   r   r   r   r   r   r   r   r   r   r   r8   rj   rv   s                    r#   r   r     sM    h 5
!COO!!'  r1   cp)z5hf buckets cp hf://buckets/user/my-bucket/config.jsonz=hf buckets cp hf://buckets/user/my-bucket/config.json ./data/zDhf buckets cp hf://buckets/user/my-bucket/config.json my-config.jsonz7hf buckets cp hf://buckets/user/my-bucket/config.json -z8hf buckets cp my-config.json hf://buckets/user/my-bucketz>hf buckets cp my-config.json hf://buckets/user/my-bucket/logs/zKhf buckets cp my-config.json hf://buckets/user/my-bucket/remote-config.jsonz7hf buckets cp - hf://buckets/user/my-bucket/config.jsonsrcz9Source: local file, hf://buckets/... path, or - for stdindstz?Destination: local path, hf://buckets/... path, or - for stdoutc           	         [        US9n[        U 5      nUSL=(       a    [        U5      nU S:H  nUS:H  nU(       a  U(       a  [        R                  " S5      eU(       d=  U(       d6  U(       d/  Uc  [        R                  " S5      e[        R                  " S5      eU(       a  U(       d  [        R                  " S5      eU(       aK  U(       aD  Uc   e[	        U5      u  pU
S:X  d  U
R                  S	5      (       a  [        R                  " S
5      eU(       a  U(       d  [        R                  " S5      eU(       dA  U(       d:  [        R                  R                  U 5      (       a  [        R                  " S5      eU(       Ga9  [	        U 5      u  pU
S:X  d  U
R                  S	5      (       a  [        R                  " S5      eU
R                  S	S5      S   nU(       a  [        5       nU(       d
  [        5          [        R                  " 5        n[        R                  R                  X5      nUR                  XU4/5        [!        US5       n["        R$                  R&                  R)                  UR+                  5       5        SSS5        SSS5        U(       d  [-        5         ggUc  UnO[        R                  R                  U5      (       d:  UR                  [        R.                  5      (       d  UR                  S	5      (       a   [        R                  R                  X5      nOUn[        R                  R1                  U5      nU(       a  [        R2                  " USS9  U(       a
  [        5          UR                  XU4/5        U(       a
  [-        5         U(       d  [5        SU  SU 35        ggU(       a  [	        U5      u  nn["        R6                  R&                  R+                  5       nU(       a
  [        5          UR9                  UUU4/S9  U(       a
  [-        5         U(       d  [5        SU 35        gg[        R                  R;                  U 5      (       d  [        R                  " SU  35      e[	        U5      u  pU
S:X  a   [        R                  R=                  U 5      nO;U
R                  S	5      (       a#  U
[        R                  R=                  U 5      -   nOU
nU(       a
  [        5          UR9                  XU4/S9  U(       a
  [-        5         U(       d  [5        SU  S[>         U S	U 35        gg! , (       d  f       GN= f! , (       d  f       GN= f! U(       d  [-        5         f f = f! U(       a  [-        5         f f = f! U(       a  [-        5         f f = f! U(       a  [-        5         f f = f)z'Copy a single file to or from a bucket.rl   N-z$Remote-to-remote copy not supported.z2Missing destination. Provide a bucket path as DST.z;One of SRC or DST must be a bucket path (hf://buckets/...).z+Stdin upload requires a bucket destination.r4   r:   zAStdin upload requires a full destination path including filename.z"Cannot pipe to stdout for uploads.zNSource must be a file, not a directory. Use `hf buckets sync` for directories.zJSource path must include a file name, not just a bucket or directory path.r   r;   rbT)ri   zDownloaded: r   )addzUploaded: stdin -> zSource file not found: z
Uploaded: ) r   r   rp   rq   r   endswithosrB   isdirrsplitr   r   tempfileTemporaryDirectoryjoindownload_bucket_filesopensysstdoutbufferwritereadr   sepdirnamemakedirsrs   stdinr   isfilebasenamer   )r   r   r8   rj   rv   src_is_bucketdst_is_bucketsrc_is_stdindst_is_stdoutr   rc   rg   filenamepbar_was_disabledtmp_dirtmp_pathr   
local_path
parent_dirremote_pathdatas                        r#   r   r     so   , 5
!C#C(MtO<(<M#:L3JM   !GHH|;$$%YZZ  !^__M  !NOO&s+	R<6??3//$$%hii]  !EFF"''--2D2D  !qrr .s3	R<6??3//$$%qrr==a(, !; <$%'+002g!ww||G>H--i8:L9MNh-

))//9 . 3 )(* ) {%
s##s||BFF';';s||C?P?PWW\\#8
 
 4JJ6%'+)))z6J5KL(*SEj\:;  
!3C!8	;yy$$&!#	'""9D+3F2G"H$&'u-. 
 ww~~c""$$'>se%DEE.s3	R<''**3/K__S!! 277#3#3C#88K K!#	'""93E2F"G$&Jse4yk;-PQ I .- 32 )(* )* (*   $& 2 $& sa   >U1 A U8UUU1 V V V6 
U	U
U.)U1 1VVV36W
)F)FF)r   r   F)FFFN)FN)FFFNNFNr   )NNFFFNNFNNNFFFFN)NFN)B__doc__r   r   r   r   r   typingr   r   r   rp   huggingface_hubr   huggingface_hub._bucketsr   r	   r
   r   r   r   r   huggingface_hub.utilsr   r   r   r   r   r   r   r   r   r   r   r   r   
get_logger__name__loggerbuckets_clir.   tupler$   intfloatboolr0   r6   r   rR   r   rG   commandArgumentOptionre   r{   tabler   r   r   r   r   r   r   r   r    r1   r#   <module>r!     s   >  	 
   - -  #   v u	 	 	 
		H	% !EF
S 
U38_ 
"uS%Z( $ 3 /(+ /T /c / !<j,./0<< < 
#Y	<F  )
)9) ) 	)
 ) ) 
)X 	  	. 	 	-/Qg	
	/Q +	
	/Q F	
	/Q* +/Q, -/Q. 
//Q	/QdC D  	
  . 	 	 	 	$**G@
W	
	@
 7	
	@
$ F	
	%@
2 C	
	3@
B C@
D E@
F G@
H 
I@
@
F-r}-r-r -r 	-r
 -r -r C=-r 
-r`>?>?>? >? 	>?
 >? >? C=>? 
>?B 	(5   @Y	
	@ @ @ 
@@2 	  . 	 	/9.Y	
	9. 
,	
	
9. F	
	9., -9.. /9.0 
19.9.x 	  	6 	 	 	 	 	]QEa	
	QE C	
	QE$ 
,	
	
%QE4 K	
	5QEB cd	
	CQEN c_	
	OQEZ [QE\ ]QE^ 
_QE	QEh 	  * "?`	
	"? e	
	"? "? 
"?"?T 		  & 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	Ix^	
	x c	
	x B	
	x& N	
	'x4 O	
	5xB P	
	CxN 6	
	OxZ H	
	[xh cI	
	ixt cI	
	ux@ ;	
	AxL T	
	MxZ V	
	[xh 8	
	ixx "	
	yxH IxJ 
Kxx@ 		  " 	R	3,ghh	iR	u~~+lmm
R
 R R 
RRr1   