403Webshell
Server IP : 127.0.0.1  /  Your IP : 216.73.216.109
Web Server : Apache/2.4.54 (Win64) OpenSSL/1.1.1q PHP/8.1.10
System : Windows NT DESKTOP-E5T4RUN 10.0 build 19045 (Windows 10) AMD64
User : SERVERWEB ( 0)
PHP Version : 8.1.10
Disable Function : NONE
MySQL : OFF |  cURL : ON |  WGET : OFF |  Perl : OFF |  Python : OFF |  Sudo : OFF |  Pkexec : OFF
Directory :  C:/cygwin64/lib/python3.9/site-packages/babel/__pycache__/

Upload File :
current_dir [ Writeable] document_root [ Writeable]

 

Command :


[ Back ]     

Current File : C:/cygwin64/lib/python3.9/site-packages/babel/__pycache__/plural.cpython-39.pyc
a


�4d�Z�	@sJUdZddlmZddlZddlZddlmZmZddlm	Z	m
Z
mZe	rVddlm
Z
dZdZd	d
d�dd
�ZGdd�d�Zddd�dd�Zddd�dd�Zddd�dd�Zd	ddd�dd�Zd	ddd�dd �Zd!d!d!d"�d#d$�ZGd%d&�d&e�Zhd'�Zde�d(ej�fd)e�d*d+�e��d,��fd-e�d.�fd/e�d0�fd1e�d2ej�fgZd3ed4<dd5d6�d7d8�Z ded5dd9d:d;�d<d=�Z!dfd5dd9d>�d?d@�Z"dAdBdC�dDdE�Z#ddFdG�dHdI�Z$ddJdK�dLdM�Z%dNdOdP�dQdR�Z&GdSdT�dT�Z'dUdV�Z(dWdX�Z)dYdZ�Z*Gd[d\�d\�Z+Gd]d^�d^e+�Z,Gd_d`�d`e+�Z-Gdadb�dbe-�Z.Gdcdd�dde+�Z/dS)gz�
    babel.numbers
    ~~~~~~~~~~~~~

    CLDR Plural support.  See UTS #35.

    :copyright: (c) 2013-2023 by the Babel Team.
    :license: BSD, see LICENSE for more details.
�)�annotationsN)�Iterable�Mapping)�
TYPE_CHECKING�Any�Callable)�Literal)ZzeroZoneZtwo�few�many�otherr�float | decimal.DecimalzMtuple[decimal.Decimal | int, int, int, int, int, int, Literal[0], Literal[0]])�source�returncCs�t|�}t|�}t|t�r6||kr(|}nt�t|��}t|tj�r�|��}|j}|dkrf|j	|d�nd}d�
dd�|D��}|�d�}t|�}t|�}	t|p�d�}
t|p�d�}nd}}	}
}d}}
||||	|
|||
fS)u�Extract operands from a decimal, a float or an int, according to `CLDR rules`_.

    The result is a 8-tuple (n, i, v, w, f, t, c, e), where those symbols are as follows:

    ====== ===============================================================
    Symbol Value
    ------ ---------------------------------------------------------------
    n      absolute value of the source number (integer and decimals).
    i      integer digits of n.
    v      number of visible fraction digits in n, with trailing zeros.
    w      number of visible fraction digits in n, without trailing zeros.
    f      visible fractional digits in n, with trailing zeros.
    t      visible fractional digits in n, without trailing zeros.
    c      compact decimal exponent value: exponent of the power of 10 used in compact decimal formatting.
    e      currently, synonym for ‘c’. however, may be redefined in the future.
    ====== ===============================================================

    .. _`CLDR rules`: https://www.unicode.org/reports/tr35/tr35-61/tr35-numbers.html#Operands

    :param source: A real number
    :type source: int|float|decimal.Decimal
    :return: A n-i-v-w-f-t-c-e tuple
    :rtype: tuple[decimal.Decimal, int, int, int, int, int, int, int]
    rN��css|]}t|�VqdS�N��str)�.0�drr�0/usr/lib/python3.9/site-packages/babel/plural.py�	<genexpr>G�z#extract_operands.<locals>.<genexpr>�0)
