%PDF- %PDF-
Mini Shell

Mini Shell

Direktori : /lib/python3/dist-packages/babel/__pycache__/
Upload File :
Create Path :
Current File : //lib/python3/dist-packages/babel/__pycache__/numbers.cpython-312.pyc

�

ƪb'���0�dZddlZddlZddlmZmZddlZddlm	Z	m
Z
mZ	ee	d�ZGd�de�Zd0d�Zd0d	�Zd0d
�Zd0d�Zdefd�Zefd
�Zd�Zdefd�Z			d1d�Zefd�Zefd�Zefd�Zefd�Zefd�Zefd�Z d�Z!d�Z"deddfd�Z#Gd�de$�Z%deddddfd�Z&deddddfd �Z'deddfd!�Z(dedfd"�Z)Gd#�d$e*�Z+efd%�Z,edfd&�Z-d'Z.d(Z/d)e.zZ0d*e/zZ1d+Z2ejfe0�e1�e2���Z4d,�Z5d-�Z6Gd.�d/�Z7y#e
$reZY��wxYw)2a�
    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-2022 by the Babel Team.
    :license: BSD, see LICENSE for more details.
�N)�date�datetime)�default_locale�Locale�
get_global�
LC_NUMERICc��eZdZdZd�Zy)�UnknownCurrencyErrorzRException thrown when a currency is requested for which no data is available.
    c�D�tj|d|z�||_y)zkCreate the exception.
        :param identifier: the identifier string of the unsupported currency
        zUnknown currency %r.N)�	Exception�__init__�
identifier)�selfrs  �//usr/lib/python3/dist-packages/babel/numbers.pyr
zUnknownCurrencyError.__init__*s#��	���4�!7�*�!D�E�%���N)�__name__�
__module__�__qualname__�__doc__r
�rrr
r
&s���%rr
c��|r8tj|�jj�}t|�St	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)�localers  r�list_currenciesr4sG����\�\�&�)�4�4�9�9�;�
��z�?�� � 0�1�
��z�?�rc�4�|t|�vrt|��y)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)rr
��currencyrs  r�validate_currencyr"Fs!����v�.�.�"�8�,�,�/rc�b�|rt|t�sy	t||�y#t$rYywxYw)zy Returns `True` only if a currency is recognized by Babel.

    This method always return a Boolean and never raise.
    FT)�
isinstance�strr"r
r s  r�is_currencyr&Rs;��
�:�h��4����(�F�+��� ����s�"�	.�.c�`�t|t�r|j�}t||�sy|S)z�Returns the normalized sting 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)r$r%�upperr&r s  r�normalize_currencyr)`s,���(�C� ��>�>�#���x��(���Orc���tj|�}|�;|j|�}|jd}||vr||}||vr||Sd|vr|dS|jj||�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.
    �currency_names_plural�other)rr�plural_form�_datar�get)r!�countr�locr-�plural_names�currency_plural_namess       r�get_currency_namer4os����,�,�v�
�C����o�o�e�,���y�y�!8�9���|�#�$0��$:�!��3�3�,�[�9�9��/�/�,�W�5�5��>�>���h��1�1rc�`�tj|�jj||�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_symbolr7�s&���<�<���0�0�4�4�X�x�H�Hrc�H�td�}|j||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)rr/)r!�
precisionss  r�get_currency_precisionr<�s*���0�1�J��>�>�(�J�y�$9�:�1�=�=rc��tj|�}|�$|j|�}	|jd|S|jddS#t$rY�wxYw)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.
    �currency_unit_patternsr,)rrr-r.�LookupError)r!r0rr1r-s     r�get_currency_unit_patternr@�sk��$�,�,�v�
