o
    0j                     @   s   U d Z ddlZddlZe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dZdede	fddZdedeee	f de	fddZdedefddZdS ) 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                 C   
   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    r   _/var/www/html/Deteccion_Ine/venv/lib/python3.10/site-packages/huggingface_hub/utils/_parsing.py
parse_size)      
r   c                 C   r   )zfParse a duration expressed as a string with digits and unit (like `"10s"`) to an integer (in seconds).)r   r   r   r   r   r   parse_duration.   r   r   unitsc                 C   s   |   }|s
tdzt| W S  ty   Y nw t|}|s(td|  dt|d}|d }||vrItd| dt|  d|||  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unitr   r   r   r   3   s    

r   tsc                 C   sr   d}t   |  }|dk rdS |D ]\}}}t|| }|dur%||kr% nq| d| |dkr4d 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   r6   )monthr      )yearr   N   za few seconds agoN r   r    z ago)timeround)r0   Z_TIMESINCE_CHUNKSdeltalabeldividerZ	max_valuer   r   r   r   format_timesinceJ   s   
&rC   )__doc__rer>   compile
IGNORECASEr&   r   dictstrr%   __annotations__r   r   r   r   floatrC   r   r   r   r   <module>   s,   	