�abs�int�
isinstance�float�decimalZDecimalrZas_tupleZexponent�digits�join�rstrip�len)r
�n�iZ	dec_tupleZexpZfraction_digitsZtrailingZno_trailing�v�w�f�t�c�errr�extract_operandss&

r+c@s�eZdZdZdZddd�dd�Zdd	�d
d�Zeddd�d
d��Ze	dd	�dd��Z
e	dd	�dd��Zdd	�dd�Zddd�dd�Z
ddd�dd�ZdS) �
PluralRuleafRepresents a set of language pluralization rules.  The constructor
    accepts a list of (tag, expr) tuples or a dict of `CLDR rules`_. The
    resulting object is callable and accepts one parameter with a positive or
    negative number (both integer and float) for the number that indicates the
    plural form for a string and returns the tag for the format:

    >>> rule = PluralRule({'one': 'n is 1'})
    >>> rule(1)
    'one'
    >>> rule(2)
    'other'

    Currently the CLDR defines these tags: zero, one, two, few, many and
    other where other is an implicit default.  Rules should be mutually
    exclusive; for a given numeric value, only one rule should apply (i.e.
    the condition should only be true for one of the plural rule elements.

    .. _`CLDR rules`: https://www.unicode.org/reports/tr35/tr35-33/tr35-numbers.html#Language_Plural_Rules
    )�abstract�_funcz-Mapping[str, str] | Iterable[tuple[str, str]]�None)�rulesrcCs�t|t�r|��}t�}g|_t|�D]`\}}|tvrFtd|����n||vr^td|�d���|�|�t	|�j
}|r&|j�||f�q&dS)a$Initialize the rule instance.

        :param rules: a list of ``(tag, expr)``) tuples with the rules
                      conforming to UTS #35 or a dict with the tags as keys
                      and expressions as values.
        :raise RuleError: if the expression is malformed
        zunknown tag ztag z defined twiceN)rr�items�setr-�sorted�_plural_tags�
ValueError�add�_Parser�ast�append)�selfr0�found�key�exprr8rrr�__init__js


zPluralRule.__init__r)rcs6|j�d��fdd�tD��}dt|�j�d|�d�S)N�, cs&g|]}|�vr|�d�|���qS)z: r�r�tag�r0rr�
<listcomp>�rz'PluralRule.__repr__.<locals>.<listcomp>�<� �>)r0r r4�type�__name__)r:�argsrrBr�__repr__�szPluralRule.__repr__�:Mapping[str, str] | Iterable[tuple[str, str]] | PluralRulecCst|t�r|S||�S)a
Create a `PluralRule` instance for the given rules.  If the rules
        are a `PluralRule` object, that object is returned.

        :param rules: the rules as list or dict, or a `PluralRule` object
        :raise RuleError: if the expression is malformed
        )rr,)�clsr0rrr�parse�s
zPluralRule.parsezMapping[str, str]cst�j��fdd�|jD�S)z�The `PluralRule` as a dict of unicode plural rules.

        >>> rule = PluralRule({'one': 'n is 1'})
        >>> rule.rules
        {'one': 'n is 1'}
        csi|]\}}|�|��qSrr)rrAr8��_compilerr�
<dictcomp>�rz$PluralRule.rules.<locals>.<dictcomp>)�_UnicodeCompiler�compiler-�r:rrNrr0�szPluralRule.ruleszfrozenset[str]cCstdd�|jD��S)z�A set of explicitly defined tags in this rule.  The implicit default
        ``'other'`` rules is not part of this set unless there is an explicit
        rule for it.
        css|]}|dVqdS)rNr)rr$rrrr�rz"PluralRule.tags.<locals>.<genexpr>)�	frozensetr-rSrrr�tags�szPluralRule.tagszlist[tuple[str, Any]]cCs|jSr�r-rSrrr�__getstate__�szPluralRule.__getstate__)r-rcCs
||_dSrrV)r:r-rrr�__setstate__�szPluralRule.__setstate__r)r#rcCst|d�st|�|_|�|�S)Nr.)�hasattr�	to_pythonr.)r:r#rrr�__call__�s

zPluralRule.__call__N)rH�
__module__�__qualname__�__doc__�	__slots__r>rJ�classmethodrM�propertyr0rUrWrXr[rrrrr,Ss
r,rKr)�rulercCsVt�j}dg}t�|�jD]"\}}|�||��d|�d��q|�dt�d�|�S)a�Convert a list/dict of rules or a `PluralRule` object into a JavaScript
    function.  This function depends on no external library:

    >>> to_javascript({'one': 'n is 1'})
    "(function(n) { return (n == 1) ? 'one' : 'other'; })"

    Implementation detail: The function generated will probably evaluate
    expressions involved into range operations multiple times.  This has the
    advantage that external helper functions are not required and is not a
    big performance hit for these simple calculations.

    :param rule: the rules as list or dict, or a `PluralRule` object
    :raise RuleError: if the expression is malformed
    z(function(n) { return � ? � : z%r; })r)�_JavaScriptCompilerrRr,rMr-r9�
_fallback_tagr )rbZto_js�resultrAr8rrr�
to_javascript�srhz(Callable[[float | decimal.Decimal], str]cCs�ttttd�}t�j}ddg}t�|�jD]&\}}|�	d||��dt
|����q*|�	dt���td�|�dd	�}t
||�|d
S)a<Convert a list/dict of rules or a `PluralRule` object into a regular
    Python function.  This is useful in situations where you need a real
    function and don't are about the actual rule object:

    >>> func = to_python({'one': 'n is 1', 'few': 'n in 2..4'})
    >>> func(1)
    'one'
    >>> func(3)
    'few'
    >>> func = to_python({'one': 'n in 1,11', 'few': 'n in 3..10,13..19'})
    >>> func(11)
    'one'
    >>> func(15)
    'few'

    :param rule: the rules as list or dict, or a `PluralRule` object
    :raise RuleError: if the expression is malformed
    )�INZWITHINZMODr+zdef evaluate(n):z- n, i, v, w, f, t, c, e = extract_operands(n)z if (z
): return z return �
z<rule>�execZevaluate)�
in_range_list�within_range_list�cldr_modulor+�_PythonCompilerrRr,rMr-r9rrfr �eval)rb�	namespaceZto_python_funcrgrAr8�coderrrrZ�s�� 
rZcs�t�|�}|jthB�t�j}�fdd�tD�j}dt���d�g}|j	D]&\}}|�
||��d||��d��qJ|�
|t��d��d�|�S)	aThe plural rule as gettext expression.  The gettext expression is
    technically limited to integers and returns indices rather than tags.

    >>> to_gettext({'one': 'n is 1', 'two': 'n is 2'})
    'nplurals=3; plural=((n == 1) ? 0 : (n == 2) ? 1 : 2);'

    :param rule: the rules as list or dict, or a `PluralRule` object
    :raise RuleError: if the expression is malformed
    csg|]}|�vr|�qSrrr@�Z	used_tagsrrrC�rzto_gettext.<locals>.<listcomp>z	nplurals=z
; plural=(rcrdz);r)r,rMrUrf�_GettextCompilerrRr4�indexr"r-r9r )rbrOZ
_get_indexrgrAr8rrsr�
to_gettext�s

 rvz+Iterable[Iterable[float | decimal.Decimal]]�bool)�num�
range_listrcCs|t|�kot||�S)a�Integer range list test.  This is the callback for the "in" operator
    of the UTS #35 pluralization rule language:

    >>> in_range_list(1, [(1, 3)])
    True
    >>> in_range_list(3, [(1, 3)])
    True
    >>> in_range_list(3, [(1, 3), (5, 8)])
    True
    >>> in_range_list(1.2, [(1, 4)])
    False
    >>> in_range_list(10, [(1, 4)])
    False
    >>> in_range_list(10, [(1, 4), (6, 8)])
    False
    )rrm�rxryrrrrlsrlcst�fdd�|D��S)a�Float range test.  This is the callback for the "within" operator
    of the UTS #35 pluralization rule language:

    >>> within_range_list(1, [(1, 3)])
    True
    >>> within_range_list(1.0, [(1, 3)])
    True
    >>> within_range_list(1.2, [(1, 4)])
    True
    >>> within_range_list(8.8, [(1, 4), (7, 15)])
    True
    >>> within_range_list(10, [(1, 4)])
    False
    >>> within_range_list(10.5, [(1, 4), (20, 30)])
    False
    c3s"|]\}}�|ko�|kVqdSrr)rZmin_Zmax_�rxrrr+rz$within_range_list.<locals>.<genexpr>)�anyrzrr{rrmsrmr)�a�brcCs@d}|dkr|d9}d}|dkr(|d9}||}|r<|d9}|S)z�Javaish modulo.  This modulo operator returns the value with the sign
    of the dividend rather than the divisor like Python does:

    >>> cldr_modulo(-3, 5)
    -3
    >>> cldr_modulo(-3, -5)
    -3
    >>> cldr_modulo(3, 5)
    3
    r����r)r}r~�reverse�rvrrrrn.srnc@seZdZdZdS)�	RuleErrorzRaised if a rule is malformed.N)rHr\r]r^rrrrr�Esr�>r%r(r)r&r$r'r#r*z\s+�wordz"\b(and|or|is|(?:with)?in|not|mod|[rz])\b�valuez\d+�symbolz%|,|!=|=�ellipsisz\.{2,3}|\u2026z(list[tuple[str | None, re.Pattern[str]]]�_RULESzlist[tuple[str, str]])�srcCs�|�d�d}g}d}t|�}||kr|tD]>\}}|�||�}|dur*|��}|rd|�||��f�qq*td||��q|ddd�S)N�@rz5malformed CLDR pluralization rule.  Got unexpected %rr)�splitr"r��match�endr9�groupr�)r�rg�posr��tokrbr�rrr�
tokenize_rule]s �r�z
str | Nonezlist[tuple[str, str]] | bool)�tokens�type_r�rcCs,|o*|dd|ko*|dup*|dd|kS)Nrrr�r�r�r�r�rrr�test_next_tokenps�r�r�cCst|||�r|��SdSr)r��popr�rrr�
skip_tokenysr�rz#tuple[Literal['value'], tuple[int]])r�rcCs
d|ffS)Nr�r)r�rrr�
value_node~sr�ztuple[str, tuple[()]])�namercCs|dfS)Nrr)r�rrr�
ident_node�sr�zItuple[Literal['range_list'], Iterable[Iterable[float | decimal.Decimal]]])ryrcCsd|fS)Nryr)ryrrr�range_list_node�sr�ztuple[Any, ...]z-tuple[Literal['not'], tuple[tuple[Any, ...]]])r�rcCs
d|ffS)N�notr)r�rrr�negate�sr�c@sbeZdZdZdd�Zddd�Zdd�Zd	d
�Zdd�Zd
d�Z	dd�Z
dd�Zdd�Zdd�Z
dS)r7u�Internal parser.  This class can translate a single rule into an abstract
    tree of tuples. It implements the following grammar::

        condition     = and_condition ('or' and_condition)*
                        ('@integer' samples)?
                        ('@decimal' samples)?
        and_condition = relation ('and' relation)*
        relation      = is_relation | in_relation | within_relation
        is_relation   = expr 'is' ('not')? value
        in_relation   = expr (('not')? 'in' | '=' | '!=') range_list
        within_relation = expr ('not')? 'within' range_list
        expr          = operand (('mod' | '%') value)?
        operand       = 'n' | 'i' | 'f' | 't' | 'v' | 'w'
        range_list    = (range | value) (',' range_list)*
        value         = digit+
        digit         = 0|1|2|3|4|5|6|7|8|9
        range         = value'..'value
        samples       = sampleRange (',' sampleRange)* (',' ('…'|'...'))?
        sampleRange   = decimalValue '~' decimalValue
        decimalValue  = value ('.' value)?

    - Whitespace can occur between or around any of the above tokens.
    - Rules should be mutually exclusive; for a given numeric value, only one
      rule should apply (i.e. the condition should only be true for one of
      the plural rule elements).
    - The in and within relations can take comma-separated lists, such as:
      'n in 3,5,7..15'.
    - Samples are ignored.

    The translator parses the expression on instantiation into an attribute
    called `ast`.
    cCsFt|�|_|jsd|_dS|��|_|jrBtd|jdd����dS)NzExpected end of rule, got rr�)r�r�r8�	conditionr�)r:�stringrrrr>�s

z_Parser.__init__NcCsnt|j||�}|dur|S|dur6t|dur0|p2|�}|jsLtd|�d���td|�d|jdd����dS)Nz	expected z but end of rule reachedz	 but got rr�)r�r��reprr�)r:r�r�Zterm�tokenrrr�expect�sz_Parser.expectcCs,|��}t|jdd�r(d||��ff}q|S)Nr��or)�
and_conditionr�r��r:�oprrrr��sz_Parser.conditioncCs,|��}t|jdd�r(d||��ff}q|S)Nr��and)�relationr�r�r�rrrr��sz_Parser.and_conditioncCs�|��}t|jdd�r8t|jdd�r(dp*d||��ffSt|jdd�}d}t|jdd�r^d}n$t|jdd�s�|rxtd��|�|�Sd|||��ff}|r�t|�S|S)	Nr��isr�Zisnot�inZwithinz#Cannot negate operator based rules.r�)r=r�r�r�r��newfangled_relationryr�)r:�left�negated�methodr�rrrr��s
�
z_Parser.relationcCsRt|jdd�rd}nt|jdd�r(d}ntd��dd||��ff}|rNt|�S|S)	Nr��=Fz!=Tz'Expected "=" or "!=" or legacy relationr�r�)r�r�r�ryr�)r:r�r�r�rrrr��sz_Parser.newfangled_relationcCs,|��}t|jd�r ||��fS||fSdS)Nr�)r�r�r�)r:r�rrr�range_or_value�sz_Parser.range_or_valuecCs0|��g}t|jdd�r(|�|���q
t|�S)Nr��,)r�r�r�r9r�)r:ryrrrry�s
z_Parser.range_listcCs|t|jd�}|dus |dtvr(td��|d}t|jdd�rRd|df|��ffSt|jdd�rtd|df|��ffSt|�S)Nr�r�zExpected identifier variable�modrr��%)r�r��_VARSr�r�r�)r:r�r�rrrr=�sz_Parser.exprcCstt|�d�d��S)Nr�r�)r�rr�rSrrrr�sz
_Parser.value)NN)rHr\r]r^r>r�r�r�r�r�r�ryr=r�rrrrr7�s!


r7cs�fdd�S)�%Compiler factory for the `_Compiler`.cs�|�|�|�|�fSr�rR)r:r��right�Ztmplrr�<lambda>rz"_binary_compiler.<locals>.<lambda>rr�rr�r�_binary_compiler
sr�cs�fdd�S)r�cs�|�|�Srr�)r:�xr�rrr�rz!_unary_compiler.<locals>.<lambda>rr�rr�r�_unary_compilersr�cCsdS)Nrr�r�rrrr�rr�c@s�eZdZdZdd�Zdd�Zdd�Zdd�Zdd�Zd	d�Z	d
d�Z
dd�Zdd�Zd
d�Z
ed�Zed�Zed�Zed�Zed�Zed�Zdd�ZdS)�	_CompilerzZThe compilers are able to transform the expressions into multiple
    output formats.
    cCs|\}}t|d|���|�S)NZcompile_)�getattr)r:�argr�rIrrrrRsz_Compiler.compilecCsdS)Nr#rr�rrrr� rz_Compiler.<lambda>cCsdS)Nr$rr�rrrr�!rcCsdS)Nr%rr�rrrr�"rcCsdS)Nr&rr�rrrr�#rcCsdS)Nr'rr�rrrr�$rcCsdS)Nr(rr�rrrr�%rcCsdS)Nr)rr�rrrr�&rcCsdS)Nr*rr�rrrr�'rcCst|�Srr)r�r%rrrr�(rz
(%s && %s)z
(%s || %s)z(!%s)z
(%s %% %s)z
(%s == %s)z
(%s != %s)cCs
t��dSr)�NotImplementedError)r:r�r=ryrrr�compile_relation0sz_Compiler.compile_relationN)rHr\r]r^rR�	compile_n�	compile_i�	compile_v�	compile_w�	compile_f�	compile_tZ	compile_cZ	compile_eZ
compile_valuer��compile_and�
compile_orr��compile_not�compile_mod�
compile_is�
compile_isnotr�rrrrr�s$r�c@s8eZdZdZed�Zed�Zed�Zed�Z	dd�Z
dS)	roz!Compiles an expression to Python.z(%s and %s)z
(%s or %s)z(not %s)zMOD(%s, %s)cs<d��fdd�|dD��}|���d��|��d|�d�S)Nr�cs.g|]&\}}d��|��d��|��d��qS)�(r?�)r�)rr}r~rSrrrC=rz4_PythonCompiler.compile_relation.<locals>.<listcomp>r�r�z, [z]))r �upperrR)r:r�r=ry�rangesrrSrr�<sz _PythonCompiler.compile_relationN)rHr\r]r^r�r�r�r�r�r�r�rrrrro4sroc@s.eZdZdZejZeZeZ	eZ
eZdd�ZdS)rtz)Compile into a gettext plural expression.cCs�g}|�|�}|dD]l}|d|dkrN|�d|�d|�|d��d��qt|j|�\}}|�d|�d|�d|�d|�d�	�qdd	�|��d�S)
Nr�rr�z == r�z >= � && z <= z || )rRr9�mapr )r:r�r=ryr��item�min�maxrrrr�Js
$&z!_GettextCompiler.compile_relationN)
rHr\r]r^r�r�r��compile_zeror�r�r�r�r�rrrrrtAsrtc@s0eZdZdZdd�ZeZeZeZeZ	dd�Z
dS)rez/Compiles the expression to plain of JavaScript.cCsdS)NzparseInt(n, 10)rr�rrrr�[rz_JavaScriptCompiler.<lambda>cCs>t�||||�}|dkr:|�|�}d|�d|�d|�d�}|S)Nr�z
(parseInt(z	, 10) == r�r�)rtr�rR)r:r�r=ryrrrrrr�as�
z$_JavaScriptCompiler.compile_relationN)rHr\r]r^r�r�r�r�r�r�r�rrrrreVsrec@sJeZdZdZed�Zed�Zed�Zed�Zed�Z	dd�Z
d
d
d�ZdS)rQz+Returns a unicode pluralization rule again.z%s is %sz%s is not %sz	%s and %sz%s or %sz	%s mod %scCs|j|dddi�S)Nr�r�T)r�)r:r�rrrr�wsz_UnicodeCompiler.compile_notFc	Cs�g}|dD]R}|d|dkr6|�|�|d��q|�|�|d��d|�|d����q|�|��|rrdnd�d|�dd�|���S)Nr�rz..z notrrEr�)r9rRr )r:r�r=ryr�r�r�rrrr�zs*z!_UnicodeCompiler.compile_relationN)F)rHr\r]r^r�r�r�r�r�r�r�r�rrrrrQjsrQ)N)N)0r^Z
__future__rr�re�collections.abcrr�typingrrrZtyping_extensionsrr4rfr+r,rhrZrvrlrmrn�	Exceptionr�r�rR�UNICODEr r��__annotations__r�r�r�r�r�r�r�r7r�r�r�r�rortrerQrrrr�<module>sT	;](�	�	z


Youez - 2016 - github.com/yon3zu
LinuXploit