+
    Pjm                        R t ^ RIt^ RIt^ RIHt ^ RIHtHt ^ RIH	t	 ^ RI
Ht ^ RIHtHt ^ RIt^ RIHt ^RIHtHtHtHtHtHtHtHt ^R	IHtHt ^R
IHtH t H!t!H"t"H#t#H$t$ ^RI%H&t&H't' ^RI(H)t) ]$! RR7      t*]	! RR7       ! R R4      4       t+]PX                  ! R4      t-0 RDmt.0 REmt/0 RFmt0]PX                  ! R4      t1RRRRRRRR/t2/ t3]4! ]04       F  t5]5]3]5&   ]5 R2]3]5 R2&   ]5 R2]3]5 R2&   K   	  ]! R]3]6]7R 7      t8]	! RR7       ! R! R"4      4       t9]:]]R,          3,          t;]<]]=]6,          3,          t>R# R$ lt?R% R& lt@R' R( ltAR) R* ltBR+ R, ltCR- R. ltDR/ R0 ltER1 R2 ltFR3 R4 ltGR5 R6 ltH]*P                  R7. RGOR87      RHR: R; ll4       tJ]*P                  . RIOR87      RJR< R= ll4       tK]*P                  R>R?.R87      RJR@ RA ll4       tL]*P                  . RKOR87      ] P                  RRRR9R9R3RB RC ll4       tNR# )LzHContains the 'hf cache' command group with cache management subcommands.N)defaultdict)CallableMapping)	dataclass)Enum)	AnnotatedAny)CLIError)ANSICachedRepoInfoCachedRevisionInfoCacheNotFoundHFCacheInfo_format_sizeparse_hf_uriscan_cache_dir)parse_duration
parse_size)	RepoIdArgRepoTypeOptRevisionOptTokenOpt
get_hf_apityper_factory)ArgumentOption)outzManage local cache directory.helpT)frozenc                   ,   a  ] tR t^2t o V 3R ltRtV tR# )_DeletionResolutionc                   < V ^8  d   Qh/ S[ S[,          ;R&   S[S[S[ S[,          3,          ;R&   S[S[R3,          ;R&   # )   	revisionsselected.missing)	frozensetstrdictr   r   tuple)format__classdict__s   "r/Users/ahmed/devFolder/Ultron/claude-voice/gateway/.venv/lib/python3.14/site-packages/huggingface_hub/cli/cache.py__annotate__ _DeletionResolution.__annotate__2   sF     ~  >9-?#@@AA  38_	      N)__name__
__module____qualname____firstlineno____annotate_func____static_attributes____classdictcell__r,   s   @r-   r!   r!   2   s      r0   r!   zA^(?P<key>[a-zA-Z_]+)\s*(?P<op>==|!=|>=|<=|>|<|=)\s*(?P<value>.+)$accessedmodifiedsizenamez.^(?P<key>[a-zA-Z_]+)(?::(?P<order>asc|desc))?$descascz:asc_ascz:desc_descSortOptions)typemodulec                   0   a  ] tR t^Qt o RtV 3R ltRtV tR# )CacheDeletionCountsz>Simple counters summarizing cache deletions for CLI messaging.c                >   < V ^8  d   Qh/ S[ ;R&   S[ ;R&   S[ ;R&   # )r#   
repo_countpartial_revision_counttotal_revision_count)int)r+   r,   s   "r-   r.    CacheDeletionCounts.__annotate__Q   s+      O	 
     r0   r1   N)r2   r3   r4   r5   __doc__r6   r7   r8   r9   s   @r-   rF   rF   Q   s     H  r0   rF   c                h    V ^8  d   QhR\         \        \        \        ,          3,          R\        /# )r#   selected_by_reporeturn)r   r   r'   r   rF   )r+   s   "r-   r.   r.   ^   s0     T Tni8J.KKLTTr0   c                   ^ p^ p^ pV P                  4        FW  w  rEV\        V4      ,          p\        V4      \        VP                  4      8X  g   K<  V^,          pV\        V4      ,          pKY  	  W#,
          p\        WV4      # )z(Summarize deletions across repositories.)itemslenr$   rF   )rO   rH   total_revisionsrevisions_in_full_reposrepor$   rI   s   &      r-   summarize_deletionsrW   ^   s|     JO+1133y>)y>S00!OJ#s9~5#	 4 -Fz?SSr0   c                <    V ^8  d   QhR\         R\         R\        /# )r#   revision_countincomplete_countrP   )rK   r(   )r+   s   "r-   r.   r.   p   s!      3 # # r0   c                    . pV '       d   VP                  V  R24       V'       d   VP                  V R24       RP                  V4      # )zMBuild the human-readable summary of what `hf cache prune` is about to delete.z unreferenced revision(s)z incomplete download(s) and )appendjoin)rY   rZ   partss   && r-   _prune_summaryr`   p   sG    E''@AB())@AB<<r0   c                `    V ^8  d   QhR\         \        \        \        ,          3,          RR/# )r#   rO   rP   N)r   r   r'   r   )r+   s   "r-   r.   r.   z   s/     [ [W^YWiMj=j5k [pt [r0   c           
     0   \        V P                  4       R R7       F  pVP                   RVP                   2p\        W,          R R7      p\	        V4      \	        VP
                  4      8X  d   \        P                  ! RV R24       Kq  \        P                  ! RV R24       V Fd  pRP                  \        VP                  4      4      ;'       g    R	p\        P                  ! R
