403Webshell
Server IP : 192.158.238.246  /  Your IP : 18.118.37.224
Web Server : LiteSpeed
System : Linux uniform.iwebfusion.net 4.18.0-553.27.1.lve.1.el8.x86_64 #1 SMP Wed Nov 20 15:58:00 UTC 2024 x86_64
User : jenniferflocom ( 1321)
PHP Version : 8.1.32
Disable Function : NONE
MySQL : OFF  |  cURL : ON  |  WGET : ON  |  Perl : ON  |  Python : ON  |  Sudo : OFF  |  Pkexec : OFF
Directory :  /opt/alt/python38/lib/python3.8/site-packages/humanize/__pycache__/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Command :


[ Back ]     

Current File : /opt/alt/python38/lib/python3.8/site-packages/humanize/__pycache__/number.cpython-38.pyc
U

su]a,0�@sdZddlZddlZddlmZddlmZddlmZddlm	Z
ddlmZdd	lm
Z
d-dd�Zd.d
d�Zdd�dD�Ze
dd�e
dd�e
dd�e
dd�e
dd�e
dd�e
dd�e
dd�e
dd�e
dd�e
dd�e
dd�fZd/dd �Zd!d"�Zd#d$�Zd0d&d'�Zd1d+d,�ZdS)2z!Humanizing functions for numbers.�N)�Fraction�)�gettext)�ngettext)�
ngettext_noop)�pgettext)�thousands_separator�malecCszt|�}Wnttfk
r(|YSX|dkr�tdd�tdd�tdd�tdd	�td
d�tdd�tdd�td
d�tdd�tdd�f
}nTtdd�tdd�tdd�tdd	�tdd�tdd�tdd�tdd�tdd�tdd�f
}|ddkr�|�|d��S|�||d��S)a]Converts 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 other value will have nothing
    done to it.

    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(None) is None
        True

        ```
    Args:
        value (int, str, float): Integer to convert.
        gender (str): Gender for translations. Accepts either "male" or "female".

    Returns:
        str: Ordinal string.
    r	z0 (male)�thz1 (male)�stz2 (male)Zndz3 (male)Zrdz4 (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)���
r�
)�int�	TypeError�
ValueError�P_)�valueZgender�t�r�@/opt/alt/python38/lib/python3.8/site-packages/humanize/number.py�ordinals<$
��rc	Cs�t�}z(t|t�r$t|�|d��nt|�Wnttfk
rJ|YSX|r^d�||�}nt|�}t�	dd|�d�|�}||kr�|St
|�SdS)abConverts 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(None) is None
        True

        ```
    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.
    �z	{0:.{1}f}z^(-?\d+)(\d{3})z\g<1>z\g<2>N)r�
isinstance�str�float�replacerr�format�re�sub�intcomma)r�ndigits�sep�orig�newrrrr"Vs

r"cCsg|]}d|�qS)rr)�.0�xrrr�
<listcomp>�sr))���	r�������!rZthousandZmillionZbillionZtrillionZquadrillionZquintillionZ
sextillionZ
septillionZ	octillionZ	nonillionZ	decillionZgoogol�%.1fc
Cszt|�}Wnttfk
r(|YSX|tdkr>t|�Sttdd�d�D]�\}}||krP|tt|d�}t||�td�kr�|tt|�}t|\}}d�|t	||t
�|��g�|St|d\}}d�|t	||t
�|��g�|SqPt|�S)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) is None
        True
        >>> 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`.
    rrN��� )rrr�powersr�	enumerater�human_powers�joinr�math�ceil)rrrZpowerZchoppedZsingular�pluralrrr�intword�s("
��
r>cCs�zt|�}Wnttfk
r(|YSXd|kr>dksHnt|�Std�td�td�td�td�td�td	�td
�td�td�f
|S)
a:Converts 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) is None
      True

      ```
    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, unlike the Django filter.
    rrZzero�oneZtwoZthreeZfourZfiveZsixZsevenZeightZnine)rrrr�_)rrrr�apnumber�s&
��rAc	Cs�zt|�}Wnttfk
r(|YSXt|�}t||��d�}|j}|j}|rh|sh|dkrh|d�S|s~|d�d|d��S|d�d|d�d|d��SdS)aZConvert 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

    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) is None
        True

        ```
    Args:
        value (int, float, str): Integer to convert.

    Returns:
        str: Fractional number as a string.
    r5rz.0f�/r6N)rrrrrZlimit_denominatorZ
_numeratorZ_denominator)r�numberZwhole_number�frac�	numerator�denominatorrrr�
fractionals%
rG�c
Cs
ddddddddd	d
ddd
�}d}zPdt|�krDt|��dd�}d}t|t�rVt|�}dtt|��}|�|�}Wnttfk
r�|YSX|�d�\}}d|kr�|�dd�}d|kr�|�dd�}g}|r�|�	|d�|D]}	|�	||	�q�|dd�
|�}
|
S)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) is None
        True

        ```

    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⁺u⁻)�0�1�2�3�4�5�6�7�8�9�+�-FrWrTz{:.%se}�ez-0z+0z x 10)rrrrrrrr�split�appendr:)rZ	precisionZ	exponents�negative�fmt�nZpart1Zpart2Z	new_part2�charZ	final_strrrr�
scientific:sH �

r_�{:}�<�>cCs||dkrdS|dk	r&||kr&|}|}n|dk	r@||kr@|}|}nd}t|t�r\||�|�St|�rp|||�Std��dS)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 than 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 if 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.)rrr�callabler)rr�floorr<Zfloor_tokenZ
ceil_token�tokenrrr�clamp�s (
�rf)r	)N)r4)rH)r`NNrarb)�__doc__r;r Z	fractionsrZi18nrr@rrZNS_rrrrr"r7r9r>rArGr_rfrrrr�<module>s:
G
4�
:.7
O

Youez - 2016 - github.com/yon3zu
LinuXploit