
    3j                        % S r SSKrSSKr\R                  " S\R                  5      rSSSSSS	.r\\\	4   \
S
'   SSSSSSSS.r\\\	4   \
S'   S\S\	4S jrS\S\	4S jrS\S\\\	4   S\	4S jrS\	S-  S\4S jrS\S\4S jrg)z&Parsing helpers shared across modules.    Nz(\d+)([a-z]+)i  i@B i ʚ;l    J)l     I5 )kmgtp
BYTE_UNITS   <     Q :	  ' 3)sr   hdwmoy
TIME_UNITSvaluereturnc                 "    [        U [        5      $ )zaParse a size expressed as a string with digits and unit (like `"10MB"`) to an integer (in bytes).)_parse_with_unitr   r   s    X/home/wildlama/miniconda3/lib/python3.13/site-packages/huggingface_hub/utils/_parsing.py
parse_sizer   )       E:..    c                 "    [        U [        5      $ )zfParse a duration expressed as a string with digits and unit (like `"10s"`) to an integer (in seconds).)r   r   r   s    r   parse_durationr!   .   r   r   unitsc           	         U R                  5       nU(       d  [        S5      e [        U 5      $ ! [         a     Of = f[        R	                  U5      nU(       d  [        SU  S35      e[        UR                  S5      5      nUR                  S5      R                  5       nXQ;  a)  [        SU S[        UR                  5       5       S35      eXAU   -  $ )	z)Parse a numeric value with optional unit.zValue cannot be empty.zInvalid value 'z7'. Must match pattern '\d+[a-z]+' or be a plain number.r	      zUnknown unit 'z'. Must be one of .)	strip
ValueErrorintRE_NUMBER_WITH_UNIT	fullmatchgrouplowerlistkeys)r   r"   strippedmatchnumberunits         r   r   r   3   s    {{}H1225z   ))(3E?5'1ijkkQ F;;q>!D>$/A$uzz|BTAUUVWXX$Ks   
/ 
<<secsc                     U c  g[        U 5      n U S:  a  U  S3$ U S:  a  U S-   SU S-   S3$ U S-   SU S-  S-   S3$ )zFormat a duration in seconds as a short human-readable string (e.g. `"1m 32s"`, `"2h 15m"`, `"45s"`).

Returns `"--"` when `secs` is `None` so it can be used directly as a CLI table cell.
z--r
   r   r   zm zh r   )r(   )r3   s    r   format_durationr5   J   sk    
 |t9Dbyqzd{"*Rr	{!,,dl^2td{r12!44r   tsc                     Sn[         R                   " 5       U -
  nUS:  a  gU H  u  p4n[        X$-  5      nUc  M  Xe::  d  M    O   W SW US:  a  S S3$ S S3$ )	zFormat timestamp in seconds into a human-readable string, relative to now.

Vaguely inspired by Django's `timesince` formatter.
))secondr	   r
   )minuter
   r
   )hourr      )dayr      )weekr   r=   )monthr      )yearr   N   za few seconds ago r	   r    z ago)timeround)r6   _TIMESINCE_CHUNKSdeltalabeldivider	max_valuer   s          r   format_timesincerL   Y   s|    
	 IIK"Erz"%6!	eo& U%7 &7 WAeWEAIS6d;;26d;;r   )__doc__rerE   compile
IGNORECASEr)   r   dictstrr(   __annotations__r   r   r!   r   r5   floatrL    r   r   <module>rV      s    - 	  jj!12==A  
				
DcN  
				
	
DcN /c /c /
/# /# /
 C  S#X  3  .5#* 5 5< <3 <r   