
    -:j                        U d Z ddlZddlZ ej                  dej                        Zdddddd	Zeee	f   e
d
<   ddddddddZeee	f   e
d<   dede	fdZdede	fdZdedeee	f   de	fdZde	dz  defdZdedefdZy)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                 "    t        | t              S )zaParse a size expressed as a string with digits and unit (like `"10MB"`) to an integer (in bytes).)_parse_with_unitr   r   s    `/var/www/html/tokenscope/api/venv/lib/python3.12/site-packages/huggingface_hub/utils/_parsing.py
parse_sizer   )       E:..    c                 "    t        | t              S )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           	         | j                         }|st        d      	 t        |       S # t        $ r Y nw xY wt        j	                  |      }|st        d|  d      t        |j                  d            }|j                  d      j                         }||vr)t        d| dt        |j                                d      |||   z  S )	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5>$/A$uzz|BTAUUVWXXE$Ks   
* 	66secsc                 z    | yt        |       } | dk  r|  dS | dk  r| dz   d| dz   dS | dz   d| dz  dz   dS )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                     d}t        j                          | z
  }|dk  ry|D ]  \  }}}t        ||z        }|||k  s n  d |dkD  rd dS d dS )	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 !w	ego& Ui%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    - 	  !bjj!12==A  
				
DcN  
				
	
DcN /c /c /
/# /# /
 C  S#X  3  .5#* 5 5< <3 <r   