VP                   RV RVP                   24       Kf  	  K  	  R# )zBPretty-print selected cache revisions during confirmation prompts.c                 N    V P                   V P                  P                  4       3# N	repo_typerepo_idlowerrV   s   &r-   <lambda>0print_cache_selected_revisions.<locals>.<lambda>|   s    $..RVR^R^RdRdRfAgr0   key/c                     V P                   # rd   commit_hashrevs   &r-   rj   rk   ~       3??r0     - z (entire repo): z
(detached)z      z [z] N)sortedkeysrf   rg   rS   r$   r   textr^   refsrq   size_on_disk_str)rO   rV   repo_keyr$   revisionr{   s   &     r-   print_cache_selected_revisionsr   z   s    ',,.4ghnn%Qt||n5+17RS	y>S00HHtH:^454z#$!H88F8==12BBlDHHvh2232dV2h>W>W=XYZ " ir0   c          
          V ^8  d   QhR\         R\        \        \        \        3,          \        \        \        \        \
        3,          3,          3,          /# )r#   hf_cache_inforP   )r   r*   r)   r(   r   r   )r+   s   "r-   r.   r.      sK     ( ((
n	eN$667	78:(r0   c                    / p/ pV P                    FQ  pVP                  P                  4       pW1V&   VP                   F   pW53W%P                  P                  4       &   K"  	  KS  	  W3# )zPCreate lookup tables so CLI commands can resolve repo ids and revisions quickly.)reposcache_idrh   r$   rq   )r   repo_lookuprevision_lookuprV   r}   r~   s   &     r-   build_cache_indexr      sk     .0KLNO##==&&( $HH=A<LO006689 ' $
 ''r0   c                0    V ^8  d   QhR\         R\         /# )r#   targetrP   )r(   )r+   s   "r-   r.   r.      s     
" 
"s 
"s 
"r0   c                   V P                  R4      '       g   V # \        V 4      pVP                  '       g   \        R4      hVP                  f   VP
                  '       d   \        R4      hVP                   RVP                   2# )zCReturn the cache id matching a repo target passed to `hf cache rm`.zhf://z:Only repository hf:// URIs are supported by `hf cache rm`.zBOnly repo-level hf:// URIs are supported by `hf cache rm` for now.rn   )
startswithr   is_repor	   r~   path_in_reporC   id)r   uris   & r-   _repo_cache_id_from_targetr      sq    W%%
v
C;;;STT
||3#3#3#3[\\hhZq!!r0   c                t    V ^8  d   QhR\         R\        R\        \        \        ,          \
        3,          /# )r#   r   include_revisionsrP   )r   boolr*   list
CacheEntryRepoRefsMap)r+   s   "r-   r.   r.      s3     " ""6:"
4
[()"r0   c          	        . p/ p\        V P                  R R7      pV F  p\        VP                   UUu0 uF  qfP                   F  qwkK  	  K  	  upp4      W5&   V'       d4   \        VP                  R R7       F  pVP                  WV34       K  	  Kx  VP                  VR34       K  	  V'       d   VP                  R R7       W#3# VP                  R R7       W#3# u uppi )z;Flatten cache metadata into rows consumed by `hf cache ls`.c                 N    V P                   V P                  P                  4       3# rd   re   ri   s   &r-   rj   'collect_cache_entries.<locals>.<lambda>   s    QUQ]Q]QcQcQe@fr0   rl   c                     V P                   # rd   rp   rr   s   &r-   rj   r      rt   r0   Nc                 j    V ^ ,          P                   V ^,          e   V ^,          P                  3# R3# )     )r   rq   entrys   &r-   rj   r      s2    a!!(-a(<a$$BDr0   c                 (    V ^ ,          P                   # )r   )r   r   s   &r-   rj   r      s    uQx'8'8r0   )rx   r   r'   r$   r{   r]   sort)r   r   entriesrepo_refs_mapsorted_reposrV   r~   refs   &$      r-   collect_cache_entriesr      s     !#G!#M---3fgL'T^^(e^WdWdPSWd^(ef"4>>7RS/0 T NND$<(   	 	
 !! 	89!! )fs   C"c          	          V ^8  d   QhR\         R\        R\        \        \        R,          \
        .\        3,          /# )r#   exprr   rP   N)r(   r   r   r   r   floatr   )r+   s   "r-   r.   r.      s;     > >
>)>~1D8%@$FG>r0   c           
       aaaaa	a
