ok

Mini Shell

Direktori : /opt/imunify360/venv/lib64/python3.11/site-packages/humanize/__pycache__/
Upload File :
Current File : //opt/imunify360/venv/lib64/python3.11/site-packages/humanize/__pycache__/number.cpython-311.pyc

�

2�Dgj?��D�UdZddlmZddlZddlZddlZddlmZddlm	Z	ddl
mZddl
m
Z
mZmZdd	l
mZdd
l
mZe	rejdkrddlmZnddlmZd
Zded<d?d�Zd@dAd�ZdBdCd�Zd�dD��Zedd��edd��edd��ed d ��ed!d!��ed"d"��ed#d#��ed$d$��ed%d%��ed&d&��ed'd'��ed(d(��fZdDdEd+�ZdFd,�ZdFd-�Z dGdHd1�Z!					dIdJd:�Z"dKdLd>�Z#dS)Mz!Humanizing functions for numbers.�)�annotationsN)�Fraction)�
TYPE_CHECKING�)�_gettext)�	_ngettext�decimal_separator�thousands_separator)�_ngettext_noop)�	_pgettext)��
)�	TypeAliaszfloat | strr�NumberOrString�value�float�return�strc��tj|��rdStj|��r|dkrdStj|��r|dkrdSdS)z2Utility function to handle infinite and nan cases.�NaNrz-Infz+Inf�)�math�isnan�isinf�rs �o/builddir/build/BUILD/imunify360-venv-2.4.0/opt/imunify360/venv/lib/python3.11/site-packages/humanize/number.py�_format_not_finiters\���z�%�����u��z�%����U�Q�Y�Y��v��z�%����U�Q�Y�Y��v�
�2��male�genderc
��	tjt|����stt|����St	|��}n&#t
tf$rt|��cYSwxYw|dkr�tdd��tdd��tdd��tdd	��td
d��tdd��tdd��td
d��tdd��tdd��f
}n�tdd��tdd��tdd��tdd	��tdd��tdd��tdd��tdd��tdd��tdd��f
}|dzdvr|�|d��S|�||dz��S)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.
    rz0 (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�isfiniterr�int�	TypeError�
ValueErrorr�P_)rr �ts   r�ordinalr0%s���J��}�U�5�\�\�*�*�	4�%�e�E�l�l�3�3�3��E�
�
�����z�"�����5�z�z��������
�����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������$�Q�u�r�z�]�$�$�$��<A�A� A2�1A2�ndigits�
int | Nonec�*�t��}t��}	t|t��r�|�|d���|d��}tjt|����stt|����Sd|vrt|��}n\t|��}nLtjt|����stt|����St|��n&#ttf$rt|��cYSwxYw|�d�||��}nt|��}|�d|��}	tjdd|�d�|��}||kr|S|}�%)	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�.Nz	{0:.{1}f}Tz^(-?\d+)(\d{3})z\g<1>z\g<2>)r
r	�
isinstancer�replacerr*rrr+r,r-�format�re�sub)rr2�
thousands_sep�decimal_sep�orig�news      r�intcommar?os���D(�)�)�M�#�%�%�K���e�S�!�!�	��M�M�-��4�4�<�<�[�#�N�N�E��=��u���.�.�
8�)�%��,�,�7�7�7��e�|�|��e������E�
�
����=��u���.�.�
8�)�%��,�,�7�7�7��%�L�L�L����z�"�����5�z�z�����������!�!�%��1�1����5�z�z���<�<��[�)�)�D���f�'�)F�-�)F�)F�)F��M�M���3�;�;��J���	s�A;D�A D�;D� D.�-D.c��g|]}d|z��S)r�)�.0�xs  r�
<listcomp>rD�s��	H�	H�	H�A�"�a�%�	H�	H�	Hr)r
��	r(�������!r&�thousand�million�billion�trillion�quadrillion�quintillion�
sextillion�
septillion�	octillion�	nonillion�	decillion�googol�%.1fr8c���	tjt|����stt|����St	|��}n&#t
tf$rt|��cYSwxYw|dkr|dz}d}nd}|tdkr|t|��zSttdd�d��D�]!\}}||k�r|tt|dz
��z}t|t|dz
z}t||z��|krm|tt|��z}t|\}}|d�|t||tj
|����g��z|zcSt|dz
\}}|d�|t||tj
|����g��z|zcS��#|t|��zS)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*rrr+r,r-r�powers�	enumerate�human_powers�joinr�ceil)	rr8�negative_prefix�ordinal_�power�chopped�powers_difference�singular�plurals	         r�intwordrk�s��F��}�U�5�\�\�*�*�	4�%�e�E�l�l�3�3�3��E�
�
�����z�"�����5�z�z��������
�q�y�y�
����������v�a�y�����U���+�+�$�V�A�B�B�Z��3�3�����%��5�=�=��e�F�8�a�<�$8�9�9�9�G� &�x� 0�6�(�Q�,�3G� G���V�g�%�&�&�*;�;�;��%��x�(8�"9�"9�9��#/��#9� ��&�#��h�h���8�V�T�Y�w�=O�=O�!P�!P�Q��������� ,�H�q�L�9��H�f���(�(�F�I�h���	�'�@R�@R�$S�$S�T�U�U�V���
�
�
��&�S��Z�Z�'�'r1c�N�	tjt|����stt|����St	|��}n&#t
tf$rt|��cYSwxYwd|cxkrdksnt|��Std��td��td��td��td��td��td	��td
��td��td��f
|S)
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*rrr+r,r-r�_rs r�apnumberrx
s��8��}�U�5�\�\�*�*�	4�%�e�E�l�l�3�3�3��E�
�
�����z�"�����5�z�z����������?�?�?�?��?�?�?�?��5�z�z��	�&�	�	�	�%���	�%���	�'�
�
�	�&�	�	�	�&�	�	�	�%���	�'�
�
�	�'�
�
�	�&�	�	���
�
r1c��	t|��}tj|��st|��Sn&#tt
f$rt
|��cYSwxYwt|��}t||z
���	d��}|j
}|j}|r|s
|dkr|d�S|s	|d�d|d��S|d�d|d�d|d��S)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�/r^)rrr*rr,r-rr+r�limit_denominator�	numerator�denominator)r�number�whole_number�fracr|r}s      r�
fractionalr�<s��N��u�����}�V�$�$�	.�%�f�-�-�-�	.���z�"�����5�z�z���������v�;�;�L��F�\�)�*�*�<�<�T�B�B�D���I��"�K��%�I�%�+��*:�*:��$�$�$��4��3�3�3�+�3�3�3�3��B�B�B��B�B�B��B�B�B�Bs�15� A�A��	precisionr+c��ddddddddd	d
dd�}	t|��}tj|��st|��Sn&#tt
f$rt
|��cYSwxYwd
t
t|����z}|�|��}|�	d��\}}tjdd|��}g}|D]}|�||���|dzd�
|��z}	|	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)
        '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�9r]z{:.%se}�ez^\+?(\-?)0*(.+)$z\1\2z x 10r)rrr*rr-r,rr+r8�splitr9r:�appendrb)
