404

[ Avaa Bypassed ]




Upload:

Command:

elspacio@18.223.158.29: ~ $
3

rޖYX+�@s�ddlmZddlmZddlmZmZGdd�de�Zdefdd�Z	efd	d
�Z
ddefdd
�Zefdd�Zdddddefdd�Z
dS)�)�string_types)�Locale)�format_decimal�
LC_NUMERICc@seZdZdd�ZdS)�UnknownUnitErrorcCstj|d||f�dS)Nz%s is not a known unit in %s)�
ValueError�__init__)�self�unit�locale�r�/usr/lib/python3.6/units.pyr	szUnknownUnitError.__init__N)�__name__�
__module__�__qualname__rrrrr
rsrZlongcCs:tj|�}t||d�}|s&t||d��|jj|i�j|�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:
                             http://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_patternrZunit_display_names�get)�measurement_unit�lengthrr
rrr
�
get_unit_name
s

rcCsHtj|�}|jd}||kr |Sx"t|td�D]}|j|�r.|Sq.WdS)a�
    Expand an unit into a qualified form.

    Known units can be found in the CLDR Unit Validity XML file:
    http://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)Zunit_idrrZunit_patternrrr
r*s


rNc	Cs�tj|�}t||d�}|s&t||d��|jd|j|i�}t|t�rP|}d}nt|||�}|j	|�}||kr|||j
|�Sd|t|||d�p�|fS)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 \xb0C'

    The locale's usual pluralization rules are respected.

    >>> format_unit(1, 'length-meter', locale='ro_RO')
    u'1 metru'
    >>> format_unit(0, 'length-picometer', locale='cy')
    u'0 picometr'
    >>> format_unit(2, 'length-picometer', locale='cy')
    u'2 bicometr'
    >>> format_unit(3, 'length-picometer', locale='cy')
    u'3 phicometr'

    >>> 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:
                             http://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
rrZonez%s %s)rr)rrrrrr�
isinstancerr�plural_form�formatr)	�valuerrrrZq_unitrZformatted_valuerrrr
�format_unitDs-


r!cCsbtj|�}t||d�}t||d�}|o(|s.dS|jdd�d}|jdd�d}td||f|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
    )rN�-�z	%s-per-%s���r$)rrr�split)�numerator_unit�denominator_unitrZbare_numerator_unitZbare_denominator_unitrrr
�_find_compound_unit�s
r(r#cCstj|�}|r>|r>|dkr>t|||d�}|r>t|||||d�St|t�rN|}n&|rft|||||d�}nt|||d�}t|t�r�|}	np|r�|dkr�t||d�}|jdj	|i�j	|i�j	d�}
|
r�|
j
|�Sd}t|||||d�j�}	nt|||d�}	|jdj	di�j	|d	�}
|
j
||	�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 vuodessa'

    >>> 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 http://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.
    r#)r)rrr)rrrZper�Zcompound_unit_patternsz{0}/{1})rrr(r!rrrrrrr�strip)Znumerator_valuer&Zdenominator_valuer'rrrZ
compound_unitZformatted_numeratorZformatted_denominatorZper_patternrrr
�format_compound_unit�s21


 
r+)Z
babel._compatrZ
babel.corerZ
babel.numbersrrrrrrr!r(r+rrrr
�<module>sF1

Filemanager

Name Type Size Permission Actions
__init__.cpython-36.opt-1.pyc File 862 B 0644
__init__.cpython-36.pyc File 862 B 0644
_compat.cpython-36.opt-1.pyc File 1.79 KB 0644
_compat.cpython-36.pyc File 1.79 KB 0644
core.cpython-36.opt-1.pyc File 34.35 KB 0644
core.cpython-36.pyc File 34.35 KB 0644
dates.cpython-36.opt-1.pyc File 54.18 KB 0644
dates.cpython-36.pyc File 54.22 KB 0644
languages.cpython-36.opt-1.pyc File 3.01 KB 0644
languages.cpython-36.pyc File 3.01 KB 0644
lists.cpython-36.opt-1.pyc File 1.25 KB 0644
lists.cpython-36.pyc File 1.25 KB 0644
localedata.cpython-36.opt-1.pyc File 7.56 KB 0644
localedata.cpython-36.pyc File 7.56 KB 0644
numbers.cpython-36.opt-1.pyc File 21.58 KB 0644
numbers.cpython-36.pyc File 21.58 KB 0644
plural.cpython-36.opt-1.pyc File 21.48 KB 0644
plural.cpython-36.pyc File 21.48 KB 0644
support.cpython-36.opt-1.pyc File 22.1 KB 0644
support.cpython-36.pyc File 22.1 KB 0644
units.cpython-36.opt-1.pyc File 8.2 KB 0644
units.cpython-36.pyc File 8.2 KB 0644
util.cpython-36.opt-1.pyc File 9 KB 0644
util.cpython-36.pyc File 9 KB 0644