a \         P                  V P                  4       4      pV'       g   \        RV  R24      hVP	                  R4      P                  4       oVP	                  R4      oVP	                  R4      P                  4       oS\        9  d#   \        RS RV  R\        \        4       R	24      hS\        9  d#   \        R
S RV  R\        \        4       R	24      hSR8X  d   \        S4      o
VV
3R l# SR9   d'   \        SP                  4       4      o	R VVV	3R llpV# SR8X  d2   SP                  4       oSR8w  d   \        RS R24      hR V3R llpV# SR8w  d   \        RS R	24      hR VV3R llpV# )zqConvert a `hf cache ls` filter expression into the yes/no test we apply to each cache entry before displaying it.zInvalid filter expression: 'z'.rm   opvaluezUnsupported operator 'z' in filter ''. Must be one of .zUnsupported filter key '' in 'r<   c                 ^   < \        Ve   VP                  SS4      # V P                  SS4      # rd   )_compare_numericsize_on_disk)rV   r~   _r   size_thresholds   &&&r-   rj   &compile_cache_filter.<locals>.<lambda>   s3    )9%-%9H!!*
?C?P?P*
r0   c                V    V ^8  d   QhR\         R\        R,          R\        R\        /# )r#   rV   r~   NnowrP   r   r   r   r   )r+   s   "r-   r.   *compile_cache_filter.<locals>.__annotate__   s6     
	B 
	B~ 
	B9Kd9R 
	BY^ 
	Bcg 
	Br0   c                    < SR 8X  d   V P                   MVe   VP                  MV P                  pVf   R# \        W#,
          SS4      # )r:   F)last_accessedlast_modifiedr   )rV   r~   r   	timestamprm   r   secondss   &&& r-   _time_filter*compile_cache_filter.<locals>._time_filter   sU     *$ "" ' ++''   #CORAAr0   rC   =z/Only '=' is supported for 'type' filters. Got 'c                V    V ^8  d   QhR\         R\        R,          R\        R\        /# r#   rV   r~   Nr   rP   r   )r+   s   "r-   r.   r      s0     	6 	6~ 	69Kd9R 	6W\ 	6ae 	6r0   c                 >   < V P                   P                  4       S8H  # rd   )rf   rh   )rV   r~   r   expecteds   &&&r-   _type_filter*compile_cache_filter.<locals>._type_filter   s    >>'')X55r0   z.Only '=' is supported for 'refs' filters. Got c                V    V ^8  d   QhR\         R\        R,          R\        R\        /# r   r   )r+   s   "r-   r.   r      s6     	F 	F~ 	F9Kd9R 	FW\ 	Fae 	Fr0   c                    < Ve   VP                   MSP                  V \        4       4      pSP                  4       V Uu. uF  qDP                  4       NK  	  up9   # u upi rd   )r{   getr'   rh   )rV   r~   r   r{   r   r   	value_raws   &&&  r-   _refs_filter*compile_cache_filter.<locals>._refs_filter   sM    $,$88==m>O>OPTV_Va>bD??$(E(EEE(Es   A>   r:   r;   )_FILTER_PATTERNmatchstrip
ValueErrorgrouprh   _ALLOWED_OPERATORSr   _FILTER_KEYSr   r   )r   r   r   r   r   r   r   rm   r   r   r   r   s   &f    @@@@@@r-   compile_cache_filterr      s    !!$**,/E7vR@AA
++e

