AlkantarClanX12

Your IP : 3.133.129.8


Current Path : /opt/imunify360/venv/lib64/python3.11/site-packages/babel/__pycache__/
Upload File :
Current File : //opt/imunify360/venv/lib64/python3.11/site-packages/babel/__pycache__/numbers.cpython-311.pyc

�

j��ff����dZddlmZddlZddlZddlZddlZddlmZm	Z	m
Z
mZddlm
Z
mZmZddlmZerddlmZed��ZGd	�d
e��Zdmdnd�Zdmdod�Zdmdpd�Zdmdqd�Zdefdrd�Zefdsd�Zdtd�Zdefdrd�Ze					dudvd)���Ze					dudwd,���Z					dxdyd0�Zefdzd1�Z efdzd2�Z!efdzd3�Z"efdzd4�Z#efdzd5�Z$efdzd6�Z%efd{d9�Z&d|d;�Z'd}d>�Z(ded-d-fd~dC�Z)dDeddE�ddI�Z*d�dN�Z+GdO�dPe,��Z-ded-dQd-d-fd�dT�Z.ded-dQd-d-fd�dU�Z/dDeddE�d�dW�Z0ded-d-fd~dX�Z1ded-fd�dY�Z2GdZ�d[e3��Z4efd�d]�Z5ed.fd�d_�Z6d`Z7daZ8dbe7zZ9dce8zZ:ddZ;ej<e9�e:�e;����Z=d�dg�Z>d�dk�Z?Gdl�dj��Z@dS)�a�
    babel.numbers
    ~~~~~~~~~~~~~

    Locale dependent formatting and parsing of numeric data.

    The default locale for the functions in this module is determined by the
    following environment variables, in that order:

     * ``LC_NUMERIC``,
     * ``LC_ALL``, and
     * ``LANG``

    :copyright: (c) 2013-2023 by the Babel Team.
    :license: BSD, see LICENSE for more details.
�)�annotationsN)�
TYPE_CHECKING�Any�cast�overload)�Locale�default_locale�
get_global)�LocaleDataDict)�Literal�
LC_NUMERICc��eZdZdZdd�ZdS)	�UnknownCurrencyErrorzRException thrown when a currency is requested for which no data is available.
    �
identifier�str�return�Nonec�R�t�|d|�d���||_dS)zkCreate the exception.
        :param identifier: the identifier string of the unsupported currency
        zUnknown currency �.N)�	Exception�__init__r)�selfrs  �m/builddir/build/BUILD/imunify360-venv-2.3.5/opt/imunify360/venv/lib/python3.11/site-packages/babel/numbers.pyrzUnknownCurrencyError.__init__)s3��	���4�!D�Z�!D�!D�!D�E�E�E�%�����N)rrrr)�__name__�
__module__�__qualname__�__doc__r�rrrr%s2��������%�%�%�%�%�%rr�locale�Locale | str | Noner�set[str]c��|r,tj|��j���}nt	d��}t|��S)aM Return a `set` of normalized currency codes.

    .. versionadded:: 2.5.0

    :param locale: filters returned currency codes by the provided locale.
                   Expected to be a locale instance or code. If no locale is
                   provided, returns the list of all currencies from all
                   locales.
    �all_currencies)r�parse�
currencies�keysr
�set)r r&s  r�list_currenciesr)3sF���2��\�&�)�)�4�9�9�;�;�
�
�� 0�1�1�
��z�?�?�r�currencyrrc�F�|t|��vrt|���dS)a Check the currency code is recognized by Babel.

    Accepts a ``locale`` parameter for fined-grained validation, working as
    the one defined above in ``list_currencies()`` method.

    Raises a `UnknownCurrencyError` exception if the currency is unknown to Babel.
    N)r)r�r*r s  r�validate_currencyr-Es-����v�.�.�.�.�"�8�,�,�,�/�.r�boolc�~�|rt|t��sdS	t||��n#t$rYdSwxYwdS)zy Returns `True` only if a currency is recognized by Babel.

    This method always return a Boolean and never raise.
    FT)�
isinstancerr-rr,s  r�is_currencyr1Qsa��
��:�h��4�4���u���(�F�+�+�+�+�������u�u������4s�,�
:�:�
str | Nonec�|�t|t��r|���}t||��sdS|S)z�Returns the normalized identifier of any currency code.

    Accepts a ``locale`` parameter for fined-grained validation, working as
    the one defined above in ``list_currencies()`` method.

    Returns None if the currency is unknown to Babel.
    N)r0r�upperr1r,s  r�normalize_currencyr5_sA���(�C� � �$��>�>�#�#���x��(�(�����Or�count�float | decimal.Decimal | Nonec�&�tj|��}|�a	|�|��}n#ttf$rd}YnwxYw|jd}||vr ||}||vr||Sd|vr|dS|j�||��S)a�Return the name used by the locale for the specified currency.

    >>> get_currency_name('USD', locale='en_US')
    u'US Dollar'

    .. versionadded:: 0.9.4

    :param currency: the currency code.
    :param count: the optional count.  If provided the currency name
                  will be pluralized to that number if possible.
    :param locale: the `Locale` object or locale identifier.
    N�other�currency_names_plural)rr%�plural_form�
OverflowError�
ValueError�_datar&�get)r*r6r �locr;�plural_names�currency_plural_namess       r�get_currency_namerCns���"�,�v�
�
�C���	"��/�/�%�0�0�K�K���z�*�	"�	"�	"�!�K�K�K�	"�����y�!8�9���|�#�#�$0��$:�!��3�3�3�,�[�9�9��/�/�/�,�W�5�5��>���h��1�1�1s�.�A�Ac�\�tj|��j�||��S)z�Return the symbol used by the locale for the specified currency.

    >>> get_currency_symbol('USD', locale='en_US')
    u'$'

    :param currency: the currency code.
    :param locale: the `Locale` object or locale identifier.
    )rr%�currency_symbolsr?r,s  r�get_currency_symbolrF�s'���<����0�4�4�X�x�H�H�Hr�intc�d�td��}|�||d��dS)z�Return currency's precision.

    Precision is the number of decimals found after the decimal point in the
    currency's format pattern.

    .. versionadded:: 2.5.0

    :param currency: the currency code.
    �currency_fractions�DEFAULTr)r