rr��	exponents�fmt�n�part1�part2�	new_part2�char�	final_strs
          r�
scientificr�xs8��@�
�
�
�
�
�
�
�
�
�
���I���e�����}�U�#�#�	-�%�e�,�,�,�	-���	�"�����5�z�z��������
�c�#�i�.�.�)�)�
)�C��
�
�5���A��7�7�3�<�<�L�E�5��F�&���7�7�E��I��*�*������4��)�)�)�)����"�'�'�)�"4�"4�4�I��s�1A� A&�%A&�{:}�<�>�floor�float | Nonerc�floor_token�
ceil_tokenc�>�|�dStj|��st|��S|�||kr|}|}n|�||kr|}|}nd}t|t��r||�|��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*rr6rr8�callabler-)rr8r�rcr�r��token�msgs        r�clampr��s���^
�}��t��=����)�!�%�(�(�(���U�U�]�]������	
�	�e�d�l�l���������&�#���,��v�}�}�U�+�+�+�+�����%��v�v�e�}�}�$�$�	3���S�/�/�rrr
�unitc	��tj|��st|��S|dkr@ttjtjt
|��������nd}|dks|dkrt||dz
��|zS|d|dzdzzz}|dkrd|dzdz
}n|dkrd|dz
dz}nd	}t|d
||dzz
dz
z��}|s|r|dvrd	}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:
    rrMi��rrr
�
kMGTPEZYRQumμnpfazyrqrz.%if)�°u′u″r^)	rr*rr+r��log10�absr�r8)rr�r��exponentre�value_�spaces       r�metricr�sA��F�=����)�!�%�(�(�(�:?�1�*�*�s�4�:�d�j��U���4�4�5�5�6�6�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�
E�F���H���)=�!=�!=�������-�e�-�X�-�t�-�-�-r)rrrr)r)rrr rrr)N)rrr2r3rr)rZ)rrr8rrr)rrrr)r�)rrr�r+rr)r�NNr�r�)rrr8rr�r�rcr�r�rr�rrr)rr
)rrr�rr�r+rr)$�__doc__�
__future__rrr9�sys�	fractionsr�typingr�i18nrrwrr	r
r�NS_rr.�version_infor�typing_extensionsr�__annotations__rr0r?r_rarkrxr�r�r�r�rArr�<module>r�s���'�'�'�"�"�"�"�"�"�����	�	�	�	�
�
�
�
������� � � � � � �������C�C�C�C�C�C�C�C�C�C�'�'�'�'�'�'�!�!�!�!�!�!��0�
��7�"�"�$�$�$�$�$�$�$�/�/�/�/�/�/�*��)�)�)�)�����G%�G%�G%�G%�G%�T=�=�=�=�=�@
I�	H�G�	H�	H�	H���C�
�J����C�	�9����C�	�9����C�
�J����C�
�}�%�%��C�
�}�%�%��C��l�#�#��C��l�#�#��C��[�!�!��C��[�!�!��C��[�!�!��C��(���
�� G(�G(�G(�G(�G(�T/
�/
�/
�/
�d9C�9C�9C�9C�x>�>�>�>�>�F�����
H�H�H�H�H�V7.�7.�7.�7.�7.�7.�7.r

Zerion Mini Shell 1.0