MOON
Server: Apache
System: Linux server30c.hostingraja.org 3.10.0-962.3.2.lve1.5.63.el7.x86_64 #1 SMP Fri Oct 8 12:03:35 UTC 2021 x86_64
User: jibhires (1887)
PHP: 8.1.30
Disabled: show_source, system, shell_exec, passthru, exec, popen, proc_open, allow_url_fopen, symlink, escapeshellcmd, pcntl_exec
Upload Files
File: //opt/alt/python35/lib/python3.5/site-packages/humanize/__pycache__/number.cpython-35.opt-1.pyc


�dT��@s
dZddlZddlmZddlmZddlmZm	Z
mZdd�Z
d	d
�Zdd�d*D�Ze
d�e
d�e
d�e
d�e
d�e
d�e
d�e
d�e
d �e
d!�e
d"�fZd#d$d%�Zd&d'�Zd(d)�ZdS)+z!Humanizing functions for numbers.�N)�Fraction�)�compat)�gettext�gettext_noop�pgettextcCs�yt|�}Wnttfk
r.|SYnXtdd�tdd�tdd�tdd�td	d�td
d�tdd�tdd�td
d�tdd�f
}|ddkr�d||dfSd|||dfS)z�Converts an integer to its ordinal as a string. 1 is '1st', 2 is '2nd',
    3 is '3rd', etc. Works for any integer or anything int() will turn into an
    integer.  Anything other value will have nothing done to it.�0Zth�1�st�2Znd�3Zrd�4�5�6�7�8�9�d���
z%d%sr�
)rrr)�int�	TypeError�
ValueError�P_)�value�t�r�
/number.py�ordinals"	r cCs�y9t|tj�r.t|jdd��n
t|�Wnttfk
rW|SYnXt|�}tj	dd|�}||kr�|St
|�SdS)z�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 compatability with Django's intcomma, this function also accepts
    floats.�,�z^(-?\d+)(\d{3})z\g<1>,\g<2>N)�
isinstancerZstring_types�float�replacerr�str�re�sub�intcomma)rZorig�newrrrr)"s	r)cCsg|]}d|�qS)rr)�.0�xrrr�
<listcomp>5s	r-��	r�������!rZmillionZbillionZtrillionZquadrillionZquintillionZ
sextillionZ
septillionZ	octillionZ	nonillionZ	decillionZgoogolz%.1fcCs�yt|�}Wnttfk
r.|SYnX|tdkrIt|�Sxpttdd�d�D]U\}}||krc|tt|d�}dj|tt	|d�g�|SqcWt|�S)a�Converts a large integer to a friendly text representation. Works best for
    numbers over 1 million. For example, 1000000 becomes '1.0 million', 1200000
    becomes '1.2 million' and '1200000000' becomes '1.2 billion'.  Supports up to
    decillion (33 digits) and googol (100 digits).  You can pass format to change
    the number of decimal or general format of the number portion.  This function
    returns a string unless the value passed was unable to be coaxed into an int.rrN� )
rrr�powersr&�	enumerater$�join�_�human_powers)r�formatr ZpowerZchoppedrrr�intword;s	
&)r>cCs�yt|�}Wnttfk
r.|SYnXd|koFdknsUt|�Std�td�td�td�td�td�td	�td
�td�f	|dS)
z�For numbers 1-9, returns the number spelled out. Otherwise, returns the
    number. This follows Associated Press style.  This always returns a string
    unless the value was not int-able, unlike the Django filter.rrZoneZtwoZthreeZfourZfiveZsixZsevenZeightZniner)rrrr&r;)rrrr�apnumberPs	
6r?cCs�yt|�}Wnttfk
r.|SYnXt|�}t||�jd�}|j}|j}|r�|r�|dkr�d|S|s�d||fSd|||fSdS)as
    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 whole number
        or a mixed fraction
    Examples:
        fractional(0.3) will return '1/3'
        fractional(1.3) will return '1 3/10'
        fractional(float(1/3)) will return '1/3'
        fractional(1) will return '1'
    This will always return a string.
    i�rz%.0fz	%.0f/%.0fz%.0f %.0f/%.0fN)r$rrrrZlimit_denominatorZ
_numeratorZ_denominator)r�numberZwholeNumberZfrac�	numerator�denominatorrrr�
fractional^s			rC)r.r/rr0r1r2r3r4r5r6r)�__doc__r'Z	fractionsrr"rZi18nrr;rZN_rrr r)r8r<r>r?rCrrrr�<module>s$*