"
"
$C	T	BG$**,I	##1"]4&HZ[_`r[sZttuvww
,3C5tfDVW[\hWiVjjklmm
f}#I.
 	
 && !23
	B 
	B 
f}??$9NrdRTUVV	6 	6  9MbTQRSTT	F 	F r0   c                V    V ^8  d   QhR\         R,          R\        R\         R\        /# )r#   leftNr   rightrP   )r   r(   r   )r+   s   "r-   r.   r.     s,      54< S  4 r0   c                z    V f   R# RW8H  RW8g  RW8  RW8  RW8  RW8*  /pW9  d   \        RV 24      hW1,          # )	z)Evaluate numeric comparisons for filters.Fr   !=><>=<=z)Unsupported numeric comparison operator: )r   )r   r   r   comparisonss   &&& r-   r   r     s`    | 	T]dmT\T\dmdmK 
DRDIJJ?r0   c          	          V ^8  d   QhR\         R\        \        \        .\        \        R3,          3,          \
        3,          /# )r#   	sort_exprrP   .)r(   r*   r   r   r   r   )r+   s   "r-   r.   r.     s:     3 3# 3%*uSRUX9V0WY]0]*^ 3r0   c           
       a \         P                  V P                  4       P                  4       4      pV'       g   \	        RV  R24      hVP                  R4      P                  4       oVP                  R4      pS\        9  d#   \	        RS RV  R\        \        4       R24      hV'       d   TM\        S,          pVR	8H  pR
 V3R llpWT3# )zConvert a `hf cache ls` sort expression into a key function for sorting entries.

Returns:
    A tuple of (key_function, reverse_flag) where reverse_flag indicates whether
    to sort in descending order (True) or ascending order (False).
