
    i                         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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    o/var/www/vps2.regionflexible.com/Desarrollo/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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)r3   _TIMESINCE_CHUNKSdeltalabeldivider	max_valuer   s          r   format_timesincerI   J   s    
	 IIK"Erz"%6 !w	ego& Ui%7 WAeWEAIS6d;;26d;;r   )__doc__rerB   compile
IGNORECASEr)   r   dictstrr(   __annotations__r   r   r!   r   floatrI    r   r   <module>rS      s    - 	  !bjj!12==A  
				
DcN  
				
	
DcN /c /c /
/# /# /
 C  S#X  3  .< <3 <r   