0x1949 Team - FAZEMRX - MANAGER
Edit File: units.cpython-310.pyc
o ^I+ � @ s� d dl mZ d dlmZ d dlmZmZ G dd� de�Zdefdd�Z efd d �Z ddefdd �Zefdd�Zdddddefdd�Z dS )� )�string_types)�Locale)�format_decimal� LC_NUMERICc @ s e Zd Zdd� ZdS )�UnknownUnitErrorc C s t �| d||f � d S )Nz%s is not a known unit in %s)� ValueError�__init__)�self�unit�locale� r �-/usr/lib/python3/dist-packages/babel/units.pyr s zUnknownUnitError.__init__N)�__name__� __module__�__qualname__r r r r r r s r �longc C s: t �|�}t| |d�}|st| |d��|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 �r r )r �parse�_find_unit_patternr �unit_display_names�get)�measurement_unit�lengthr r r r r � get_unit_name s r c C sH t �|�}|jd }| |v r| S t|td�D ]}|�| �r!| S qdS )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)r r �_data�sorted�len�endswith)�unit_idr r �unit_patternr r r r * s ��r Nc C s� t �|�}t||d�}|st||d��|jd | �|i �}t| t�r(| }d}nt| ||�}|� | �}||v r>|| � |�S d|t|||d�pH|f 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-inch-hg', locale='nb') u'1\xa0200 tommer kvikks\xf8lv' Number formats may be overridden with the ``format`` parameter. >>> from babel._compat 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 �onez%s %s)r r )r r r r r r � isinstancer r �plural_form�formatr ) �valuer r r&