zInvalid sort expression: 'z5'. Expected format: 'key' or 'key:asc' or 'key:desc'.rm   orderzUnsupported sort key 'r   r   r   r>   c                J    V ^8  d   QhR\         R\        \        R3,          /# )r#   r   rP   .)r   r*   r   )r+   s   "r-   r.   (compile_cache_sort.<locals>.__annotate__+  s"     9 9 9c3h 9r0   c                   < V w  rSR 8X  d   VP                   P                  4       pV3# SR8X  d#   Ve   VP                  pV3# VP                  pV3# SR8X  d#   VP                  e   VP                  pV3# RpV3# SR8X  dC   Ve    VP                  e   VP                  MRpV3# VP                  e   VP                  MRpV3# \        RS 24      h)r=   r<   r:   g        r;   zUnsupported sort key: )r   rh   r   r   r   r   )r   rV   r~   r   rm   s   &   r-   	_sort_key%compile_cache_sort.<locals>._sort_key+  s    &=,,.E8O&=-5-AH))E8O HLGXGXE8O* +/*<*<*HD&&E8O ORE8O*#2:2H2H2T..Z] 8O /3.@.@.L**RU8O 1#788r0   )	_SORT_PATTERNr   r   rh   r   r   
_SORT_KEYSr   _SORT_DEFAULT_ORDER)r   r   explicit_orderr   reverser   rm   s   &     @r-   compile_cache_sortr     s     	 1 7 7 9:E5i[@uvww
++e

"
"
$C[[)N
*1#fYKGYZ^_iZjYkklmnn -N2Ec2JEvoG9 9< r0   c                R    V ^8  d   QhR\         R\        \        ,          R\        /# )r#   r   targetsrP   )r   r   r(   r!   )r+   s   "r-   r.   r.   L  s&     & &[ &49 &Qd &r0   c                d   \        V 4      w  r#\        \        4      p\        4       p. pV EF/  pVP                  4       pV'       g   K  VP	                  4       p	\
        P                  ! RV	4      '       da   VP                  V	4      p
V
f   VP                  V4       Ks  V
w  rWK,          P                  V4       VP                  VP                  4       K  VP                  \        V4      P	                  4       4      pVf   VP                  V4       K  VP                   F5  pWM,          P                  V4       VP                  VP                  4       K7  	  EK2  	  VP                  4        UUu/ uF  w  rV\        V4      bK  	  ppp\        \        V4      V\!        V4      R7      # u uppi )z8Resolve the deletion targets into a deletion resolution.z[0-9a-fA-F]{40})r$   r%   r&   )r   r   setr   rh   re	fullmatchr   r]   addrq   r   r$   rR   r'   r!   r*   )r   r   r   r   r%   r$   r&   
raw_targetr   loweredr   rV   r~   matched_reporevsfrozen_selecteds   &&              r-   _resolve_deletion_targetsr   L  sf   #4]#C K>I#>NH%IG
!!#,,.<<*G44#''0E}z*"NDNx(MM(../"'A&'I'O'O'QRNN:&$..H"&&x0MM(../ /+ 2 @H~~?OP?OtYt_,?OOPI& g  Qs   2F,z	list | ls)examplesFc                   V ^8  d   QhR\         \        R,          \        RR7      3,          R\         \        \        RR7      3,          R\         \        \        ,          R,          \        RR	R
R7      3,          R\         \
        R,          \        RR7      3,          R\         \        R,          \        RR7      3,          RR/# )r#   	cache_dirN9Cache directory to scan (defaults to Hugging Face cache).r   r$   zCInclude revisions in the output instead of aggregated repositories.filterz-fz--filterzZFilter entries (e.g. 'size>1GB', 'type=model', 'accessed>7d'). Can be used multiple times.r   a  Sort entries by key. Supported keys: 'accessed', 'modified', 'name', 'size'. Append ':asc' or ':desc' to explicitly set the order (e.g., 'modified:asc'). Defaults: 'accessed', 'modified', 'size' default to 'desc' (newest/biggest first); 'name' defaults to 'asc' (alphabetical).limitzSLimit the number of results returned. Returns only the top N entries after sorting.rP   )r   r(   r   r   r   rB   rK   )r+   s   "r-   r.   r.     s     D
 D
d
L	
	D
 V	
	D
 S	Dm	
	D
* d7	
	+D
< d
f	
	=D
H 
ID
r0   c                    \        V 4      pT;'       g    . p\	        YQR7      w  r T U
u. uF  p
\        Y4      NK  	  pp
\        P                  ! 4       pT F3  pT Uu. uF$  q! T^ ,          T^,          T4      '       g   K"  TNK&  	  ppK5  	  T'       d-    \        TP                  4      w  ppTP                  TTR7       Te'   T^ 8  d   \        P                  ! RT R24      hTRT pT'       d   T UUu. uF  w  ppTf   K  RTP                  RTP                  R	TP                   R
TP"                  R\        TP$                  4      RTP&                  RTP(                  R\+        TP,                  4      /NK  	  ppp\.        P0                  ! T. ROR
RR/R7       MT UUu. uF}  w  ppRTP                  RTP                  R	TP                   RTP&                  RTP2                  ;'       g    RRTP(                  R\+        T	P5                  T\7        4       4      4      /NK  	  ppp\.        P0                  ! T. RORRR/R7       T'       d   T UUu0 uF  w  ppTkK
  	  ppp\9        T4      pT'       d&   \;        R T 4       4      p\;        R T 4       4      pM$\;        R T 4       4      p\;        R T 4       4      p\.        P<                  ! \>        P@                  ! RT RT R\C        T4       R24      4       TPD                  pT'       d<   \.        PF                  ! R\9        T4       R\C        TPH                  4       R24       R# R#   \         d   p\        RTP                   24      ThRp?ii ; iu up
i   \         d&   p\        P                  ! \        T4      4      ThRp?ii ; iu upi   \         d&   p\        P                  ! \        T4      4      ThRp?ii ; iu uppi u uppi u uppi ) z&List cached repositories or revisions.Cache directory not found: N)r   )rm   r   z&Limit must be a positive integer, got r   r   rg   rf   r~   snapshot_pathr<   r   r{   r   )headersid_key
alignmentsr   r   c              3   6   "   T F  w  rVf   K  ^x  K  	  R # 5ird   r1   .0r   rs   s   &  r-   	<genexpr>ls.<locals>.<genexpr>  s      LvqCs   
c              3   J   "   T F  w  rVf   K  VP                   x  K  	  R # 5ird   r   r	  s   &  r-   r  r    s     WG&!s-S--Gs   ##c              3   L   "   T F  p\        VP                  4      x  K  	  R # 5ird   )rS   r$   r
  rV   s   & r-   r  r    s      NT^^!4!4s   "$c              3   8   "   T F  qP                   x  K  	  R # 5ird   r  r  s   & r-   r  r    s     H<4..<   z