�C����o�o�e�,��	��9�9�5�6�{�C�C�
�9�9�-�.�w�7�7��	�	��	�s�A�	A�ATFc�����td�}��tj��n t�t�r�j������n t�t�r�j��|j
|j�d�}��fd�}g}	|D]Y\}
}}}
|rt|�}|rt|�}|
r|s|
r�#|s�&|||�s�0|r|	j|
|||
d���I|	j|
��[|	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_currenciesrc�4��|duxs|�kxr|duxs|�k\S�Nr)�start�end�end_date�
start_dates  ��r�
_is_activez,get_territory_currencies.<locals>._is_actives/�����
�2��(�!2�2��t��0�s�j�0�	2r)r!�from�to�tender)	r�date_�todayr$�	datetime_rr/r(�append)�	territoryrHrGrL�
non_tender�include_detailsr�cursrI�result�
currency_coderErF�	is_tenders ``           r�get_territory_currenciesrX�s����h�2�3�J����[�[�]�
�	�J�	�	*��_�_�&�
�����	�H�i�	(��=�=�?���>�>�)�/�/�+�R�0�D�2��F�04�-�,�
�u�c�9���5�M�E����+�C�
�6��:�J�u�c�4J���
�
� -�!��'�	���
�
�m�,�-�"�Mrc�`�tj|�jjdd�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
    �decimal�.�rr�number_symbolsr/�rs r�get_decimal_symbolr_s&���<�<���.�.�2�2�9�d�C�Crc�`�tj|�jjdd�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�+r\r^s r�get_plus_sign_symbolrc&s&���<�<���.�.�2�2�:�t�D�Drc�`�tj|�jjdd�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�-r\r^s r�get_minus_sign_symbolrg1s&���<�<���.�.�2�2�;��E�Erc�`�tj|�jjdd�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�Er\r^s r�get_exponential_symbolrk<s&���<�<���.�.�2�2�=�$�G�Grc�`�tj|�jjdd�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�,r\r^s r�get_group_symbolroGs&���<�<���.�.�2�2�7�D�A�Arc�P�tjdt�t||��S)afReturn the given number formatted for a specific locale.

    >>> format_number(1099, locale='en_US')
    u'1,099'
    >>> format_number(1099, locale='de_DE')
    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.r^)�warnings�warn�DeprecationWarning�format_decimal)�numberrs  r�
format_numberrvRs!��"
�M�M�?�AS�T��&��0�0rc��t|tj�sJ�|j�j	�}|j
dk\ryt
|j
�S)z�Return maximum precision of a decimal instance's fractional part.

    Precision is extracted from the fractional part only.
    r)r$rZ�Decimal�	normalize�as_tuple�exponent�abs)ru�
decimal_tuples  r�get_decimal_precisionr~gsQ���f�g�o�o�.�.�.��$�$�&�/�/�1�M�����"���}�%�%�&�&rc��t|tttjf�sJ�tjd�|zS)z<Return minimal quantum of a number, as defined by precision.�
)r$�int�longrZrx)�	precisions r�get_decimal_quantumr�ts3���i�#�t�W�_�_�!=�>�>�>��?�?�2��I�:�.�.rc��tj|�}|s|jj|�}t	|�}|j||||��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.
    ��decimal_quantization�group_separator)rr�decimal_formatsr/�
parse_pattern�apply�ru�formatrr�r��patterns      rrtrtzsY��T�\�\�&�
!�F���'�'�+�+�F�3���F�#�G��=�=���-A�Sb��d�drc��eZdZdZy)�UnknownCurrencyFormatErrorz>Exception raised when an unknown currency format is requested.N)rrrrrrrr�r��s��Hrr��standardc	��|dk(rt|||||||��Stj|�}|rt|�}n	|j|}|j||||||��S#t
$rt
d|z��wxYw)u�
Return formatted currency value.

    >>> format_currency(1099.98, 'USD', locale='en_US')
    u'$1,099.98'
    >>> format_currency(1099.98, 'USD', locale='es_CO')
    u'US$\xa01.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 overriden 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�currency_digitsr�r�z&%r is not a known currency format type�r!r�r�r�)�_format_currency_long_namerrr��currency_formats�KeyErrorr�r�)	rur!r�rr��format_typer�r�r�s	         r�format_currencyr��s���t�f��)�&�(�6�17��?S�et�v�	v��\�\�&�
!�F�
���'��	H��-�-�k�:�G�
�=�=����?�1�?��T�T��	�	H�,�8�;�F�H�
H�	H�s�A"�"A:c�B�tj|�}t|t�rt	|�}n|}t|||��}	t
|||��}
|s|jj|�}t|�}|j||||||��}|	j||
�S)N)r0rr�)rrr$r%�floatr@r4r�r/r�r�r�)
rur!r�rr�r�r�r��number_n�unit_pattern�display_namer��number_parts
             rr�r�s���
�\�\�&�
!�F��&�#����=����-�X�X�f�U�L�%�X�X�f�M�L���'�'�+�+�F�3���F�#�G��-�-����?�1�?� �T�K����{�L�9�9rc��tj|�}|s|jj|�}t	|�}|j||||��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�r�s      r�format_percentr�AsY��N�\�\�&�
!�F���'�'�+�+�F�3���F�#�G��=�=���-A�Sb��d�drc��tj|�}|s|jj|�}t	|�}|j|||��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�)rur�rr�r�s     r�format_scientificr�psU��6�\�\�&�
!�F���*�*�.�.�v�6���F�#�G��=�=���-A��C�Crc�$��eZdZdZd�fd�	Z�xZS)�NumberFormatErrorz>Exception raised when a string cannot be parsed into a number.c�2��t�|�|�||_yrD)�superr
�suggestions)r�messager��	__class__s   �rr
zNumberFormatError.__init__�s���
����!�&��rrD)rrrrr
�
__classcell__)r�s@rr�r��s���H�'�'rr�c��	t|jt|�d��S#t$rt	d|z��wxYw)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
    �z%r is not a valid number)r��replacero�
ValueErrorr�)�stringrs  r�parse_numberr��sF��(E��6�>�>�"2�6�":�B�?�@�@���E�� :�V� C�D�D�E�s�#&�>c���tj|�}t|�}t|�}|s|dk(r||vrd|vr|j	d|�}	tj|j	|d�j	|d��}|r�||vr�t||d��}||k7r�|jd�||zk7ru	tj|j	|d�j	|d��}t||d��}||k(rt|�d	|�d
�|g���t|�d	|�d|�d
�||g���|S#t
j$rtd|z��wxYw#t
j$rt|�d	|�d
�|g���wxYw)
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�r[z %r is not a valid decimal numberF)rr��0z: is not a properly formatted decimal number. Did you mean �?)r�z? Or maybe )rrror_r�rZrx�InvalidOperationr�rt�rstrip)	r�r�strict�group_symbol�decimal_symbol�parsed�proper�
parsed_alt�
proper_alts	         r�
parse_decimalr��s���J�\�\�&�
!�F�#�F�+�L�'��/�N������F�"��v�
�����\�2��M��������b�!A�(/����(D�F���,�&�(���v�E�R���V���
�
�c� 2�v��7N� O�
9�$�_�_�V�^�^�N�B�-O�4;�G�L�#�4N�P�
�,�J�v�\a�b�
���'�+�#�V�-�$*�8�-�-�
,����5�$*�J�#7�9�9��M��3�#�#�M�� B�V� K�L�L�M���+�+�
)�'��V�%� &�x�)�)�
)�s�5D*�45E�*"E�(E7z
[^0-9@#.,]z[0-9@#.,E+]z(?P<prefix>(?:'[^']*'|%s)*)z(?P<number>%s*)z(?P<suffix>.*)c��t|�}|jd�}|dk(ry||z
dz
}|d|dz
jd�}|dk(r||fS||z
|z
dz
}||fS)z�Parse primary and secondary digit grouping

    >>> parse_grouping('##')
    (1000, 1000)
    >>> parse_grouping('#,###')
    (3, 3)
    >>> parse_grouping('#,####,###')
    (3, 4)
    rn���)��r��N�)�len�rfind)�p�width�g1�g2s    r�parse_groupingr�sx��
��F�E�	
�����B�	�R�x��	���a��B�	
�8�R�C�!�G��	�	�3�	�B�	�R�x��2�v�
�	���b��1�	�B�
�r�6�Mrc
�&�t|t�r|Sd�}|}d|vr.|jdd�\}}||�\}}}||�\}}}	n||�\}}}d|z}|}	d|vr|jdd�\}}
nd}
d|vrd|vrd	|vrtd
��d|vr|j	dd�\}}n|}d}d�}
|
|�}|
|�}|
r+|
jd
�}|
j
d
�}
|
|
�}nd}d}t|�}t|||f||	f|||||�S)zParse number format patternsc�l�tj|�}|�td|z��|j�S)NzInvalid number pattern %r)�	number_re�searchr��groups)r��rvs  r�
_match_numberz$parse_pattern.<locals>._match_number,s4��
�
�
�g�
&��
�:��8�7�B�C�C��y�y�{�r�;r�rfrjN�@r[r�z5Significant digit patterns can not contain "@" or "0"r�c�h�dx}}|D]&}|dvr|dz
}|dz
}�|dk(r|dz
}�|dk(r�#||fS||fS)z(Calculate the min and max allowed digitsrz@0r��#rnr)r��min�max�cs    r�parse_precisionz&parse_pattern.<locals>.parse_precisionKsd���
��c��		�A��D�y��q����q����c���q����c�����C�x��		��C�x�rrb)r$�
NumberPattern�splitr��rsplit�
startswith�lstripr�)r�r��pos_pattern�neg_pattern�
pos_prefixru�
pos_suffix�
neg_prefix�_�
neg_suffix�exp�integer�fractionr��int_prec�	frac_prec�exp_plus�exp_prec�groupings                   rr�r�'sj���'�=�)�����K��g�~�#*�=�=��a�#8� ��[�)6�{�)C�&�
�F�J�$1�+�$>�!�
�A�z�)6�{�)C�&�
�F�J��:�%�
��
�
�f�}��l�l�3��*������
�f�}��&�=�S�F�]��*�+�
+�
�f�}�"�M�M�#�q�1��������
��w�'�H���)�I�
��>�>�#�&���j�j��o��"�3�'�������g�&�H���:�z�":�$�j�1�8�!�9�!�8�-�-rc�P�eZdZd�Zd�Zd�Zd�Z					dd�Zd�Zd�Z	d	�Z
dd
�Zy)
r�c	��||_||_||_||_||_||_||_||_|j�|_	yrD)
r��prefix�suffixr�r�r�r�r��
compute_scale�scale)	rr�r�r�r�r�r�r�r�s	         rr
zNumberPattern.__init__lsL����������� ��
� ��
�"��� ��
� ��
��'�'�)��
rc�N�dt|�j�d|j�d�S)N�<r��>)�typerr�)rs r�__repr__zNumberPattern.__repr__ys�� ��J�/�/����>�>rc��d}ddj|j|jz�vrd}|Sddj|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�r�u‰�)�joinr�r�)rr�s  rr�zNumberPattern.compute_scale|s]�����"�'�'�$�+�+����3�4�4��E����r�w�w�t�{�{�T�[�[�8�9�
9��E��rc�J�|j�}|t|�z}|j�dk(sJ�tdt|j�g�dz
}||z
}|t|�z}d}|dkrt|�}n|jrt|�}t|�}|||fS)zG Returns normalized scientific notation components of a value.
        rr�r�)	�adjustedr�r�r�r�rgr�rcr|)r�valuerr��
lead_shift�exp_signs      r�scientific_notation_elementsz*NumberPattern.scientific_notation_elements�s����n�n����+�C�0�0���~�~��1�$�$�$�
�!�S����/�0�1�A�5�
��J����+�Z�K�8�8������7�,�V�4�H�
�]�]�+�F�3�H��#�h���c�8�#�#rNc�F�t|tj�stjt|��}|j	|j
�}t
|j��}t|�j�}|jr|j||�\}}	}
|rtjdt�|}n |r|rt|�fdz}n|j }|r|jr#|dk(r|dt#|dt%|�g�f}|jrfdj'|j)||||�t+|�
|j-t	�|jd|jd|�g�}n�d|j.vrj|j1||j2d|j2d�}
|
j5d�\}}}|j-|dd	|�}|r&|t7|�|zz
}n|j)||||�}dj'|j8|||j:|g�}d
|vrY|j=dt?|||��}|j=d|jA��}|j=d
tC||��}|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�r�r[r��¤u¤¤¤u¤¤)"r$rZrxr%�scalebr�r��	is_signedr|ryr�rrqrrrsr<r�r�r~r�_quantize_valuerk�_format_intr��_format_significantr��	partitionr_r�r�r�r4r(r7)rrrr!r�r��
force_fracr��is_negativer�rr�ru�text�a�sep�b�retvals                  rr�zNumberPattern.apply�st��F�%����1��O�O�C��J�/�E����T�Z�Z�(���%�/�/�+�,���E�
�$�$�&���=�=�#'�#D�#D�U�F�#S� �E�3����M�M�\�^p�q�"�I�
�/�/��9�<�q�@�I����I�$��
�
�)�v�:M�"�1��s�I�a�L�:O�PU�:V�+W�'X�Y�I��=�=��W�W��$�$�U�F�I��O�&�v�.��� � ���H�d�m�m�A�.��
�
�a�0@�&�J�	K�L�F��D�L�L�
 ��+�+�E�,0�M�M�!�,<�,0�M�M�!�,<�>�D����s�+�I�A�s�A��%�%�a��D�&�9�F���,�V�4�q�8�8���)�)�%���O�T�F�����K�K��$���K�K��$�&�'��
�F�?��^�^�I�$5�h��v�$N�P�F��^�^�G�X�^�^�-=�>�F��^�^�E�+>�x��+P�Q�F��
rc	��|j�}|dz
|z
}t|j|�jt	j
d���}|dkr|d|zz}|S|d|}t
|�}	|	t||	z
d�z}
dj|xsddt|dzd�||	|
||
djd���jd�}|S)Nr�rr�z-{intpart}.{pad:0<{fill}}{fracpart}{fracextra}r�)�intpart�pad�fill�fracpart�	fracextrar[)rr%r
�quantizerZrxr�r�r�r�r�)rr�minimum�maximumr�r��digitsrUr�i�js           rrz!NumberPattern._format_significant!s����n�n����!��c�!���U�\�\�%�(�1�1�'�/�/�!�2D�E�F���A�:��c�U�F�l�*�F��
��W�u�f�o�G��G��A��C��!��Q�'�'�A�D�K�K���3���#��'�1�o�%���!�� ���*�+�+�C�0�L���f�S�k�

��
rc��t|�}||krd||z
z|z}|jd}d}t|�}t|�|kDr0|||dz|z}|d|}|jd}t|�|kDr�0||zS)Nr�rr�r�)r�r�ro)	rrr�r�rr��gsize�ret�symbols	         rr
zNumberPattern._format_int4s����E�
���3�;��3��;�'�%�/�E��
�
�a� ����!�&�)���%�j�5� ��5�%���>�)�C�/�C��'�E�6�N�E��M�M�!�$�E��%�j�5� ��s�{�rc�$�t|d�}|j|�}dj|�jd�\}}}	|}
|r.|j	||j
d|j
d|�}
|
|j
|	xsd||�z}|S)Nr�z{:f}r[rr�)r�rr�rr
r��_format_frac)rrrr�r��quantum�roundedrrr�integer_partrus            rrzNumberPattern._quantize_valueAs���%�i��l�3���.�.��)���M�M�'�*�4�4�S�9�	��3������+�+�A�t�}�}�Q�/?����q�AQ�SY�Z�L��� 1� 1�!�(�s�F�I� N�N���
rc��|xs|j\}}t|�|kr|d|t|�z
zz
}|dk(s|dk(rt|�dk(ryt|�|kDr$|ddk(r|dd}t|�|kDr	|ddk(r�t|�|zS)Nr�rr�r�)r�r�r�r_)rrrrr�r�s      rr(zNumberPattern._format_fracKs����/������S��u�:����c�S�3�u�:�-�.�/�E��!�8��q��S��Z�1�_���%�j�3��5��9��#3��#�2�J�E��%�j�3��5��9��#3�!�&�)�E�1�1r)NTTNTrD)rrrr
r�r�rr�rr
rr(rrrr�r�jsB��*�?��$�>��!���f�x�&��2rr�rD)NNTFF)8rrZ�rerrrMrOrq�
babel.corerrrr��	NameErrorr�rrr
rr"r&r)r4r7r<r@rXr_rcrgrkrorvr~r�rtr�r�r�r�r�r�r�r�r�r��
PREFIX_END�NUMBER_TOKEN�PREFIX_PATTERN�NUMBER_PATTERN�SUFFIX_PATTERN�compiler�r�r�r�rrr�<module>r6s����&�	�9��9�9����L�
)�
�%�9�%��$	-���'+�:�2�4*4�	I�>�/3�:�8�<CG�5:�-2�W�t)�D�!+�E�",�F�#-�H�'�B�",�1�*
'�/��J�T�[_�/d�dI��I�
"&�j�$��T�4�jT�\"&�j�$��T�4�!:�J�J�T�[_�,d�`�J�T� C�F'�
�'�!+�E�4",�E�M�`�
���/�*�<��#�l�2��"���B�J�J�N�N�$2�4�
5�	��,@-�Fi2�i2��Y���D��s�D�D�D

Zerion Mini Shell 1.0