Ë Iî|Õá* wãó4—UdZddlmZddlZddlZddlZddlmZddlm Z ddl m Z ddl m Z mZmZdd l mZdd l mZe rej(d k\rdd lmZndd lmZd Zded<d'd„Zd(d)d„Zd*d+d„ZdD�cgc]}d|z‘Œ c}Zedd«edd«edd«edd«edd«edd«edd«edd«edd«edd«edd«ed d «f Zd,d-d!„Zd.d"„Zd.d#„Z d/d0d$„Z! d1 d2d%„Z"d3d4d&„Z#ycc}w)5z!Humanizing functions for numbers.é)Ú annotationsN)ÚFraction)Ú TYPE_CHECKINGé)Ú_gettext)Ú _ngettextÚdecimal_separatorÚthousands_separator)Ú_ngettext_noop)Ú _pgettext)éé )Ú TypeAliasz float | strrÚNumberOrStringcóœ—tj|«rytj|«r|dkrytj|«r|dkDryy)z2Utility function to handle infinite and nan cases.ÚNaNrz-Infz+InfÚ)ÚmathÚisnanÚisinf©Úvalues ú4/usr/lib/python3.12/site-packages/humanize/number.pyÚ_format_not_finiters>€ä ‡z�z�%ÔØÜ ‡z�z�%Ô˜U QšYØÜ ‡z�z�%Ô˜U QšYØØ óc ó— tjt|««stt|««St |«}|dk(rqtdd«tdd«tdd«tdd «td d«td d«td d«td d«tdd«tdd«f }nptdd«tdd«tdd«tdd «tdd«tdd«tdd«tdd«tdd«tdd«f }|dzdvr |›|d›�S|›||dz›�S#t t f$rt|«cYSwxYw)akConverts an integer to its ordinal as a string. For example, 1 is "1st", 2 is "2nd", 3 is "3rd", etc. Works for any integer or anything `int()` will turn into an integer. Anything else will return the output of str(value). Examples: ```pycon >>> ordinal(1) '1st' >>> ordinal(1002) '1002nd' >>> ordinal(103) '103rd' >>> ordinal(4) '4th' >>> ordinal(12) '12th' >>> ordinal(101) '101st' >>> ordinal(111) '111th' >>> ordinal("something else") 'something else' >>> ordinal([1, 2, 3]) == "[1, 2, 3]" True ``` Args: value (int, str, float): Integer to convert. gender (str): Gender for translations. Accepts either "male" or "female". Returns: str: Ordinal string. Úmalez0 (male)Úthz1 (male)Ústz2 (male)Úndz3 (male)Úrdz4 (male)z5 (male)z6 (male)z7 (male)z8 (male)z9 (male)z 0 (female)z 1 (female)z 2 (female)z 3 (female)z 4 (female)z 5 (female)z 6 (female)z 7 (female)z 8 (female)z 9 (female)éd)é é é rr) rÚisfiniteÚfloatrÚintÚ TypeErrorÚ ValueErrorÚstrÚP_)rÚgenderÚts rÚordinalr/%sj€ðJÜ�}‰}œU 5›\Ô*Ü%¤e¨E£lÓ3Ð 3Ü�E“ ˆð�Òä ˆz˜4Ó Ü ˆz˜4Ó Ü ˆz˜4Ó Ü ˆz˜4Ó Ü ˆz˜4Ó Ü ˆz˜4Ó Ü ˆz˜4Ó Ü ˆz˜4Ó Ü ˆz˜4Ó Ü ˆz˜4Ó ð ‰ô ˆ|˜TÓ "Ü ˆ|˜TÓ "Ü ˆ|˜TÓ "Ü ˆ|˜TÓ "Ü ˆ|˜TÓ "Ü ˆ|˜TÓ "Ü ˆ|˜TÓ "Ü ˆ|˜TÓ "Ü ˆ|˜TÓ "Ü ˆ|˜TÓ "ð ˆð ˆs�{�lÑ"Ø�˜˜1™˜ÐÐØˆW�Q�u˜r‘z‘]�OÐ $Ð$øô= ”zÐ "òÜ�5‹zÒðús‚1E´ EÅEÅEcó–—t«}t«} t|t«rp|j |d«j |d«}t j t|««stt|««Sd|vr t|«}nIt|«}n=t j t|««stt|««St|«|�dj||«}n t|«}|j d|«} tjdd|›d�|«}||k(r|S|}Œ%#ttf$rt|«cYSwxYw)a”Converts an integer to a string containing commas every three digits. For example, 3000 becomes "3,000" and 45000 becomes "45,000". To maintain some compatibility with Django's `intcomma`, this function also accepts floats. Examples: ```pycon >>> intcomma(100) '100' >>> intcomma("1000") '1,000' >>> intcomma(1_000_000) '1,000,000' >>> intcomma(1_234_567.25) '1,234,567.25' >>> intcomma(1234.5454545, 2) '1,234.55' >>> intcomma(14308.40, 1) '14,308.4' >>> intcomma("14308.40", 1) '14,308.4' >>> intcomma(None) 'None' ``` Args: value (int, float, str): Integer or float to convert. ndigits (int, None): Digits of precision for rounding after the decimal point. Returns: str: String containing commas every three digits. rÚ.z {0:.{1}f}z^(-?\d+)(\d{3})z\g<1>z\g<2>)r r Ú isinstancer+Úreplacerr&r'rr(r)r*ÚformatÚreÚsub)rÚndigitsÚ thousands_sepÚ decimal_sepÚorigÚnews rÚintcommar<os'€ôD(Ó)€MÜ#Ó%€KðÜ �eœSÔ !Ø—M‘M -°Ó4×<Ñ<¸[È#ÓNˆEÜ—=‘=¤ u£Ô.Ü)¬%°«,Ó7Ð7Ø�e‰|ܘe› ‘ä˜E› ‘ä—=‘=¤ u£Ô.Ü)¬%°«,Ó7Ð7Ü �%ŒLðÐØ×!Ñ! %¨Ó1‰ä�5‹zˆØ �<‰<˜˜[Ó )€DØ Ü�f‰fÐ'¨E°-°ÀÐ)FÈÓMˆØ �3Š;؈J؈ð øô ”zÐ "òÜ�5‹zÒðús–A#D+Á:A D+à D+Ä+EÅE) r éé r$ééééééé!r"rÚthousandÚmillionÚbillionÚtrillionÚ quadrillionÚ quintillionÚ sextillionÚ septillionÚ octillionÚ nonillionÚ decillionÚgoogolc ó.— tjt|««stt|««St |«}|dkr|dz}d}nd}|tdkr|t|«zSttddd«D]ë\}}||ksŒ |tt|dz «z }t|t|dz z }t||z«|k(rZ|tt|«z }t|\}}|dj|t||tj|««g«z|zcSt|dz \}}|dj|t||tj|««g«z|zcS|t|«zS#t t f$rt|«cYSwxYw)aConverts a large integer to a friendly text representation. Works best for numbers over 1 million. For example, 1_000_000 becomes "1.0 million", 1200000 becomes "1.2 million" and "1_200_000_000" becomes "1.2 billion". Supports up to decillion (33 digits) and googol (100 digits). Examples: ```pycon >>> intword("100") '100' >>> intword("12400") '12.4 thousand' >>> intword("1000000") '1.0 million' >>> intword(1_200_000_000) '1.2 billion' >>> intword(8100000000000000000000000000000000) '8.1 decillion' >>> intword(None) 'None' >>> intword("1234000", "%0.3f") '1.234 million' ``` Args: value (int, float, str): Integer to convert. format (str): To change the number of decimal or general format of the number portion. Returns: str: Friendly text representation as a string, unless the value passed could not be coaxed into an `int`. réÿÿÿÿÚ-rrNÚ )rr&r'rr(r)r*r+ÚpowersÚ enumerateÚ human_powersÚjoinrÚceil) rr4Únegative_prefixÚordinal_ÚpowerÚchoppedÚpowers_differenceÚsingularÚplurals rÚintwordrbÀs­€ðFÜ�}‰}œU 5›\Ô*Ü%¤e¨E£lÓ3Ð 3Ü�E“ ˆð ˆq‚yØ �‰ ˆØ‰àˆà Œv�a‰yÒØ¤ U£Ñ+Ð+ä$¤V¨A¨B Z°Ö3‰ˆ�%Ø �5‹=Øœe¤F¨8°a©<Ñ$8Ó9Ñ9ˆGÜ & xÑ 0´6¸(ÀQ¹,Ñ3GÑ GÐ Ü�V˜gÑ%Ó&Ð*;Ò;ؤ%¬¨xÑ(8Ó"9Ñ9�Ü#/°Ñ#9Ñ �˜&à#Ø—h‘hؤ¨8°V¼T¿Y¹YÀwÓ=OÓ!PÐQóñðñ òô ,¨H°q©LÑ9Ñ ˆH�fàØ—(‘(˜F¤I¨h¸ÄÇ Á È'Ó@RÓ$SÐTÓUñVàñò ð4ð( œS ›ZÑ 'Ð'øôA ”zÐ "òÜ�5‹zÒðús‚1E7´ E7Å7FÆFc óÔ— tjt|««stt|««St |«}d|cxkrdkst|«St|«Std«td«td«td«td«td«td «td «td «td «f |S#t t f$rt|«cYSwxYw) aJConverts an integer to Associated Press style. Examples: ```pycon >>> apnumber(0) 'zero' >>> apnumber(5) 'five' >>> apnumber(10) '10' >>> apnumber("7") 'seven' >>> apnumber("foo") 'foo' >>> apnumber(None) 'None' ``` Args: value (int, float, str): Integer to convert. Returns: str: For numbers 0-9, the number spelled out. Otherwise, the number. This always returns a string unless the value was not `int`-able, then `str(value)` is returned. rrÚzeroÚoneÚtwoÚthreeÚfourÚfiveÚsixÚsevenÚeightÚnine) rr&r'rr(r)r*r+Ú_rs rÚapnumberro sÏ€ð8Ü�}‰}œU 5›\Ô*Ü%¤e¨E£lÓ3Ð 3Ü�E“ ˆð �Œ?˜Š?Ü�5‹zÐð Ü�5‹zÐä ˆ&‹ Ü ˆ%‹Ü ˆ%‹Ü ˆ'‹ Ü ˆ&‹ Ü ˆ&‹ Ü ˆ%‹Ü ˆ'‹ Ü ˆ'‹ Ü ˆ&‹ ð ð ñ ð  øô ”zÐ "òÜ�5‹zÒðús‚1C ´ C à C'Ã&C'cóf— t|«}tj|«s t|«S t|«}t||z «jd«}|j}|j}|r |s |dk(r|d›S|s |d›d|d›�S|d›d|d›d|d›�S#tt f$rt |«cYSwxYw)a˜Convert to fractional number. There will be some cases where one might not want to show ugly decimal places for floats and decimals. This function returns a human-readable fractional number in form of fractions and mixed fractions. Pass in a string, or a number or a float, and this function returns: * a string representation of a fraction * or a whole number * or a mixed fraction * or the str output of the value, if it could not be converted Examples: ```pycon >>> fractional(0.3) '3/10' >>> fractional(1.3) '1 3/10' >>> fractional(float(1/3)) '1/3' >>> fractional(1) '1' >>> fractional("ten") 'ten' >>> fractional(None) 'None' ``` Args: value (int, float, str): Integer to convert. Returns: str: Fractional number as a string. ièrz.0fÚ/rU) r'rr&rr)r*r+r(rÚlimit_denominatorÚ numeratorÚ denominator)rÚnumberÚ whole_numberÚfracrsrts rÚ fractionalrx<s×€ðNÜ�u“ˆÜ�}‰}˜VÔ$Ü% fÓ-Ð -ð%ô�v“;€LÜ �F˜\Ñ)Ó *× <Ñ <¸TÓ B€DØ—‘€IØ×"Ñ"€KÙ™I¨+¸Ò*:ð˜sÐ#Ð$á Ø˜C�  +¨cÐ!2Ð3Ð3à˜3Ð ˜q ¨3 ¨q°¸SÐ0AÐ BÐBøô ”zÐ "òÜ�5‹zÒðús‚*BÂB0Â/B0c óÊ—ddddddddd d d d œ } t|«}tj|«s t|«S d t t|««z}|j|«}|jd«\}}tjdd|«}g}|D]}|j||«Œ|dzdj|«z} | S#tt f$rt |«cYSwxYw)uÔReturn number in string scientific notation z.wq x 10â�¿. Examples: ```pycon >>> scientific(float(0.3)) '3.00 x 10â�»Â¹' >>> scientific(int(500)) '5.00 x 10²' >>> scientific(-1000) '-1.00 x 10³' >>> scientific(1000, 1) '1.0 x 10³' >>> scientific(1000, 3) '1.000 x 10³' >>> scientific("99") '9.90 x 10¹' >>> scientific("foo") 'foo' >>> scientific(None) 'None' ``` Args: value (int, float, str): Input number. precision (int): Number of decimal for first part of the number. Returns: str: Number in scientific notation z.wq x 10â�¿. uâ�°ô¹ô²ô³uâ�´uâ�µuâ�¶uâ�·uâ�¸uâ�¹uâ�») Ú0Ú1Ú2Ú3Ú4Ú5Ú6Ú7Ú8Ú9rTz{:.%se}Úez^\+?(\-?)0*(.+)$z\1\2z x 10r)r'rr&rr*r)r+r(r4Úsplitr5r6ÚappendrY) rÚ precisionÚ exponentsÚfmtÚnÚpart1Úpart2Ú new_part2ÚcharÚ final_strs rÚ scientificr“xsþ€ð@Ø Ø Ø Ø Ø Ø Ø Ø Ø Ø ñ €IðÜ�e“ ˆÜ�}‰}˜UÔ#Ü% eÓ,Ð ,ð$ð ”cœ#˜i›.Ó)Ñ )€CØ � ‰ �5Ó€AØ—7‘7˜3“<�L€Eˆ5ä �F‰FÐ&¨°Ó 7€Eà€IÛˆØ×ј 4™Õ)ð𘑠"§'¡'¨)Ó"4Ñ4€Ià Ðøô œ Ð "òÜ�5‹zÒðús�*CÃC"Ã!C"có —|€ytj|«s t|«S|� ||kr|}|}n|� ||kDr|}|}nd}t|t«r||j |«zSt |«r |||«zSd}t|«‚)a¡Returns number with the specified format, clamped between floor and ceil. If the number is larger than ceil or smaller than floor, then the respective limit will be returned, formatted and prepended with a token specifying as such. Examples: ```pycon >>> clamp(123.456) '123.456' >>> clamp(0.0001, floor=0.01) '<0.01' >>> clamp(0.99, format="{:.0%}", ceil=0.99) '99%' >>> clamp(0.999, format="{:.0%}", ceil=0.99) '>99%' >>> clamp(1, format=intword, floor=1e6, floor_token="under ") 'under 1.0 million' >>> clamp(None) is None True ``` Args: value (int, float): Input number. format (str OR callable): Can either be a formatting string, or a callable function that receives value and returns a string. floor (int, float): Smallest value before clamping. ceil (int, float): Largest value before clamping. floor_token (str): If value is smaller than floor, token will be prepended to output. ceil_token (str): If value is larger than ceil, token will be prepended to output. Returns: str: Formatted number. The output is clamped between the indicated floor and ceil. If the number is larger than ceil or smaller than floor, the output will be prepended with a token indicating as such. NrzpInvalid format. Must be either a valid formatting string, or a function that accepts value and returns a string.)rr&rr2r+r4Úcallabler*)rr4ÚfloorrZÚ floor_tokenÚ ceil_tokenÚtokenÚmsgs rÚclampr›¹s €ð^ €}Øä �=‰=˜Ô Ü! %Ó(Ð(à ИU Uš]ØˆØ‰Ø Ð ˜e dšl؈؉àˆä�&œ#ÔØ�v—}‘} UÓ+Ñ+Ð+ä�ÔØ‘v˜e“}Ñ$Ð$ð 3ðô �S‹/Ðrc óÀ—tj|«s t|«S|dk7r:ttjtj t |««««nd}|dk\s|dkrt||dz «|zS|d|dzdzzz}|dk\r d|dzdz }n|dkr d| dz dz}nd }t|d ||dzz dz z«}|s|r|d vrd }nd }|›|›|›|›�S) uŸReturn a value with a metric SI unit-prefix appended. Examples: ```pycon >>> metric(1500, "V") '1.50 kV' >>> metric(2e8, "W") '200 MW' >>> metric(220e-6, "F") '220 μF' >>> metric(1e-14, precision=4) '10.00 f' ``` The unit prefix is always chosen so that non-significant zero digits are required. i.e. `123,000` will become `123k` instead of `0.123M` and `1,230,000` will become `1.23M` instead of `1230K`. For numbers that are either too huge or too tiny to represent without resorting to either leading or trailing zeroes, it falls back to `scientific()`. ```pycon >>> metric(1e40) '1.00 x 10â�´â�°' ``` Args: value (int, float): Input number. unit (str): Optional base unit. precision (int): The number of digits the output should contain. Returns: str: rrEiâÿÿÿrrr Ú kMGTPEZYRQu mμnpfazyrqrz.%if)ô°u′u″rU) rr&rr(r–Úlog10Úabsr“r4)rÚunitrŠÚexponentr\Úvalue_Úspaces rÚmetricr¥s€ôF �=‰=˜Ô Ü! %Ó(Ð(Ø:?À1º*Œs”4—:‘:œdŸj™j¬¨U«Ó4Ó5Ô6È!€Hà�2‚~˜ CšÜ˜% ¨Q¡Ó/°$Ñ6Ð6à ˆR�H ‘M AÑ%Ñ &Ñ&€EØ�1‚}Ø ¨A¡ °Ñ 1Ñ2‰Ø �AŠØ  8 )¨a¡-°AÑ!5Ñ6‰àˆÜ �E˜6 Y°(¸Q±,Ñ%?À!Ñ%CÑDÓ E€FÙ ‘H Ð)=Ñ!=؉àˆàˆX�e�W˜X˜J t fÐ -Ð-r)rr'Úreturnr+)r)rrr-r+r¦r+)N)rrr7z int | Noner¦r+)z%.1f)rrr4r+r¦r+)rrr¦r+)é)rrrŠr(r¦r+)z{:}NNÚ<Ú>)rr'r4r+r–ú float | NonerZrªr—r+r˜r+r¦r+)rr )rr'r¡r+rŠr(r¦r+)$Ú__doc__Ú __future__rrr5ÚsysÚ fractionsrÚtypingrÚi18nrrnrr r r ÚNS_r r,Ú version_inforÚtyping_extensionsrÚ__annotations__rr/r<rVrXrbrorxr“r›r¥)Úxs0rÚr¶s�ðÚ'Ý"ã Û Û ÝÝ åßCÑCÝ'Ý!áØ ×ј7Ò"Þ$å/ð*€� Ó)óôG%ôT=ñ@HÓ HÑG�Aˆ"ˆa‹%ÐGÑ H€áˆ �JÓÙˆ �9ÓÙˆ �9ÓÙˆ �JÓÙˆ �}Ó%Ùˆ �}Ó%Ùˆ �lÓ#Ùˆ �lÓ#Ùˆ �[Ó!Ùˆ �[Ó!Ùˆ �[Ó!Ùˆ�(Óð € ô G(óT/ ód9Côx>ðFØØØØð HØ ðHà ðHð ðHð ð Hð ð Hð ð Hð óHõV7.ùòk IsÁ5 D