
    qi              &          d Z ddlZddlZddlZddlZddlmZ ddlmZmZm	Z	 ddl
Z
ddlmZ ddlmZmZmZmZmZmZmZ ddlmZmZmZmZ dd	lmZmZmZmZmZm Z m!Z!m"Z"  ejF                  e$      Z% e"d
      Z&de'de(e'e'f   fdZ)dde	e*e+f   de,de'fdZ-ddee   de,de'fdZ.	 	 dde/e	eef      de,de,de/e'   fdZ0	 	 	 dde1de/e'   de'de*de*de,ddfdZ2e&jg                  dg d       	 	 	 	 dd!ee' e
jh                  d"      f   d#ee, e
jj                  d$d%      f   d&ee, e
jj                  d'd(      f   ded)eddfd*       Z6de'de,fd+Z7e&jg                  d,g d-       ddddejp                  ddfdeee'    e
jh                  d.      f   dee, e
jj                  d/d0d1      f   d2ee, e
jj                  d3d4      f   d5ee, e
jj                  d6d7d8      f   d9eded)eddfd:       Z9d;ee'   de,d2e,d5e,d9ede,d)ee'   ddfd<Z:de'de,d2e,d5e,d9ede,d)ee'   ddfd=Z;e&jg                  d>d?d@g       	 	 dd!ee' e
jh                  dA      f   ded)eddfdB       Z<e&jg                  dCg dD       	 	 	 	 dd!ee' e
jh                  dA      f   dEee, e
jj                  dFdGdH      f   dIee, e
jj                  dJdK      f   ded)eddfdL       Z=e&jg                  dMg dN       	 	 	 	 	 	 	 ddee' e
jh                  dO      f   d5ee, e
jj                  d6d7dP      f   dEee, e
jj                  dFdGdH      f   dQee, e
jj                  dRdS      f   dTeee/e'       e
jj                  dU      f   dVeee/e'       e
jj                  dW      f   ded)eddfdX       Z>e&jg                  dYg dZ       	 dd[ee' e
jh                  d\      f   d]ee' e
jh                  d^      f   d)eddfd_       Z?e&jg                  d`g da       	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 ddbeee'    e
jh                  dc      f   ddeee'    e
jh                  de      f   dCee, e
jj                  df      f   dgee, e
jj                  dhdi      f   djee, e
jj                  dkdl      f   dmeee'    e
jj                  dn      f   doeee'    e
jj                  dp      f   dQee, e
jj                  dRdq      f   dTeee/e'       e
jj                  dr      f   dVeee/e'       e
jj                  ds      f   dteee'    e
jj                  du      f   dvee, e
jj                  dwdx      f   dyee, e
jj                  dzd{      f   d|ee, e
jj                  d}d~d      f   dee, e
jj                  ddd      f   d)eddf"d       Z@e&jg                  dg d       	 	 	 ddee' e
jh                  d      f   deee'    e
jh                  d      f   ded)eddf
d       ZAy)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                     | j                  t              rt        |       S 	 t        |       S # t        $ r t	        d|  dt         d      w xY w)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    M/opt/pipecat/venv/lib/python3.12/site-packages/huggingface_hub/cli/buckets.py_parse_bucket_argumentr$   8   sb     =)!(++
*844 
'z 2 /!68
 	

s	   
-  AFsizehuman_readablec                 z    |st        |       S dD ]$  }| dk  r|dk(  r	|  d| c S | dd| c S | dz  } & | ddS )zFormat a size in bytes.)BKBMBGBTBi  r(    z.1fz PB)str)r%   r&   units      r#   _format_sizer0   I   sj    4y- $;s{q''3Zq'' 3Zs    mtimec                 P    | y|r| j                  d      S | j                  d      S )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                 
   i }| D ]e  }|j                   j                  d      }|}|dd D ]  }||vrdi i||<   ||   d   } |d   }t        |t              r||vsWdi i||<   _d|i||<   g d}	d}
d}|s{| D ]i  }t        |t              st        |j                  |      }t        |
t        |            }
t        |j                  |      }t        |t        |            }k |
dkD  r|
dz   |z   }	g }t        ||d|	|
|	       |S )
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   `   sS   & D 5		$#2J 	4D7"!/ 4dmN3G	4
 2Y
dL)('5r&:
##-t"4GJ5  LNN 	DD$
+'		>B!$^S]!C(^D!$^S]!C	D A)A->L E
!%% Lr1   noderQ   indentr@   rA   c           	      .   t        | j                               }t        |      D ]  \  }\  }}	|t        |      dz
  k(  }
