
    Zi                         U d Z ddlZddlZddlm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e	fdZdS )z&Parsing helpers shared across modules.    N)Dictz(\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    Y/root/projects/butler/venv/lib/python3.11/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"   0   r   r    unitsc           	         |                                  }|st          d          	 t          |           S # t          $ r Y nw xY wt                              |          }|st          d|  d          t          |                    d                    }|                    d                                          }||vr5t          d| dt          |                                           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   5   s   {{}}H 312225zz     ))(33E lj5jjjkkkQ  F;;q>>!!D5W$WW$uzz||BTBTWWWXXXE$Ks   6 
AAtsc                     d}t          j                     | z
  }|dk     rdS |D ]"\  }}}t          ||z            }|||k    r n#| d| |dk    rdn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 agoN r
   r    z ago)timeround)r4   _TIMESINCE_CHUNKSdeltalabeldivider	max_valuer   s          r   format_timesincerJ   L   s    
	 IKK"Erzz""%6  !w	ego&& Ui%7%7E;;e;EAIISS2;;;;r    )__doc__rerC   typingr   compile
IGNORECASEr*   r	   strr)   __annotations__r   r   r"   r   floatrJ    r    r   <module>rT      s`   - , , 				        !bj!12=AA  
				 
DcN    
				
	 
DcN   /c /c / / / /
/# /# / / / /
 C  S#X  3        .< <3 < < < < < <r    