Found z repo(s) for a total of z revision(s) and z	 on disk.zFound z" incomplete download(s) totalling z$. Remove them with 'hf cache prune'.)r   r~   r<   r   r{   )r   r<   r   r   r{   )%r   r   r	   r   r   r   r   clickBadParameterr(   timer   r   r   r   rg   rf   rq   r  r|   last_modified_strrx   r{   r   tablelast_accessed_strr   r'   rS   sumrz   r
   boldr   incomplete_fileshintincomplete_size_on_disk)r   r$   r   r   r  r   excfiltersr   r   r   
filter_fnsr   fnr   sort_key_fnr   rV   r~   rR   r   unique_reposrH   rY   
total_sizer  s   &&&&&                     r-   lsr%  x  s   ^O&y1 llG2=^G4LSTGD*4?G
T ))+C&-MgUE!HeAh1L55gM  	8#5djj#A KLL['L:
 19$$'MeWTU%VWW&5/ #*
 #*h	dmm4<<T^^H00X%;%;!<11!;!;x}}-	 #* 	 
 			G(		
" #
 #a dmm4<<T^^--!7!7!=!=2!7!7}00y{CD # 	 
 			L(		
 ,34GqG4&
  L LLNWGWWJ  N NNNH<HHJII:,&>~>N O$Z01<	
 %55S)*++MMAABC D11	
 o  O4S]]ODE3NO U 4  S*34
 N  	8$$SX.C7	8
*
( 5s   M N N  N  N8N8+N= ;	O0	A8O0(AO647O6O<M=M88M= N N5 N00N5=O- O((O-c                ,   V ^8  d   QhR\         \        \        ,          \        RR7      3,          R\         \        R,          \	        RR7      3,          R\         \
        \	        RR	R
R7      3,          R\         \
        \	        RR7      3,          RR/# )r#   r   ziOne or more repo IDs (e.g. model/bert-base-uncased), repo-level hf:// URIs, or revision hashes to delete.r   r   Nr   yes-y--yesSkip confirmation prompt.dry_run,Preview deletions without removing anything.rP   )r   r   r(   r   r   r   )r+   s   "r-   r.   r.     s     O OS	|	
	O d
L	
	O 
,	
	
O* ?	
	+O6 
7Or0   c           	         \        V4      p\	        Y@4      pTP
                  '       d<   RP                  R TP
                   4       4      p\        P                  ! RT 24       \        TP                  4      ^ 8X  d7   \        P                  ! R4       \        P                  P                  ^ R7      hTP                  ! \!        TP                  4      !  p\#        TP$                  4      p	. p
T	P&                  '       d   T
P)                  T	P&                   R24       T	P*                  '       d   T
P)                  T	P*                   R	24       T
'       g   T
P)                  T	P,                   R	24       R
P                  T
4      p\        P                  ! RT RTP.                   R24       \1        TP$                  4       T'       d<   \        P2                  ! RRT	P&                  T	P,                  TP.                  R7       R# \        P4                  ! RTR7       TP7                  4        \#        TP$                  4      p	\        P2                  ! RT	P&                   RT	P,                   RTP.                   R2T	P&                  T	P,                  TP.                  R7       R#   \         d   p\        RTP                   24      ThRp?ii ; i)z(Remove cached repositories or revisions.r  N
c              3   ,   "   T F
  pR V 2x  K  	  R# 5iru   Nr1   )r
  r   s   & r-   r  rm.<locals>.<genexpr>6  s     K8Jud5'N8J   zCould not find in cache:
zNothing to delete.codez repo(s)z revision(s)r\   About to delete z totalling r   Dry run: no files were deleted.T)r+  r   r$   r<   zProceed with deletion?r'  Deleted z repo(s) and z revision(s); freed )repos_deletedrevisions_deletedfreed)r   r   r	   r   r   r&   r^   r   warningrS   r$   rz   r  
exceptionsExitdelete_revisionsrx   rW   r%   rH   r]   rI   rJ   expected_freed_size_strr   resultconfirmexecute)r   r   r'  r+  r   r  
resolutiondetailsstrategycountssummary_partssummary_texts   &&&&        r-   rmrJ    s[   LO&y1 +=BJ))K
8J8JKK0	:;
: A%%&###++--vj6J6J/KLH !4!45F!M 1 12(;<$$$ = =>lKL ; ;<LIJ<<.LHH~[9Y9Y8ZZ[\]":#6#67