|
rdnd}d|	v }|	j	                  di       }|dkD  rz|rd|z  }nQ|	j	                  d      }|9t        |j                  |      }t        |j                  |      }|d	| d
d| }nd|z  }|j                  | d| | | |rdnd
        n|j                  | | | |rdnd
        |s||
rdndz   }t        ||||||        y)z:Recursively render a tree structure with size+date prefix.r   u
   └── u
   ├── r<   r   r-   r=   N>r4     r:   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      sL    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!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                    t        |      }| j                  t              r3	 t        |       \  }}|r t        j                  d|  dt         d      |} |j                  | |r|nd|      }	|rt        |	j                         yt        d|	j                   d|	j                   d	       y# t        $ r#}t        j                  t        |            d}~ww xY w)
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Iv $$?	{ K11>?UW  	""" # J
 j   0
:;L;L:MQOP#  	-$$SV,,	-s   B, ,	C5CCc                 d    | j                  t              r| t        t              d }d|v S | }d|v S )zFCheck if argument is a bucket ID (namespace/name) vs just a namespace.Nr:   )r!   r   rF   )r   rB   s     r#   _is_bucket_idr{     s?    =)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           	      t    | duxr t        |       }|rt        | ||||||       yt        | ||||||       y)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                 *   |rt        j                  d      |rt        j                  d      | 8| j                  t              r#| t	        t              d } | j                  d      } t        |      }|j                  |       D cg c]  }t        |       }	}|	s<|s:|t        j                  k7  r'| | n|j                         d   }
t        d|
 d	       yg d
}dt        dt        t           ffd}ddd}t!        |	|||||       yc c}w )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           	          ddl m}  || j                  d             || j                  d            t        | j                  dd             || j                  d             || j                  d	            gS )
Nr   )_format_cellr   rh   r%   r   r&   r   r   )
_cli_utilsr   rZ   r0   )rI   r   r&   s     r#   row_fnz_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c-023	$$S)	
5
!C8;8H8HS\8H8]^f!&)^G^<#4#44.7.CV\I]67I6J"MNDG	
T 	
d3i 	
 "':JgfE7SYfpq- _s   
Dc           	      X   |r(|t         j                  k(  rt        j                  d      t	        |      }	 t        |       \  }}	t        |j                  ||	xs d|            }|st        d       yt        d |D              }|t         j                  k(  r:|D cg c]  }t        |       }}t        t        j                  |d             n|r!t        |||	      }|D ]  }t        |        n|rF|D ]@  }t        |t               rt        |j"                   d
       ,t        |j"                         B n|D ]  }t        |t               r7t%        |j&                  |      }t        ddd|dd|j"                   d
       Jt)        |j*                  |      }t%        |j,                  |      }t        |dd|dd|j"                           |s|rt/               j1                  d       yyy# t        $ r#}
t        j                  t        |
            d}
~
ww xY wc c}w )zList files in a bucket.z%Cannot use --tree with --format json.rl   Nrc   r}   z(empty)c              3   <   K   | ]  }t        |t                y wN)rD   r
   ).0rI   s     r#   	<genexpr>z_list_files.<locals>.<genexpr>  s     KT*T<8Ks   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<	6
 >T 	 	
E iKUKKO"""8=>%d+>>djj+,	 ~US
 	D$K		 	!D$-1o&dii 		!  	GD$-)$*:*:NK	C9S/DII;a@A'		>B)$**nE	#b3r$))EF	G => )9W  )  Q(()& ?s   G8 H'8	H$HH$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                 <   t        |      }	 t        |       \  }}|j                  |      }|rt        |j                         yt        t        j                  t        |      d             y# t        $ r#}t        j                  t        |            d}~ww xY w)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	1 __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                 *   | j                  t              r4	 t        |       \  }}|r t	        j
                  d|  dt         d      |} n$d| vr t	        j
                  d|  dt         d      |s:t	        j                  d|  d	      }|st        d
       t	        j                         t        |      }	|	j                  | |       |rt        |        yt        d|         y# t        $ r#}t	        j
                  t        |            d}~ww xY w)zDelete 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Iv $$?	{ K11>?UW  		I	  !) -;;H/I_a
 	

 --"J9+UW XY*++-