r?)r*�
precisionss  r�get_currency_precisionrL�s0���0�1�1�J��>�>�(�J�y�$9�:�:�1�=�=rc���tj|��}|�9|�|��}	|jd|S#t$rYnwxYw|jddS)aV
    Return the unit pattern used for long display of a currency value
    for a given locale.
    This is a string containing ``{0}`` where the numeric part
    should be substituted and ``{1}`` where the currency long display
    name should be substituted.

    >>> get_currency_unit_pattern('USD', locale='en_US', count=10)
    u'{0} {1}'

    .. versionadded:: 2.7.0

    :param currency: the currency code.
    :param count: the optional count.  If provided the unit
                  pattern for that number will be returned.
    :param locale: the `Locale` object or locale identifier.
    N�currency_unit_patternsr9)rr%r;r>�LookupError)r*r6r r@r;s     r�get_currency_unit_patternrP�sw��,�,�v�
�
�C����o�o�e�,�,��	��9�5�6�{�C�C���	�	�	��D�	�����9�-�.�w�7�7s�A�
A
�A
.�	territory�
start_date�datetime.date | None�end_date�tender�
non_tender�include_details�Literal[False]�	list[str]c��dS�Nr�rQrRrTrUrVrWs      r�get_territory_currenciesr]��	���Cr�
Literal[True]�list[dict[str, Any]]c��dSr[rr\s      rr]r]�r^rTF� list[str] | list[dict[str, Any]]c�l���td��}��tj����n.t	�tj��r���������n.t	�tj��r�����|�|���d��}��fd�}g}	|D]m\}
}}}
|rtj|�}|rtj|�}|
r|s|
s@|r>|||��r2|r|	�|
|||
d����X|	�|
���n|	S)asReturns the list of currencies for the given territory that are valid for
    the given date range.  In addition to that the currency database
    distinguishes between tender and non-tender currencies.  By default only
    tender currencies are returned.

    The return value is a list of all currencies roughly ordered by the time
    of when the currency became active.  The longer the currency is being in
    use the more to the left of the list it will be.

    The start date defaults to today.  If no end date is given it will be the
    same as the start date.  Otherwise a range can be defined.  For instance
    this can be used to find the currencies in use in Austria between 1995 and
    2011:

    >>> from datetime import date
    >>> get_territory_currencies('AT', date(1995, 1, 1), date(2011, 1, 1))
    ['ATS', 'EUR']

    Likewise it's also possible to find all the currencies in use on a
    single date:

    >>> get_territory_currencies('AT', date(1995, 1, 1))
    ['ATS']
    >>> get_territory_currencies('AT', date(2011, 1, 1))
    ['EUR']

    By default the return value only includes tender currencies.  This
    however can be changed:

    >>> get_territory_currencies('US')
    ['USD']
    >>> get_territory_currencies('US', tender=False, non_tender=True,
    ...                          start_date=date(2014, 1, 1))
    ['USN', 'USS']

    .. versionadded:: 2.0

    :param territory: the name of the territory to find the currency for.
    :param start_date: the start date.  If not given today is assumed.
    :param end_date: the end date.  If not given the start date is assumed.
    :param tender: controls whether tender currencies should be included.
    :param non_tender: controls whether non-tender currencies should be
                       included.
    :param include_details: if set to `True`, instead of returning currency
                            codes the return value will be dictionaries
                            with detail information.  In that case each
                            dictionary will have the keys ``'currency'``,
                            ``'from'``, ``'to'``, and ``'tender'``.
    �territory_currenciesNrc�,��|dus|�ko	|dup|�kSr[r)�start�endrTrRs  ��r�
_is_activez,get_territory_currencies.<locals>._is_active)s/�����
�2��(�!2�2��t��0�s�j�0�	2r)r*�from�torU)r
�datetime�date�todayr0r?r4�append)rQrRrTrUrVrWr&�cursrh�result�
currency_coderfrg�	is_tenders ``           rr]r]�s�����r�2�3�3�J����]�(�(�*�*�
�
�	�J�� 1�	2�	2�'��_�_�&�&�
������	�H�h�/�	0�	0�#��=�=�?�?���>�>�)�/�/�+�+�R�0�0�D�2�2�2�2�2�2��F�04�-�-�,�
�u�c�9��	*��M�5�)�E��	&��-��%�C�
�
	-�6�
	-��
	-�#-�
	-�4>�J�u�c�4J�4J�
	-��
-��
�
� -�!��'�	�������
�
�m�,�,�,���Mrc�\�tj|��j�dd��S)z�Return the symbol used by the locale to separate decimal fractions.

    >>> get_decimal_symbol('en_US')
    u'.'

    :param locale: the `Locale` object or locale identifier
    �decimalr�rr%�number_symbolsr?�r s r�get_decimal_symbolrxBs'���<����.�2�2�9�c�B�B�Brc�\�tj|��j�dd��S)z�Return the plus sign symbol used by the current locale.

    >>> get_plus_sign_symbol('en_US')
    u'+'

    :param locale: the `Locale` object or locale identifier
    �plusSign�+rurws r�get_plus_sign_symbolr|Ms'���<����.�2�2�:�s�C�C�Crc�\�tj|��j�dd��S)z�Return the plus sign symbol used by the current locale.

    >>> get_minus_sign_symbol('en_US')
    u'-'

    :param locale: the `Locale` object or locale identifier
    �	minusSign�-rurws r�get_minus_sign_symbolr�Xs'���<����.�2�2�;��D�D�Drc�\�tj|��j�dd��S)z�Return the symbol used by the locale to separate mantissa and exponent.

    >>> get_exponential_symbol('en_US')
    u'E'

    :param locale: the `Locale` object or locale identifier
    �exponential�Erurws r�get_exponential_symbolr�cs'���<����.�2�2�=�#�F�F�Frc�\�tj|��j�dd��S)z�Return the symbol used by the locale to separate groups of thousands.

    >>> get_group_symbol('en_US')
    u','

    :param locale: the `Locale` object or locale identifier
    �group�,rurws r�get_group_symbolr�ns'���<����.�2�2�7�C�@�@�@rc�\�tj|��j�dd��S)u�Return the symbol used by the locale to represent infinity.

    >>> get_infinity_symbol('en_US')
    u'∞'

    :param locale: the `Locale` object or locale identifier
    �infinityu∞rurws r�get_infinity_symbolr�ys'���<����.�2�2�:�u�E�E�Er�number�float | decimal.Decimal | strc�X�tjdt��t||���S)a�Return the given number formatted for a specific locale.

    >>> format_number(1099, locale='en_US')  # doctest: +SKIP
    u'1,099'
    >>> format_number(1099, locale='de_DE')  # doctest: +SKIP
    u'1.099'

    .. deprecated:: 2.6.0

       Use babel.numbers.format_decimal() instead.

    :param number: the number to format
    :param locale: the `Locale` object or locale identifier


    z+Use babel.numbers.format_decimal() instead.rw)�warnings�warn�DeprecationWarning�format_decimal)r�r s  r�
format_numberr��s+��"
�M�?�AS�T�T�T��&��0�0�0�0r�decimal.Decimalc��t|tj��sJ�|������}t|jt��r|jdkrdSt|j��S)z�Return maximum precision of a decimal instance's fractional part.

    Precision is extracted from the fractional part only.
    r)r0rt�Decimal�	normalize�as_tuple�exponentrG�abs)r��
decimal_tuples  r�get_decimal_precisionr��sr���f�g�o�.�.�.�.�.��$�$�&�&�/�/�1�1�M��m�,�c�2�2��m�6L�PQ�6Q�6Q��q��}�%�&�&�&r�	precision�int | decimal.Decimalc�x�t|ttjf��sJ�tjd��|zS)z<Return minimal quantum of a number, as defined by precision.�
)r0rGrtr�)r�s r�get_decimal_quantumr��s6���i�#�w��!7�8�8�8�8�8��?�2���I�:�.�.r�format�str | NumberPattern | None�decimal_quantization�group_separatorc��tj|��}|�
|j|}t|��}|�||||���S)a�Return the given decimal number formatted for a specific locale.

    >>> format_decimal(1.2345, locale='en_US')
    u'1.234'
    >>> format_decimal(1.2346, locale='en_US')
    u'1.235'
    >>> format_decimal(-1.2346, locale='en_US')
    u'-1.235'
    >>> format_decimal(1.2345, locale='sv_SE')
    u'1,234'
    >>> format_decimal(1.2345, locale='de')
    u'1,234'

    The appropriate thousands grouping and the decimal separator are used for
    each locale:

    >>> format_decimal(12345.5, locale='en_US')
    u'12,345.5'

    By default the locale is allowed to truncate and round a high-precision
    number by forcing its format pattern onto the decimal part. You can bypass
    this behavior with the `decimal_quantization` parameter:

    >>> format_decimal(1.2346, locale='en_US')
    u'1.235'
    >>> format_decimal(1.2346, locale='en_US', decimal_quantization=False)
    u'1.2346'
    >>> format_decimal(12345.67, locale='fr_CA', group_separator=False)
    u'12345,67'
    >>> format_decimal(12345.67, locale='en_US', group_separator=True)
    u'12,345.67'

    :param number: the number to format
    :param format:
    :param locale: the `Locale` object or locale identifier
    :param decimal_quantization: Truncate and round high-precision numbers to
                                 the format pattern. Defaults to `True`.
    :param group_separator: Boolean to switch group separator on/off in a locale's
                            number format.
    N�r�r�)rr%�decimal_formats�
parse_pattern�apply�r�r�r r�r��patterns      rr�r��s\��^�\�&�
!�
!�F�
�~��'��/���F�#�#�G��=�=���-A�Sb��d�d�dr�short)�format_typer �fraction_digitsr��Literal['short', 'long']r�c���tj|��}|j|}t||||��\}}|�
|jd}t|��}|�||d���S)u�Return the given decimal number formatted for a specific locale in compact form.

    >>> format_compact_decimal(12345, format_type="short", locale='en_US')
    u'12K'
    >>> format_compact_decimal(12345, format_type="long", locale='en_US')
    u'12 thousand'
    >>> format_compact_decimal(12345, format_type="short", locale='en_US', fraction_digits=2)
    u'12.34K'
    >>> format_compact_decimal(1234567, format_type="short", locale="ja_JP")
    u'123万'
    >>> format_compact_decimal(2345678, format_type="long", locale="mk")
    u'2 милиони'
    >>> format_compact_decimal(21000000, format_type="long", locale="mk")
    u'21 милион'

    :param number: the number to format
    :param format_type: Compact format to use ("short" or "long")
    :param locale: the `Locale` object or locale identifier
    :param fraction_digits: Number of digits after the decimal point to use. Defaults to `0`.
    NF�r�)rr%�compact_decimal_formats�_get_compact_formatr�r�r�)r�r�r r��compact_formatr�r�s       r�format_compact_decimalr��sn��6�\�&�
!�
!�F��3�K�@�N�(�����Y�Y�N�F�F�
�~��'��-���F�#�#�G��=�=���e�=�D�D�Drr�rr�,tuple[decimal.Decimal, NumberPattern | None]c
���t|tj��s!tjt|����}|���s|���r|dfSd}t
d�|dD��d���D]�}t|��|kr�|dt|��}t|��j	}|dkrn�ttj||d|�d��dz
zzz��}t||��}|�
t|����}||vrd}|dkrd	|vrd	}||t|��}|}n��||fS)
z�Returns the number after dividing by the unit and the format pattern to use.
    The algorithm is described here:
    https://www.unicode.org/reports/tr35/tr35-45/tr35-numbers.html#Compact_Number_Formats.
    Nc�,�g|]}t|����Sr)rG)�.0�ms  r�
<listcomp>z'_get_compact_format.<locals>.<listcomp>s��E�E�E��S��V�V�E�E�Err9T)�reverse�0r���1)r0rtr�r�is_nan�is_infinite�sortedr�r�r�rr6�roundr;)	r�r�r r�r��	magnituder��roundedr;s	         rr�r�	s����f�g�o�.�.�.����V���-�-��
�}�}����&�,�,�.�.���t�|��
�F��E�E�^�G�-D�E�E�E�t�T�T�T���	��v�;�;�)�#�#�#�G�,�S��^�^�<�F�#�F�+�+�3�G��#�~�~����'�/�6�Y�2�'�-�-�X[�J\�J\�_`�J`�Ca�5b�+c�d�d�F��F�O�4�4�G� �,�,�S��[�[�9�9�K��.�0�0�%����{�{�s�n�4�4�!��#�K�0��Y���@�F��F��E�)$�*�6�>�rc��eZdZdZdS)�UnknownCurrencyFormatErrorz>Exception raised when an unknown currency format is requested.N)rrrrrrrr�r�1s������H�H�H�Hrr��standard�currency_digits�)Literal['name', 'standard', 'accounting']c	��|dkrt|||||||���Stj|��}|rt|��}n0	|j|}n!#t
$rt
|�d���d�wxYw|�||||||���S)u�
Return formatted currency value.

    >>> format_currency(1099.98, 'USD', locale='en_US')
    '$1,099.98'
    >>> format_currency(1099.98, 'USD', locale='es_CO')
    u'US$1.099,98'
    >>> format_currency(1099.98, 'EUR', locale='de_DE')
    u'1.099,98\xa0\u20ac'

    The format can also be specified explicitly.  The currency is
    placed with the '¤' sign.  As the sign gets repeated the format
    expands (¤ being the symbol, ¤¤ is the currency abbreviation and
    ¤¤¤ is the full name of the currency):

    >>> format_currency(1099.98, 'EUR', u'¤¤ #,##0.00', locale='en_US')
    u'EUR 1,099.98'
    >>> format_currency(1099.98, 'EUR', u'#,##0.00 ¤¤¤', locale='en_US')
    u'1,099.98 euros'

    Currencies usually have a specific number of decimal digits. This function
    favours that information over the given format:

    >>> format_currency(1099.98, 'JPY', locale='en_US')
    u'\xa51,100'
    >>> format_currency(1099.98, 'COP', u'#,##0.00', locale='es_ES')
    u'1.099,98'

    However, the number of decimal digits can be overridden from the currency
    information, by setting the last parameter to ``False``:

    >>> format_currency(1099.98, 'JPY', locale='en_US', currency_digits=False)
    u'\xa51,099.98'
    >>> format_currency(1099.98, 'COP', u'#,##0.00', locale='es_ES', currency_digits=False)
    u'1.099,98'

    If a format is not specified the type of currency format to use
    from the locale can be specified:

    >>> format_currency(1099.98, 'EUR', locale='en_US', format_type='standard')
    u'\u20ac1,099.98'

    When the given currency format type is not available, an exception is
    raised:

    >>> format_currency('1099.98', 'EUR', locale='root', format_type='unknown')
    Traceback (most recent call last):
        ...
    UnknownCurrencyFormatError: "'unknown' is not a known currency format type"

    >>> format_currency(101299.98, 'USD', locale='en_US', group_separator=False)
    u'$101299.98'

    >>> format_currency(101299.98, 'USD', locale='en_US', group_separator=True)
    u'$101,299.98'

    You can also pass format_type='name' to use long display names. The order of
    the number and currency name, along with the correct localized plural form
    of the currency name, is chosen according to locale:

    >>> format_currency(1, 'USD', locale='en_US', format_type='name')
    u'1.00 US dollar'
    >>> format_currency(1099.98, 'USD', locale='en_US', format_type='name')
    u'1,099.98 US dollars'
    >>> format_currency(1099.98, 'USD', locale='ee', format_type='name')
    u'us ga dollar 1,099.98'

    By default the locale is allowed to truncate and round a high-precision
    number by forcing its format pattern onto the decimal part. You can bypass
    this behavior with the `decimal_quantization` parameter:

    >>> format_currency(1099.9876, 'USD', locale='en_US')
    u'$1,099.99'
    >>> format_currency(1099.9876, 'USD', locale='en_US', decimal_quantization=False)
    u'$1,099.9876'

    :param number: the number to format
    :param currency: the currency code
    :param format: the format string to use
    :param locale: the `Locale` object or locale identifier
    :param currency_digits: use the currency's natural number of decimal digits
    :param format_type: the currency format type to use
    :param decimal_quantization: Truncate and round high-precision numbers to
                                 the format pattern. Defaults to `True`.
    :param group_separator: Boolean to switch group separator on/off in a locale's
                            number format.

    �name)r�r r�r�r�z$ is not a known currency format typeN�r*r�r�r�)�_format_currency_long_namerr%r��currency_formats�KeyErrorr�r�)	r�r*r�r r�r�r�r�r�s	         r�format_currencyr�5s���B�f���)�&�(�6�17��?S�et�v�v�v�	v��\�&�
!�
!�F�
�o���'�'���	o��-�k�:�G�G���	o�	o�	o�,��-c�-c�-c�d�d�jn�n�	o�����=�=����?�1�?��T�T�Ts�
A�A0c�\�tj|��}t|t��rt	|��n|}t|||���}	t
|||���}
|s
|j|}t|��}|�	||||||���}|	�
||
��S)N)r6r r�)rr%r0r�floatrPrCr�r�r�r�)
r�r*r�r r�r�r�r��number_n�unit_pattern�display_namer��number_parts
             rr�r��s����\�&�
!�
!�F�!+�6�3� 7� 7�C�u�V�}�}�}�V�H�-�X�X�f�U�U�U�L�%�X�X�f�M�M�M�L��0��'��/���F�#�#�G��-�-����?�1�?� �T�T�K����{�L�9�9�9r�Literal['short']c��tj|��}	|j|}n%#t$r}t	|�d���|�d}~wwxYwt||||��\}}|�dt
|��vra|dD]X}|d|j}d|vr�tj	dd|��}tj	dd|���
��}|�td	���t|��}	|	�
|||d
d
���S)u�Format a number as a currency value in compact form.

    >>> format_compact_currency(12345, 'USD', locale='en_US')
    u'$12K'
    >>> format_compact_currency(123456789, 'USD', locale='en_US', fraction_digits=2)
    u'$123.46M'
    >>> format_compact_currency(123456789, 'EUR', locale='de_DE', fraction_digits=1)
    '123,5 Mio. €'

    :param number: the number to format
    :param currency: the currency code
    :param format_type: the compact format type to use. Defaults to "short".
    :param locale: the `Locale` object or locale identifier
    :param fraction_digits: Number of digits after the decimal point to use. Defaults to `0`.
    z, is not a known compact currency format typeN�¤r9u	[^0\s\¤]�z(\s)\s+z\1zANo compact currency format found for the given number and locale.F)r*r�r�)rr%�compact_currency_formatsr�r�r�rr��re�sub�stripr=r�r�)
r�r*r�r r�r��errorr�r�r�s
          r�format_compact_currencyr��s8��.�\�&�
!�
!�F�t��8��E�����t�t�t�(�K�)g�)g�)g�h�h�ns�s�����t����(�����Y�Y�N�F�F�
�~��S��[�[�0�0�'��0�	�	�I�#�G�,�Y�7�?�F��6�!�!���V�L�"�f�5�5�F��V�J��v�6�6�<�<�>�>�F��
�~��\�]�]�]��F�#�#�G��=�=���(�E�hm�=�n�n�ns�
$�
A�A�Ac��tj|��}|s
|j|}t|��}|�||||���S)uDReturn formatted percent value for a specific locale.

    >>> format_percent(0.34, locale='en_US')
    u'34%'
    >>> format_percent(25.1234, locale='en_US')
    u'2,512%'
    >>> format_percent(25.1234, locale='sv_SE')
    u'2\xa0512\xa0%'

    The format pattern can also be specified explicitly:

    >>> format_percent(25.1234, u'#,##0‰', locale='en_US')
    u'25,123‰'

    By default the locale is allowed to truncate and round a high-precision
    number by forcing its format pattern onto the decimal part. You can bypass
    this behavior with the `decimal_quantization` parameter:

    >>> format_percent(23.9876, locale='en_US')
    u'2,399%'
    >>> format_percent(23.9876, locale='en_US', decimal_quantization=False)
    u'2,398.76%'

    >>> format_percent(229291.1234, locale='pt_BR', group_separator=False)
    u'22929112%'

    >>> format_percent(229291.1234, locale='pt_BR', group_separator=True)
    u'22.929.112%'

    :param number: the percent number to format
    :param format:
    :param locale: the `Locale` object or locale identifier
    :param decimal_quantization: Truncate and round high-precision numbers to
                                 the format pattern. Defaults to `True`.
    :param group_separator: Boolean to switch group separator on/off in a locale's
                            number format.
    r�)rr%�percent_formatsr�r�r�s      r�format_percentr��s_��X�\�&�
!�
!�F��0��'��/���F�#�#�G��=�=���-A�Sb��d�d�drc��tj|��}|s
|j|}t|��}|�|||���S)a�Return value formatted in scientific notation for a specific locale.

    >>> format_scientific(10000, locale='en_US')
    u'1E4'

    The format pattern can also be specified explicitly:

    >>> format_scientific(1234567, u'##0.##E00', locale='en_US')
    u'1.23E06'

    By default the locale is allowed to truncate and round a high-precision
    number by forcing its format pattern onto the decimal part. You can bypass
    this behavior with the `decimal_quantization` parameter:

    >>> format_scientific(1234.9876, u'#.##E0', locale='en_US')
    u'1.23E3'
    >>> format_scientific(1234.9876, u'#.##E0', locale='en_US', decimal_quantization=False)
    u'1.2349876E3'

    :param number: the number to format
    :param format:
    :param locale: the `Locale` object or locale identifier
    :param decimal_quantization: Truncate and round high-precision numbers to
                                 the format pattern. Defaults to `True`.
    r�)rr%�scientific_formatsr�r�)r�r�r r�r�s     r�format_scientificr�3s[��>�\�&�
!�
!�F��3��*�6�2���F�#�#�G��=�=���-A��C�C�Crc�&��eZdZdZd
d�fd	�
Z�xZS)�NumberFormatErrorz>Exception raised when a string cannot be parsed into a number.N�messager�suggestions�list[str] | Nonerrc�X��t���|��||_dSr[)�superrr�)rr�r��	__class__s   �rrzNumberFormatError.__init__]s)���
������!�!�!�&����rr[)r�rr�r�rr)rrrrr�
__classcell__)r�s@rr�r�ZsH�������H�H�'�'�'�'�'�'�'�'�'�'�'rr��stringc��	t|�t|��d����S#t$r}t	|�d���|�d}~wwxYw)aSParse localized number string into an integer.

    >>> parse_number('1,099', locale='en_US')
    1099
    >>> parse_number('1.099', locale='de_DE')
    1099

    When the given string cannot be parsed, an exception is raised:

    >>> parse_number('1.099,98', locale='de')
    Traceback (most recent call last):
        ...
    NumberFormatError: '1.099,98' is not a valid number

    :param string: the string to parse
    :param locale: the `Locale` object or locale identifier
    :return: the parsed number
    :raise `NumberFormatError`: if the string can not be converted to a number
    r�z is not a valid numberN)rG�replacer�r=r�)r�r �ves   r�parse_numberr�csi��(M��6�>�>�"2�6�":�":�B�?�?�@�@�@���M�M�M��6� C� C� C�D�D�"�L�����M���s�/2�
A�A�A�strictc�l�tj|��}t|��}t|��}|s$|dkr||vrd|vr|�d|��}	tj|�|d���|d����}n*#t
j$r}t|�d���|�d}~wwxYw|r�||vr�t||d���}||kr�|�
d	��||zkr�	tj|�|d���|d����}t||d���}	|	|krt|�d
|�d�|g����t|�d
|�d
|	�d�||	g����#t
j$r}t|�d
|�d�|g���|�d}~wwxYw|S)akParse localized decimal string into a decimal.

    >>> parse_decimal('1,099.98', locale='en_US')
    Decimal('1099.98')
    >>> parse_decimal('1.099,98', locale='de')
    Decimal('1099.98')
    >>> parse_decimal('12 345,123', locale='ru')
    Decimal('12345.123')

    When the given string cannot be parsed, an exception is raised:

    >>> parse_decimal('2,109,998', locale='de')
    Traceback (most recent call last):
        ...
    NumberFormatError: '2,109,998' is not a valid decimal number

    If `strict` is set to `True` and the given string contains a number
    formatted in an irregular way, an exception is raised:

    >>> parse_decimal('30.00', locale='de', strict=True)
    Traceback (most recent call last):
        ...
    NumberFormatError: '30.00' is not a properly formatted decimal number. Did you mean '3.000'? Or maybe '30,00'?

    >>> parse_decimal('0.00', locale='de', strict=True)
    Traceback (most recent call last):
        ...
    NumberFormatError: '0.00' is not a properly formatted decimal number. Did you mean '0'?

    :param string: the string to parse
    :param locale: the `Locale` object or locale identifier
    :param strict: controls whether numbers formatted in a weird way are
                   accepted or rejected
    :raise NumberFormatError: if the string can not be converted to a
                              decimal number
    � � r�rz is not a valid decimal numberNF)r r�r�z: is not a properly formatted decimal number. Did you mean �?)r�z? Or maybe )rr%r�rxr�rtr��InvalidOperationr�r��rstrip)
