AlkantarClanX12

Your IP : 52.15.217.86


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__/units.cpython-311.pyc

�

j��fh.���ddlmZddlZddlmZddlmZddlmZm	Z	erddl
mZGd�de��Z
d	efd d�Zefd!d�Zd	defd"d�Zefd#d�Zdddd	defd$d�ZdS)%�)�annotationsN)�
TYPE_CHECKING)�Locale)�
LC_NUMERIC�format_decimal)�Literalc��eZdZd	d�ZdS)
�UnknownUnitError�unit�str�localer�return�Nonec�F�t�||�d|����dS)Nz is not a known unit in )�
ValueError�__init__)�selfrr
s   �k/builddir/build/BUILD/imunify360-venv-2.3.5/opt/imunify360/venv/lib/python3.11/site-packages/babel/units.pyrzUnknownUnitError.__init__s,�����D�T�"K�"K�6�"K�"K�L�L�L�L�L�N)rrr
rrr)�__name__�
__module__�__qualname__r�rrr
r

s.������M�M�M�M�M�Mrr
�long�measurement_unitr�length�"Literal['short', 'long', 'narrow']r
�Locale | str | Noner�
str | Nonec���tj|��}t||���}|st||����|j�|i���|��S)a�
    Get the display name for a measurement unit in the given locale.

    >>> get_unit_name("radian", locale="en")
    'radians'

    Unknown units will raise exceptions:

    >>> get_unit_name("battery", locale="fi")
    Traceback (most recent call last):
        ...
    UnknownUnitError: battery/long is not a known unit/length in fi

    :param measurement_unit: the code of a measurement unit.
                             Known units can be found in the CLDR Unit Validity XML file:
                             https://unicode.org/repos/cldr/tags/latest/common/validity/unit.xml

    :param length: "short", "long" or "narrow"
    :param locale: the `Locale` object or locale identifier
    :return: The unit display name, or None.
    �r
�rr
)r�parse�_find_unit_patternr
�unit_display_names�get)rrr
rs    r�
get_unit_namer'sj��4�\�&�
!�
!�F��.�v�>�>�>�D��E��$4�V�D�D�D�D��$�(�(��r�2�2�6�6�v�>�>�>r�unit_idc��tj|��}|jd}||vr|St|t���D]}|�|��r|cS�dS)a�
    Expand an unit into a qualified form.

    Known units can be found in the CLDR Unit Validity XML file:
    https://unicode.org/repos/cldr/tags/latest/common/validity/unit.xml

    >>> _find_unit_pattern("radian", locale="en")
    'angle-radian'

    Unknown values will return None.

    >>> _find_unit_pattern("horse", locale="en")

    :param unit_id: the code of a measurement unit.
    :return: A key to the `unit_patterns` mapping, or None.
    �
unit_patterns)�keyN)rr#�_data�sorted�len�endswith)r(r
r*�unit_patterns    rr$r$3s|��"�\�&�
!�
!�F��L��1�M��-������}�#�6�6�6� � ��� � ��)�)�	 �����	 � � r�value�float | decimal.Decimal�formatc��tj|��}t||���}|st||����|jd|�|i��}t
|t��r|}d}n&t|||��}|�	|��}||vr||�
|��St|||���}	|�d|	p|��S)a�Format a value of a given unit.

    Values are formatted according to the locale's usual pluralization rules
    and number formats.

    >>> format_unit(12, 'length-meter', locale='ro_RO')
    u'12 metri'
    >>> format_unit(15.5, 'length-mile', locale='fi_FI')
    u'15,5 mailia'
    >>> format_unit(1200, 'pressure-millimeter-ofhg', locale='nb')
    u'1\xa0200 millimeter kvikks\xf8lv'
    >>> format_unit(270, 'ton', locale='en')
    u'270 tons'

    Number formats may be overridden with the ``format`` parameter.

    >>> import decimal
    >>> format_unit(decimal.Decimal("-42.774"), 'temperature-celsius', 'short', format='#.0', locale='fr')
    u'-42,8\u202f\xb0C'

    The locale's usual pluralization rules are respected.

    >>> format_unit(1, 'length-meter', locale='ro_RO')
    u'1 metru'
    >>> format_unit(0, 'length-mile', locale='cy')
    u'0 mi'
    >>> format_unit(1, 'length-mile', locale='cy')
    u'1 filltir'
    >>> format_unit(3, 'length-mile', locale='cy')
    u'3 milltir'

    >>> format_unit(15, 'length-horse', locale='fi')
    Traceback (most recent call last):
        ...
    UnknownUnitError: length-horse is not a known unit in fi

    .. versionadded:: 2.2.0

    :param value: the value to format. If this is a string, no number formatting will be attempted.
    :param measurement_unit: the code of a measurement unit.
                             Known units can be found in the CLDR Unit Validity XML file:
                             https://unicode.org/repos/cldr/tags/latest/common/validity/unit.xml
    :param length: "short", "long" or "narrow"
    :param format: An optional format, as accepted by `format_decimal`.
    :param locale: the `Locale` object or locale identifier
    r!r"r*�one)rr
� )rr#r$r
r,r&�
isinstancerr�plural_formr3r')
r1rrr3r
�q_unitr*�formatted_valuer8�
fallback_names
          r�format_unitr<Ms���j�\�&�
!�
!�F�
� 0��
@�
@�
@�F��E��$4�V�D�D�D�D��L��1�&�9�=�=�f�b�I�I�M��%����0������(����?�?���(�(��/�/���m�#�#��[�)�0�0��A�A�A�"�"2�6�&�Q�Q�Q�M��C�C�
� A�1A�C�C�Cr�numerator_unit�denominator_unitc��tj|��}t||���}t||���}|r|sdS|�dd��d}|�dd��d}t|�d|��|���S)a�
    Find a predefined compound unit pattern.

    Used internally by format_compound_unit.

    >>> _find_compound_unit("kilometer", "hour", locale="en")
    'speed-kilometer-per-hour'

    >>> _find_compound_unit("mile", "gallon", locale="en")
    'consumption-mile-per-gallon'

    If no predefined compound pattern can be found, `None` is returned.

    >>> _find_compound_unit("gallon", "mile", locale="en")

    >>> _find_compound_unit("horse", "purple", locale="en")

    :param numerator_unit: The numerator unit's identifier
    :param denominator_unit: The denominator unit's identifier
    :param locale: the `Locale` object or locale identifier
    :return: A key to the `unit_patterns` mapping, or None.
    :rtype: str|None
    r!N�-����z-per-)rr#r$�split)r=r>r
�bare_numerator_unit�bare_denominator_units     r�_find_compound_unitrF�s���8�\�&�
!�
!�F�(��v�F�F�F�N�)�*:�6�J�J�J��
��/���t�
)�.�.�s�A�6�6�r�:��,�2�2�3��:�:�2�>���!4�R�R�;P�R�R�[a�b�b�b�brrA�numerator_value�denominator_valuec�d�tj|��}|r0|r.|dkr(t|||���}|rt|||||���St	|t
��r|}n)|rt|||||���}nt
|||���}t	|t
��r|}	n�|r�|dkrrt||���}|jd�	|i���	|i���	d��}
|
r|
�
|��Sd}t|||||������}	nt
|||���}	|jd�	di���	|i���	d	d
��}
|
�
||	��S)a�
    Format a compound number value, i.e. "kilometers per hour" or similar.

    Both unit specifiers are optional to allow for formatting of arbitrary values still according
    to the locale's general "per" formatting specifier.

    >>> format_compound_unit(7, denominator_value=11, length="short", locale="pt")
    '7/11'

    >>> format_compound_unit(150, "kilometer", denominator_unit="hour", locale="sv")
    '150 kilometer per timme'

    >>> format_compound_unit(150, "kilowatt", denominator_unit="year", locale="fi")
    '150 kilowattia / vuosi'

    >>> format_compound_unit(32.5, "ton", 15, denominator_unit="hour", locale="en")
    '32.5 tons per 15 hours'

    >>> format_compound_unit(160, denominator_unit="square-meter", locale="fr")
    '160 par m\xe8tre carr\xe9'

    >>> format_compound_unit(4, "meter", "ratakisko", length="short", locale="fi")
    '4 m/ratakisko'

    >>> format_compound_unit(35, "minute", denominator_unit="fathom", locale="sv")
    '35 minuter per famn'

    >>> from babel.numbers import format_currency
    >>> format_compound_unit(format_currency(35, "JPY", locale="de"), denominator_unit="liter", locale="de")
    '35\xa0\xa5 pro Liter'

    See https://www.unicode.org/reports/tr35/tr35-general.html#perUnitPatterns

    :param numerator_value: The numerator value. This may be a string,
                            in which case it is considered preformatted and the unit is ignored.
    :param numerator_unit: The numerator unit. See `format_unit`.
    :param denominator_value: The denominator value. This may be a string,
                              in which case it is considered preformatted and the unit is ignored.
    :param denominator_unit: The denominator unit. See `format_unit`.
    :param length: The formatting length. "short", "long" or "narrow"
    :param format: An optional format, as accepted by `format_decimal`.
    :param locale: the `Locale` object or locale identifier
    :return: A formatted compound value.
    rAr!)rr3r
)r3r
r*�per��compound_unit_patterns�compoundz{0}/{1})rr#rFr<r7rrr$r,r&r3�strip)rGr=rHr>rr3r
�
compound_unit�formatted_numerator�formatted_denominator�per_patterns           r�format_compound_unitrS�s��j�\�&�
!�
!�F��l�*�l�/@�A�/E�/E�+�N�<L�U[�\�\�\�
��	l���
�f�U[�dj�k�k�k�k��/�3�'�'�\�-���	�\�)��^�F�6�RX�
�
�
���-�_�V�TZ�[�[�[���#�S�)�)�`� 1���	�`���!�!�1�2B�6�R�R�R�� �,��7�;�;�<L�b�Q�Q�U�U�V\�^`�a�a�e�e�fk�l�l�K��
?�"�)�)�*=�>�>�>�!#�� +��/��v�V\�!
�!
�!
�
�%�'�'�	��!/�/@��X^� _� _� _���,�7�8�<�<�U�B�G�G�K�K�F�TV�W�W�[�[�\f�hq�r�r�K����1�3H�I�I�Ir)rrrrr
rrr)r(rr
rrr)r1r2rrrrr3rr
rrr)r=rr>rr
rrr)rGr2r=rrHr2r>rrrr3rr
rrr)�
__future__r�decimal�typingr�
babel.corer�
babel.numbersrr�typing_extensionsrrr
r'r$r<rFrSrrr�<module>rZs���"�"�"�"�"�"����� � � � � � �������4�4�4�4�4�4�4�4��*�)�)�)�)�)�)�M�M�M�M�M�z�M�M�M�28�",�?�?�?�?�?�BDN� � � � � �:28��",�ID�ID�ID�ID�ID�^#-�1c�1c�1c�1c�1c�l"&�12�#'�17��",�_J�_J�_J�_J�_J�_J�_Jr