-##1111	
 	KK(c2 !4!45FJJ
6$$%]63N3N2O P2231	6'' 55..U  O4S]]ODE3NOs   J$ $K/KKzhf cache prunezhf cache prune --dry-runc                    V ^8  d   QhR\         \        R,          \        RR7      3,          R\         \        \        RRRR7      3,          R	\         \        \        R
R7      3,          RR/# )r#   r   Nr   r   r'  r(  r)  r*  r+  r,  rP   )r   r(   r   r   )r+   s   "r-   r.   r.   d  s     L Ld
L	
	L 
,	
	
L ?	
	L* 
+Lr0   c           	         \        V 4      p/ p\	        4       pTP
                   FE  p\        R TP                   4       4      pT'       g   K)  YT&   TP                  R T 4       4       KG  	  TP                  p	\        T4      ^ 8X  d!   T	'       g   \        P                  ! R4       R# TP                  ! \        T4      !  p
\        T4      pT
P                   TP"                  ,           p\%        TP&                  \        T	4      4      p\        P                  ! RT R\)        T4       R24       \+        T4       T'       d:   \        P,                  ! R	R
TP&                  \        T	4      \)        T4      R7       R# \        P.                  ! RTR7       T
P1                  4        T	 F  p TP2                  P5                  4        K   	  \        P,                  ! RT R\)        T4       R2TP&                  \        T	4      \)        T4      R7       R#   \         d   p\        RTP                   24      ThRp?ii ; i  \6         d     K  \8         d2   p\        P:                  ! RTP2                   RT 24        Rp?K  Rp?ii ; i)zBRemove detached revisions and incomplete downloads from the cache.r  Nc              3   ^   "   T F#  p\        VP                  4      ^ 8X  g   K  Vx  K%  	  R# 5i)r   N)rS   r{   r
  r~   s   & r-   r  prune.<locals>.<genexpr>  s#     `n(HMMHZ^_H_XXns   -
-c              3   8   "   T F  qP                   x  K  	  R # 5ird   rp   rN  s   & r-   r  rO    s     Gh(--hr  zJNo unreferenced revisions or incomplete downloads found. Nothing to prune.r5   (z total).r6  T)r+  r$   
incompleter<   zProceed?r7  z!Could not delete incomplete file z: r8  z; freed r   )r:  incomplete_deletedr;  )r   r   r	   r   r   r   r'   r$   updater  rS   r   rz   r?  rx   rW   expected_freed_sizer  r`   rJ   r   r   rA  rB  rC  	file_pathunlinkFileNotFoundErrorOSErrorr<  )r   r'  r+  r   r  r%   r$   rV   detachedr  rF  rG  total_freedsummaryincomplete_files   &&&            r-   pruner^  c  s/   0O&y1 EGH%I##`dnn``!GhGG $ %55
9~#3]^--vi/@AH *F..1V1VVKV88#>N:OPGHHy<+D*EXNO"8,

-11+,k*	
 	KK
$+	`%%,,. , JJ
7)8L$=#>a@ 55/0;'	]  O4S]]ODE3NOT ! 	 	`KK;O<U<U;VVXY\X]^__	`s;   H *H<H9H44H9<J
JJ&J  Jc                T   V ^8  d   QhR\         R\        R\        R\        \        R,          \        RR7      3,          R\        \        R,          \        R	R7      3,          R
\        \        \        RRR7      3,          R\        \        \        RRR7      3,          R\        RR/	# )r#   rg   rf   r~   r   NzXCache directory to use when verifying files from cache (defaults to Hugging Face cache).r   	local_dirz?If set, verify files under this directory instead of the cache.fail_on_missing_filesz--fail-on-missing-filesz?Fail if some files exist on the remote but are missing locally.fail_on_extra_filesz--fail-on-extra-fileszLFail if some files exist locally but are not present on the remote revision.tokenrP   )r   r   r   r   r(   r   r   r   )r+   s   "r-   r.   r.     s     f fff f d
k	
		f d
R	
	f  %%R	
	!f. ##_	
	/f< =f> 
?fr0   c           
     F   Ve;   Ve7   \         P                  ! R4       \        P                  P	                  ^R7      h\        VR7      pTP                  T \        VR4      '       d   VP                  M
\        V4      VVVVR7      p	^ p
V	P                  '       d>   RP                  R V	P                   4       4      p\         P                  ! R	V 24       ^p
V	P                  '       ds   V'       d?   RP                  R
 V	P                   4       4      p\         P                  ! RV 24       ^p
M,\         P                  ! \        V	P                  4       R24       V	P                   '       ds   V'       d?   RP                  R V	P                    4       4      p\         P                  ! RV 24       ^p
M,\         P                  ! \        V	P                   4       R24       V	P"                  pV
^ 8w  dW   \         P                  ! RV  RVP                   RV RV	P$                   24       \        P                  P	                  V
R7      h\         P&                  ! RV	P(                   RVP                   RV  R2V VP                  V	P(                  \        V4      R7       R# )a  Verify checksums for a single repo revision from cache or a local directory.

Examples:
  - Verify main revision in cache: `hf cache verify gpt2`
  - Verify specific revision: `hf cache verify gpt2 --revision refs/pr/1`
  - Verify dataset: `hf cache verify karpathy/fineweb-edu-100b-shuffle --repo-type dataset`
  - Verify local dir: `hf cache verify deepseek-ai/DeepSeek-OCR --local-dir /path/to/repo`
NzCCannot pass both --local-dir and --cache-dir. Use one or the other.r3  )rc  r   )rg   rf   r~   r`  r   rc  r.  c           
   3   v   "   T F/  pR VR,           RVR,           RVR,           RVR,           2x  K1  	  R# 5i)	ru   pathz: expected r   rQ  	algorithmz), got actualNr1   )r
  ms   & r-   r  verify.<locals>.<genexpr>  sE      