r�r r��group_symbol�decimal_symbol�parsed�exc�proper�
parsed_alt�
proper_alts
          r�
parse_decimalr}s���J�\�&�
!�
!�F�#�F�+�+�L�'��/�/�N��3������F�"�"��v�
�
�����\�2�2��V�������b�!A�!A�(/����(D�(D�F�F�����#�V�V�V��6� K� K� K�L�L�RU�U�����V����
��,�&�(�(���v�E�R�R�R���V����
�
�c� 2� 2�v��7N� O� O�
�$�_�V�^�^�N�B�-O�-O�4;�G�L�#�4N�4N�P�P�
�,�J�v�\a�b�b�b�
���'�'�+�!�4�4�(.�4�4�4�%+�H�����,�!�M�M�(.�M�M�=G�M�M�M�%+�Z�$8�������+�
�
�
�'��0�0�$*�0�0�0�!'������	�����
����(�Ms0�<B�B>�&B9�9B>�<<F�F1�F,�,F1z
[^0-9@#.,]z[0-9@#.,E+]z(?P<prefix>(?:'[^']*'|%s)*)z(?P<number>%s*)z(?P<suffix>.*)�p�tuple[int, int]c���t|��}|�d��}|dkrdS||z
dz
}|d|dz
��d��}|dkr||fS||z
|z
dz
}||fS)z�Parse primary and secondary digit grouping

    >>> parse_grouping('##')
    (1000, 1000)
    >>> parse_grouping('#,###')
    (3, 3)
    >>> parse_grouping('#,####,###')
    (3, 4)
    r����)��r
r�N�)�len�rfind)r�width�g1�g2s    r�parse_groupingr�s���
��F�F�E�	
������B�	�R�x�x��z�	���a��B�	
�8�R�C�!�G�8��	�	�3�	�	�B�	�R�x�x��2�v�
�	���b��1�	�B�
�r�6�Mrr��NumberPattern | str�
NumberPatternc��t|t��r|Sd�}|}d|vr8|�dd��\}}||��\}}}||��\}}}	n||��\}}}d|��}|}	d|vr|�dd��\}}
nd}
d|vrd|vrd	|vrtd
���d|vr|�dd��\}}n|}d}d�}
|
|��}|
|��}|
r6|
�d
��}|
�d
��}
|
|
��}nd}d}t|��}t|||f||	f||||||�	�	S)zParse number format patternsc��t�|��}|�td|�����|���S)NzInvalid number pattern )�	number_re�searchr=�groups)r��rvs  r�
_match_numberz$parse_pattern.<locals>._match_number�s?��
�
�
�g�
&�
&��
�:��B�w�B�B�C�C�C��y�y�{�{�r�;r�rr�N�@rr�z5Significant digit patterns can not contain "@" or "0"r�c�`�dx}}|D]$}|dvr|dz
}|dz
}�|dkr|dz
}�|dkr�$||fS)z(Calculate the min and max allowed digitsrz@0r��#r�r)r�min�max�cs    r�parse_precisionz&parse_pattern.<locals>.parse_precisionsc���
��c��		�		�A��D�y�y��q����q�����c����q�����c������C�x�rr{)r0r�splitr=�rsplit�
startswith�lstripr)r�r�pos_pattern�neg_pattern�
pos_prefixr��
pos_suffix�
neg_prefix�_�
neg_suffix�exp�integer�fractionr"�int_prec�	frac_prec�exp_plus�exp_prec�groupings                   rr�r��s����'�=�)�)��������K��g�~�~�#*�=�=��a�#8�#8� ��[�)6��{�)C�)C�&�
�F�J�$1�M�+�$>�$>�!�
�A�z�z�)6��{�)C�)C�&�
�F�J�%��%�%�
��
�
�f�}�}��l�l�3��*�*�������
�f�}�}�����3�&�=�=��P�Q�Q�Q�
�f�}�}�"�M�M�#�q�1�1���������
�
�
���w�'�'�H����)�)�I�
���>�>�#�&�&���j�j��o�o��"�?�3�'�'��������g�&�&�H���:�z�":�$�j�1�8�!�9�!�8�V�5�5�5rc�h�eZdZ	d/d0d�Zd1d�Zd2d�Zd3d�Z					d4d5d%�Zd6d)�Zd7d,�Z	d8d-�Z
d/d9d.�ZdS):rNr�r�prefix�tuple[str, str]�suffixr5rr1r2r4�tuple[int, int] | Noner3�bool | None�number_patternr2rrc
��||_||_||_|	|_||_||_||_||_||_|�	��|_
dSr[)r�r7r9r<r5r1r2r4r3�
compute_scale�scale)
rr�r7r9r5r1r2r4r3r<s
          rrzNumberPattern.__init__3s[�����������,��� ��
� ��
�"��� ��
� ��
��'�'�)�)��
�
�
rc�B�dt|��j�d|j�d�S)N�<r��>)�typerr�)rs r�__repr__zNumberPattern.__repr__Ks&��:�4��:�:�&�:�:���:�:�:�:r�Literal[0, 2, 3]c��d}dd�|j|jz��vrd}n&dd�|j|jz��vrd}|S)uReturn the scaling factor to apply to the number before rendering.

        Auto-set to a factor of 2 or 3 if presence of a ``%`` or ``‰`` sign is
        detected in the prefix or suffix of the pattern. Default is to not mess
        with the scale at all and keep it to 0.
        r�%r�ru‰�)�joinr7r9)rr?s  rr>zNumberPattern.compute_scaleNsZ�����"�'�'�$�+���3�4�4�4�4��E�E�
�b�g�g�d�k�D�K�7�8�8�
8�
8��E��r�valuer�r r!� tuple[decimal.Decimal, int, str]c��|���}|t|��z}|���dksJ�tdt|j��g��dz
}||z
}|t|��z}d}|dkrt|��}n|jrt|��}t|��}|||fS)zG Returns normalized scientific notation components of a value.
        rr�r�)	�adjustedr�r rr1r�r3r|r�)rrJr r.�
lead_shift�exp_signs      r�scientific_notation_elementsz*NumberPattern.scientific_notation_elements\s����n�n�����+�C�0�0�0���~�~���1�$�$�$�$�
�!�S���/�/�0�1�1�A�5�
��J����+�Z�K�8�8�8������7�7�,�V�4�4�H�H�
�]�	4�+�F�3�3�H��#�h�h���c�8�#�#rTr�r*r�r.r��
force_fracr�c�"�t|tj��s!tjt|����}|�|j��}t
|�����}t|���	��}|j
r|�||��\}}	}
|rtj
dt��|}n|r|rt|��fdz}n|j}|r
|j
r2|dkr,|dt#|dt%|��g��f}|j
rvd�|�||||��t+|��|
|�t|	��|j
d|j
d|��g��}n�d|jvrv|�||jd|jd��}
|
�d��\}}}|�|dd	|��}|r|t7|��|zz
}n|�||||��}d�|j||jdkr|nd|j|g��}d
|vrs|�q|�dtA|||����}|�d
|�!����}|�d
tE||����}tGj$dd�|��}|S)aRenders into a string a number following the defined pattern.

        Forced decimal quantization is active by default so we'll produce a
        number string that is strictly following CLDR pattern definitions.

        :param value: The value to format. If this is not a Decimal object,
                      it will be cast to one.
        :type value: decimal.Decimal|float|int
        :param locale: The locale to use for formatting.
        :type locale: str|babel.core.Locale
        :param currency: Which currency, if any, to format as.
        :type currency: str|None
        :param currency_digits: Whether or not to use the currency's precision.
                                If false, the pattern's precision is used.
        :type currency_digits: bool
        :param decimal_quantization: Whether decimal numbers should be forcibly
                                     quantized to produce a formatted output
                                     strictly matching the CLDR definition for
                                     the locale.
        :type decimal_quantization: bool
        :param force_frac: DEPRECATED - a forced override for `self.frac_prec`
                           for a single formatting invocation.
        :return: Formatted decimal string.
        :rtype: str
        z@The force_frac parameter to NumberPattern.apply() is deprecated.r)rrrr�r�rrr
r�Nu¤¤¤u¤¤z	'([^']*)'c�0�|�d��pdS)Nr��')r�)r�s r�<lambda>z%NumberPattern.apply.<locals>.<lambda>�s������
�
�0A�c�r)%r0rtr�r�scalebr?rG�	is_signedr�r�r4rPr�r�r�rLr2r r�rI�_quantize_valuer��_format_intr��_format_significantr1�	partitionrxr7r<r9r�rCr4rFr�r�)rrJr r*r�r�rQr��is_negativer.rOr2r��text�a�sep�b�retvals                  rr�zNumberPattern.applyws��F�%���1�1�	0��O�C��J�J�/�/�E����T�Z�(�(���%�/�/�+�+�,�,���E�
�
�$�$�&�&���=�	T�#'�#D�#D�U�F�#S�#S� �E�3���	'��M�\�^p�q�q�q�"�I�I�
�	'�/�	'�/��9�9�<�q�@�I�I���I�$�	Z��
�	Z�)�v�:M�:M�"�1��s�I�a�L�:O�PU�:V�:V�+W�'X�'X�Y�I��=�	U��W�W��$�$�U�F�I��O�O�&�v�.�.��� � ��S���4�=��+;�T�]�1�=M�v�V�V�	���F�F��D�L�
 �
 ��+�+�E�,0�M�!�,<�,0�M�!�,<�>�>�D����s�+�+�I�A�s�A��%�%�a��D�&�9�9�F��
9��,�V�4�4�q�8�8����)�)�%���O�T�T�F�����K��$��)�R�/�/�F�F�R��K��$�&�'�'��
�6�>�>�h�2��^�^�H�.?��%�QW�.X�.X�Y�Y�F��^�^�F�H�N�N�,<�,<�=�=�F��^�^�D�*=�h��*O�*O�P�P�F����&A�&A�6�J�J���
r�minimumrG�maximumc	��|���}|dz
|z
}t|�|���t	jd������}|dkr
|d|zz}n�|d|�}t
|��}	|	t||	z
d��z}
d�|pddt|dzd��||	|
�||
d��
d������
d��}|S)Nr�rr�z-{intpart}.{pad:0<{fill}}{fracpart}{fracextra}r�)�intpart�pad�fill�fracpart�	fracextrar)rMrrV�quantizertr�rr r�rr�)rrJrbrcr.r?�digitsrpre�i�js           rrZz!NumberPattern._format_significant�s���n�n�����!��c�!���U�\�\�%�(�(�1�1�'�/�!�2D�2D�E�E�F�F���A�:�:��c�U�F�l�*�F�F��W�u�f�W�o�G��G���A��C��!��Q�'�'�'�A�D�K�K���3���#��'�1�o�o�%���!��� ����*�+�+�C�0�0�L����f�S�k�k�

��
rrr c�&�t|��}||krd||z
z|z}|jd}d}t|��}t|��|kr<|||d�z|z}|d|�}|jd}t|��|k�<||zS)Nr�rr�r�)rr5r�)	rrJrr r r�gsize�ret�symbols	         rrYzNumberPattern._format_int	s����E�
�
���3�;�;��3��;�'�%�/�E��
�a� ����!�&�)�)���%�j�j�5� � ��5�%����>�)�C�/�C��'�E�6�'�N�E��M�!�$�E��%�j�j�5� � ��s�{�rc�r�|���rt|��St|d��}|�|��}|d��d��\}}}	|}
|r.|�||jd|jd|��}
|
|�|	pd||��z}|S)Nr��frrr�)r�r�r�rjr[rYr1�_format_frac)rrJr r2r��quantumr�r^r_r`�integer_partr�s            rrXzNumberPattern._quantize_values��������	/�&�v�.�.�.�%�i��l�3�3���.�.��)�)���N�N�,�,�S�1�1�	��3�����	[��+�+�A�t�}�Q�/?���q�AQ�SY�Z�Z�L��� 1� 1�!�(�s�F�I� N� N�N���
rc�f�|p|j\}}t|��|kr|d|t|��z
zz
}|dks|dkrt|��dkrdSt|��|kr5|ddkr)|dd�}t|��|kr|ddk�)t|��|zS)Nr�rr�r	)r2rrGrx)rrJr rQrr s      rrtzNumberPattern._format_frac#s����/�����S��u�:�:�����c�S�3�u�:�:�-�.�/�E��!�8�8��q���S��Z�Z�1�_�_��2��%�j�j�3���5��9��#3�#3��#�2�#�J�E��%�j�j�3���5��9��#3�#3�!�&�)�)�E�1�1rr[)r�rr7r8r9r8r5rr1rr2rr4r:r3r;r<r2rr)rr)rrE)rJr�r r!rrK)NTTNT)rJr�r r!r*r2r�r.r�r.rQr:r�r.)rJr�rbrGrcrGrr)
rJrrrGr rGr r!rr)
rJr�r r!r2rr�r.rr)rJrr r!rQr:rr)rrrrrDr>rPr�rZrYrXrtrrrrr1s�������&*�*�*�*�*�*�0;�;�;�;�����$�$�$�$�> $� $�%)�-1� $�i�i�i�i�i�~����&��������2�2�2�2�2�2�2rr[)r r!rr")r*rr r!rr)r*rr r!rr.)r*rr r!rr2)r*rr6r7r r!rr)r*rr r!rr)r*rrrG).....)rQrrRrSrTrSrUr.rVr.rWrXrrY)rQrrRrSrTrSrUr.rVr.rWr_rr`)NNTFF)rQrrRrSrTrSrUr.rVr.rWr.rrb)r r!rr)r�r�r r!rr)r�r�rrG)r�r�rr�)r�r�r�r�r r!r�r.r�r.rr)
r�r�r�r�r r!r�rGrr)
r�r�r�rr rr�rGrr�)r�r�r*rr�r�r r!r�r.r�r�r�r.r�r.rr)r�r�r*rr�r�r r!r�rGrr)
r�r�r�r�r r!r�r.rr)r�rr r!rrG)r�rr r!r�r.rr�)rrrr)r�rrr)Ar�
__future__rrkrtr�r��typingrrrr�
babel.corerr	r
�babel.localedatar�typing_extensionsrr
rrr)r-r1r5rCrFrLrPr]rxr|r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r=r�r�r�
PREFIX_END�NUMBER_TOKEN�PREFIX_PATTERN�NUMBER_PATTERN�SUFFIX_PATTERN�compilerrr�rrrr�<module>r�s<����&#�"�"�"�"�"���������	�	�	�	�����5�5�5�5�5�5�5�5�5�5�5�5�9�9�9�9�9�9�9�9�9�9�+�+�+�+�+�+��*�)�)�)�)�)�)�
�^�L�
)�
)�
�%�%�%�%�%�9�%�%�%������$	-�	-�	-�	-�	-�����������"-1�",�2�2�2�2�2�BFP�	I�	I�	I�	I�	I�>�>�>�>� -1�",�8�8�8�8�8�D
�(+�%(���&)�
����
���
�(+�%(���%(�
����
���(,�%)���!�
\�\�\�\�\�~6@�C�C�C�C�C�8B�D�D�D�D�D�9C�E�E�E�E�E�:D�G�G�G�G�G�4>�A�A�A�A�A�7A�F�F�F�F�F�Xb�1�1�1�1�1�*'�'�'�'�/�/�/�/�*.�",�!%� �4d�4d�4d�4d�4d�t-4�",��"E�"E�"E�"E�"E�"E�J%�%�%�%�PI�I�I�I�I��I�I�I�*.�",� �=G�!%� �pT�pT�pT�pT�pT�l*.�",� �=G�!%� �%:�%:�%:�%:�%:�X%,�",��
,o�,o�,o�,o�,o�,o�b*.�",�!%� �1d�1d�1d�1d�1d�l.2�&0�%)�	$C�$C�$C�$C�$C�N'�'�'�'�'�
�'�'�'�=G�M�M�M�M�M�4>H�X]�P�P�P�P�P�f�
���/�*�<��#�l�2��"���B�J�.�J�.�J�.�J�J�K�K�	�����,>5�>5�>5�>5�Bz2�z2�z2�z2�z2�z2�z2�z2�z2�z2r