
    \j                        U d Z ddlZddlZ ej                  dej                        Zddddd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kbmmbggbttbppb
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    Q/root/.hermes/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&   3   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   8   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-   )r8   s    r!   format_durationr:   O   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   rB   )monthr      )yearr   N   za few seconds ago r   r    z ago)timeround)r;   _TIMESINCE_CHUNKSdeltalabeldivider	max_valuer   s          r!   format_timesincerQ   ^   s    
	 IIK"Erz"%6 !w	ego& Ui%7 WAeWEAIS6d;;26d;;r$   )__doc__rerJ   compile
IGNORECASEr.   r   dictstrr-   __annotations__r   r"   r&   r   r:   floatrQ    r$   r!   <module>r[      s    - 	  !bjj!12==A  

	
	
	
	

DcN  
				
	
DcN /c /c /
/# /# /
 C  S#X  3  .5#* 5 5< <3 <r$   