& 1V9+[:r!K.9IQRS[Q\P]^&s   79u<   ❌ Checksum verification failed for the following file(s):
c              3   ,   "   T F
  pR V 2x  K  	  R# 5ir0  r1   r
  ps   & r-   r  rj    s     I4Hq$qc
4Hr2  u6   ❌ Missing files (present remotely, absent locally):
zM remote file(s) are missing locally. Use --fail-on-missing-files for details.c              3   ,   "   T F
  pR V 2x  K  	  R# 5ir0  r1   rl  s   & r-   r  rj  	  s     G4Fq$qc
4Fr2  u4   ❌ Extra files (present locally, absent remotely):
zV local file(s) do not exist on the remote repo. Use --fail-on-extra-files for details.zVerification failed for 'z' (z) in z.
  Revision: z	Verified z file(s) for z 'z'. All checksums match.)rg   rf   checkedrf  )r   errorr  r=  r>  r   verify_repo_checksumshasattrr   r(   
mismatchesr^   rz   missing_pathsr<  rS   extra_pathsverified_pathr~   rA  checked_count)rg   rf   r~   r   r`  ra  rb  rc  apirA  	exit_coderE  verified_locations   &&&&&&&&     r-   verifyr{    sY   ` !6		WX###++
5
!C&&%,Y%@%@)//c)n ' F I)) 
&&
 
 	PQXPYZ[	 iiIF4H4HIIGHHNwiXYIKKv++,- .; ;
 iiGF4F4FGGGHHLWIVWIKKv))*+ ,9 9
 ,,A~		'yIOO3DEJ[I\\klrl{l{k|}	
 ###33JJ
F(()y6Gr'Rij//$$"#r0   >   r   r   r   r   r   r   >   r{   r<   rC   r:   r;   >   r=   r<   r:   r;   )zhf cache lszhf cache ls --revisionsz*hf cache ls --filter "size>1GB" --limit 20zhf cache ls --format json)NFNNN)zhf cache rm model/gpt2z-hf cache rm hf://models/openai-community/gpt2zhf cache rm <revision_hash>z hf cache rm model/gpt2 --dry-runzhf cache rm model/gpt2 --yes)NFF)zhf cache verify gpt2z)hf cache verify gpt2 --revision refs/pr/1z.hf cache verify my-dataset --repo-type dataset)OrM   r   r  collectionsr   collections.abcr   r   dataclassesr   enumr   typingr   r   r  huggingface_hub.errorsr	   utilsr
   r   r   r   r   r   r   r   utils._parsingr   r   
_cli_utilsr   r   r   r   r   r   
_frameworkr   r   _outputr   	cache_clir!   compiler   r   r   r   r   r   _sort_options_dictrx   rm   r(   r2   rB   rF   r*   r   r)   r'   r   rW   r`   r   r   r   r   r   r   r   r   commandr%  rJ  r^  modelr{  r1   r0   r-   <module>r     sy   O 	  # - !  !  +	 	 	 8 ` ` (  >?	 $   **ab6 ?5


LM 
F
E   *C!s*-d|#d|$+.%u#e}% 
 ="43xP $   >#5#<<=
>9S>12T$[("
""4>B(3l&X   D
D
N   OOd -/IJKL LL^    )..  	 	 	 	=ffr0   