5
!CiJ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                    	 t        |       \  }}	|	dk(  r|st        j                  d| d| d      |s|r|st        j                  d      t        |      }|r"t        |       }|j                  d	       g }|j                  ||	j                  d
      xs dd      D ]B  }t        |t              s|j                  |       |j                  dt        |       d       D |j                  dt        |       d       |s|r9t        ||      }|D cg c]   }|j!                  |j"                        s|" }}n|}|D cg c]  }|j"                   }}t%        d |D              }t'        |d      }|s|st)        d       yt        |       d| }|sV|sT|s|D ]  }t)        d|         t        j*                  d| d| d      }|st)        d       t        j,                         |r.|D ]  }t)        dt.         | d
|         t)        d| d       y|j1                  ||       |r|D ]  }t)        |        y|D ]  }t)        dt.         | d
|         t)        d| d| d       y|	j                  d
      }|st        j                  d      |r#t)        dt.         | d
|        t)        d        y|s=t        j*                  d!| d"| d      }|st)        d       t        j,                         |j1                  ||g       |rt)        |       yt)        dt.         | d
|        y# t        $ r#}
t        j                  t	        |
            d}
~
ww xY wc c}w c c}w )#zbRemove 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   4   K   | ]  }|j                     y wr   )r%   )r   fs     r#   r   zremove.<locals>.<genexpr>  s     7A7s   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<	6 |I   k "DDM;bR
 	
 	7I  !OPP
5
!CI.12&(	((==%- ) 
 	UD
 $
+  & ;C	N;K7ST	U 	1#i.1AIJg#WwWG(1M1W__QVV5LQMMM%M&34aff4
4777

4@+,Z));H:F7& 'DBtf+&'mmgk]')B$OPGj!kkm#" D	{!D6BCDJ{m+=>?y<" d # D	{!D6BCD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)   M  M4=M4
M9	M1M,,M1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                 $   t        |       \  }}|r t        j                  d|  dt         d      t        |      \  }}|r t        j                  d| dt         d      t	        |      }|j                  ||       t        d| d|        y)	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NK  7y A--:O;QS
 	
 5U;L)  7w ?--:O;QS
 	

 5
!COON,O?	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                 \    t        |      }|j                  | ||||||||	|
|||||       y)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           	      	   t        |      }t        |       }|duxr t        |      }| dk(  }|dk(  }|r|rt        j                  d      |s0|s.|s,|t        j                  d      t        j                  d      |r|st        j                  d      |r?|r=|J t	        |      \  }	}
|
dk(  s|
j                  d	      rt        j                  d
      |r|st        j                  d      |s6|s4t        j                  j                  |       rt        j                  d      |rt	        |       \  }}
|
dk(  s|
j                  d	      rt        j                  d      |
j                  d	d      d   }|rt               }|s
t                	 t        j                         5 }t        j                  j                  ||      }|j                  ||
|fg       t!        |d      5 }t"        j$                  j&                  j)                  |j+                                ddd       ddd       |st-                y||}nrt        j                  j                  |      s0|j                  t        j.                        s|j                  d	      r!t        j                  j                  ||      }n|}t        j                  j1                  |      }|rt        j2                  |d       |r
t                	 |j                  ||
|fg       |rt-                	 |st5        d|  d|        yyy|rxt	        |      \  }}t"        j6                  j&                  j+                         }|r
t                	 |j9                  |||fg       |rt-                	 |st5        d|        yyt        j                  j;                  |       st        j                  d|        t	        |      \  }}
|
dk(  r t        j                  j=                  |       }n6|
j                  d	      r#|
t        j                  j=                  |       z   }n|
}|r
t                	 |j9                  || |fg       |rt-                	 |st5        d|  dt>         | d	|        yy# 1 sw Y   {xY w# 1 sw Y   xY w# |st-                w w xY w# |rt-                w w xY w# |rt-                w w xY w# |rt-                w w xY w)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     su   , 5
!C#C(MtO<(<M#:L3JM   !GHH|;$$%YZZ  !^__M  !NOO&s+	6R<6??3/$$%hii]  !EFF"''--2D  !qrr .s3	6R<6??3/$$%qrr==a(, !; <$%'+002 :g!ww||GX>H--i68:L9MNh- :

))//9:: )(* {%
s#s||BFF';s||C?PWW\\#x8
 
 4JJ6%'+)))vz6J5KL(*SEj\:; 1 )6 
!3C!8	;yy$$&!#	'""9D+3F2G"H$&'u-. 
 ww~~c"$$'>se%DEE.s3	6R<''**3/K__S! 277#3#3C#88K K!#	'""9C3E2F"G$&Jse4yk;-PQ I: :: : )(* )* (*   $& 2 $& sa   R4 'AR')8R!R')R4 :S 7S S* R$	R''R1,R4 4SSS'*S9)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   