shell bypass 403

Cubjrnet7 Shell


name : plural.cpython-39.pyc
a

�`BS�	@s�dZddlZddlmZdZdZdd�ZGdd	�d	e�Zd
d�Z	dd
�Z
dd�Zdd�Zdd�Z
dd�ZGdd�de�ZdZde�dej�fde�d�e��fde�d�fde�d�fd e�d!ej�fgZd"d#�ZdBd$d%�ZdCd&d'�Zd(d)�Zd*d+�Zd,d-�Zd.d/�ZGd0d1�d1e�Zd2d3�Zd4d5�Zd6d7�Z Gd8d9�d9e�Z!Gd:d;�d;e!�Z"Gd<d=�d=e!�Z#Gd>d?�d?e#�Z$Gd@dA�dAe!�Z%dS)Dz�
    babel.numbers
    ~~~~~~~~~~~~~

    CLDR Plural support.  See UTS #35.

    :copyright: (c) 2013-2021 by the Babel Team.
    :license: BSD, see LICENSE for more details.
�N)�decimal)ZzeroZoneZtwo�few�many�otherrcCs�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}}	}
}||||	|
|fS)a#Extract operands from a decimal, a float or an int, according to `CLDR rules`_.

    The result is a 6-tuple (n, i, v, w, f, t), 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.
    ====== ===============================================================

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

    :param source: A real number
    :type source: int|float|decimal.Decimal
    :return: A n-i-v-w-f-t tuple
    :rtype: tuple[decimal.Decimal, int, int, int, int, int]
    rN��css|]}t|�VqdS�N��str)�.0�drr�0/usr/lib/python3.9/site-packages/babel/plural.py�	<genexpr>A�z#extract_operands.<locals>.<genexpr>�0)
�abs�int�
isinstance�floatrZDecimalr
Zas_tupleZexponent�digits�join�rstrip�len)�source�n�iZ	dec_tupleZexpZfraction_digitsZtrailingZno_trailing�v�w�f�trrr
�extract_operandss$

r c@sdeZdZdZdZdd�Zdd�Zedd��Ze	d	d
��Z
e	dd�d
d�Zdd�Zdd�Z
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�_funccCs�t|t�r|��}t�}g|_tt|��D]Z\}}|tvrHtd|��n||vr\td|��|�	|�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
        zunknown tag %rztag %r defined twiceN)
r�dict�items�setr"�sorted�list�_plural_tags�
ValueError�add�_Parser�ast�append)�self�rules�found�key�exprr-rrr
�__init__cs


zPluralRule.__init__cs,|j�dt|�jd��fdd�tD��fS)Nz<%s %r>z, cs$g|]}|�vrd|�|f�qS)z%s: %sr�r�tag�r0rr
�
<listcomp>}s�z'PluralRule.__repr__.<locals>.<listcomp>)r0�type�__name__rr)�r/rr7r
�__repr__ys
�zPluralRule.__repr__cCst||�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
        )r)�clsr0rrr
�parse�s
zPluralRule.parsecs t�j�t�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'}
        csg|]\}}|�|�f�qSrr)rr6r-��_compilerr
r8�rz$PluralRule.rules.<locals>.<listcomp>)�_UnicodeCompiler�compiler$r"r;rr?r
r0�szPluralRule.rulescCstdd�|jD��S)NcSsg|]}|d�qS)rr)rrrrr
r8�rz'PluralRule.<lambda>.<locals>.<listcomp>)�	frozensetr"��xrrr
�<lambda>�rzPluralRule.<lambda>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.)�doccCs|jSr�r"r;rrr
�__getstate__�szPluralRule.__getstate__cCs
||_dSrrH)r/r"rrr
�__setstate__�szPluralRule.__setstate__cCst|d�st|�|_|�|�S)Nr#)�hasattr�	to_pythonr#)r/rrrr
�__call__�s

zPluralRule.__call__N)r:�
__module__�__qualname__�__doc__�	__slots__r4r<�classmethodr>�propertyr0�tagsrIrJrMrrrr
r!Ls


r!cCsRt�j}dg}t�|�jD]\}}|�d||�|f�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
%s ? %r : z%r; })r)�_JavaScriptCompilerrBr!r>r"r.�
_fallback_tagr)�ruleZto_js�resultr6r-rrr
�
to_javascript�srYcCs�ttttd�}t�j}ddg}t�|�jD]"\}}|�	d||�t
|�f�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 = extract_operands(n)z if (%s): return %rz
 return %r�
z<rule>�execZevaluate)�
in_range_list�within_range_list�cldr_modulor �_PythonCompilerrBr!r>r"r.r
rVr�eval)rW�	namespaceZto_python_funcrXr6r-�coderrr
rL�s��
rLcs�t�|�}|jthB�t�j}�fdd�tD�j}dt��g}|j	D]"\}}|�
d||�||�f�qF|�
d|t��d�|�S)a~The 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|�qSrrr5�Z	used_tagsrr
r8�rzto_gettext.<locals>.<listcomp>znplurals=%d; plural=(z
%s ? %d : z%d)r)r!r>rTrV�_GettextCompilerrBr)�indexrr"r.r)rWr@Z
_get_indexrXr6r-rrdr
�
to_gettext�s

rgcCs|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
    )rr^��num�
range_listrrr
r]�sr]cst�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_�rirr
r$rz$within_range_list.<locals>.<genexpr>)�anyrhrrkr
r^sr^cCs@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)�a�b�reverse�rvrrr
r_'sr_c@seZdZdZdS)�	RuleErrorzRaised if a rule is malformed.N)r:rNrOrPrrrr
rs>srsZnivwftz\s+�wordz)\b(and|or|is|(?:with)?in|not|mod|[{0}])\b�valuez\d+�symbolz%|,|!=|=�ellipsisz\.{2,3}|\u2026cCs�|�d�d}g}d}t|�}||kr|tD]>\}}|�||�}|dur*|��}|rd|�||��f�qq*td||��q|ddd�S)N�@rz5malformed CLDR pluralization rule.  Got unexpected %rrm)�splitr�_RULES�match�endr.�grouprs)�srX�posr|�tokrWr{rrr
�
tokenize_ruleMs �r�cCs,|o*|dd|ko*|dup*|dd|kS)Nrmrrnr��tokens�type_rurrr
�test_next_token`s�r�cCst|||�r|��SdSr)r��popr�rrr
�
skip_tokenesr�cCs
d|ffS)Nrur)rurrr
�
value_nodejsr�cCs|dfS)Nrr)�namerrr
�
ident_nodensr�cCsd|fS)Nrjr)rjrrr
�range_list_nodersr�cCs
d|ffS)N�notr)rrrrr
�negatevsr�c@sbeZdZdZdd�Zddd�Zdd�Zd	d
�Zdd�Zd
d�Z	dd�Z
dd�Zdd�Zdd�Z
dS)r,u�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 instanciation into an attribute
    called `ast`.
    cCsDt|�|_|jsd|_dS|��|_|jr@td|jdd��dS)NzExpected end of rule, got %rrmrn)r�r�r-�	conditionrs)r/�stringrrr
r4�s

�z_Parser.__init__NcCsft|j||�}|dur|S|dur6t|dur0|p2|�}|jsHtd|��td||jddf��dS)Nz#expected %s but end of rule reachedzexpected %s but got %rrmrn)r�r��reprrs)r/r�ruZterm�tokenrrr
�expect�sz_Parser.expectcCs,|��}t|jdd�r(d||��ff}q|S)Nrt�or)�
and_conditionr�r��r/�oprrr
r��sz_Parser.conditioncCs,|��}t|jdd�r(d||��ff}q|S)Nrt�and)�relationr�r�r�rrr
r��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)	Nrt�isr�Zisnot�inZwithinz#Cannot negate operator based rules.r�)r3r�r�rurs�newfangled_relationrjr�)r/�left�negated�methodrrrrr
r��s
�
z_Parser.relationcCsRt|jdd�rd}nt|jdd�r(d}ntd��dd||��ff}|rNt|�S|S)	Nrv�=Fz!=Tz'Expected "=" or "!=" or legacy relationr�r�)r�r�rsrjr�)r/r�r�rrrrr
r��sz_Parser.newfangled_relationcCs,|��}t|jd�r ||��fS||fSdS)Nrw)rur�r�)r/r�rrr
�range_or_value�sz_Parser.range_or_valuecCs0|��g}t|jdd�r(|�|���q
t|�S)Nrv�,)r�r�r�r.r�)r/rjrrr
rj�s
z_Parser.range_listcCs|t|jd�}|dus |dtvr(td��|d}t|jdd�rRd|df|��ffSt|jdd�rtd|df|��ffSt|�S)NrtrnzExpected identifier variable�modrrv�%)r�r��_VARSrsrur�)r/rtr�rrr
r3�sz_Parser.exprcCstt|�d�d��S)Nrurn)r�rr�r;rrr
ru�sz
_Parser.value)NN)r:rNrOrPr4r�r�r�r�r�r�rjr3rurrrr
r,zs!


r,cs�fdd�S)�%Compiler factory for the `_Compiler`.cs�|�|�|�|�fSr�rB)r/�l�r�Ztmplrr
rF�rz"_binary_compiler.<locals>.<lambda>rr�rr�r
�_binary_compiler�sr�cs�fdd�S)r�cs�|�|�Srr�)r/rEr�rr
rF�rz!_unary_compiler.<locals>.<lambda>rr�rr�r
�_unary_compiler�sr�cCsdS)NrrrDrrr
rF�rrFc@s�eZdZdZdd�Zdd�Zdd�Zdd�Zdd�Zd	d�Z	d
d�Z
dd�Zed�Z
ed
�Zed�Zed�Zed�Zed�Zdd�ZdS)�	_CompilerzZThe compilers are able to transform the expressions into multiple
    output formats.
    cCs|\}}t|d|�|�S)NZcompile_)�getattr)r/�argr��argsrrr
rBsz_Compiler.compilecCsdS)NrrrDrrr
rFrz_Compiler.<lambda>cCsdS)NrrrDrrr
rFrcCsdS)NrrrDrrr
rF
rcCsdS)NrrrDrrr
rFrcCsdS)NrrrDrrr
rFrcCsdS)NrrrDrrr
rFrcCst|�Srr	)rErrrr
rFrz
(%s && %s)z
(%s || %s)z(!%s)z
(%s %% %s)�
(%s == %s)z
(%s != %s)cCs
t��dSr)�NotImplementedError)r/r�r3rjrrr
�compile_relationsz_Compiler.compile_relationN)r:rNrOrPrB�	compile_n�	compile_i�	compile_v�	compile_w�	compile_f�	compile_tZ
compile_valuer��compile_and�
compile_orr��compile_not�compile_mod�
compile_is�
compile_isnotr�rrrr
r�s r�c@s8eZdZdZed�Zed�Zed�Zed�Z	dd�Z
dS)	r`z!Compiles an expression to Python.z(%s and %s)z
(%s or %s)z(not %s)zMOD(%s, %s)cs8dd��fdd�|dD��}d|����|�|fS)Nz[%s]r�cs g|]}dtt�j|���qS)z(%s, %s))�tuple�maprB)rZrange_r;rr
r8's�z4_PythonCompiler.compile_relation.<locals>.<listcomp>rnz
%s(%s, %s))r�upperrB)r/r�r3rjZcompile_range_listrr;r
r�%s
���z _PythonCompiler.compile_relationN)r:rNrOrPr�r�r�r�r�r�r�rrrr
r`sr`c@s.eZdZdZejZeZeZ	eZ
eZdd�ZdS)rez)Compile into a gettext plural expression.c	Cs~g}|�|�}|dD]X}|d|dkrH|�d||�|d�f�qt|j|�\}}|�d||||f�qdd�|�S)Nrnrr�z(%s >= %s && %s <= %s)z(%s)z || )rBr.r�r)r/r�r3rjrr�item�min�maxrrr
r�6s 
�
�
z!_GettextCompiler.compile_relationN)
r:rNrOrPr�r�r��compile_zeror�r�r�r�r�rrrr
re-srec@s0eZdZdZdd�ZeZeZeZeZ	dd�Z
dS)rUz/Compiles the expression to plain of JavaScript.cCsdS)NzparseInt(n, 10)rrDrrr
rFOrz_JavaScriptCompiler.<lambda>cCs4t�||||�}|dkr0|�|�}d|||f}|S)Nr�z(parseInt(%s, 10) == %s && %s))rer�rB)r/r�r3rjrcrrr
r�Us�
z$_JavaScriptCompiler.compile_relationN)r:rNrOrPr�r�r�r�r�r�r�rrrr
rUJsrUc@sJeZdZdZed�Zed�Zed�Zed�Zed�Z	dd�Z
d
d
d�ZdS)rAz+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)Nrnr�T)r�)r/r�rrr
r�ksz_UnicodeCompiler.compile_notFcCsvg}|dD]D}|d|dkr6|�|�|d��q|�dtt|j|���qd|�|�|rddpfd|d�|�fS)Nrnrz%s..%sz
%s%s %s %sz notrr�)r.rBr�r�r)r/r�r3rjr�Zrangesr�rrr
r�ns
�z!_UnicodeCompiler.compile_relationN)F)r:rNrOrPr�r�r�r�r�r�r�r�rrrr
rA^srA)N)N)&rP�reZ
babel._compatrr)rVr �objectr!rYrLrgr]r^r_�	Exceptionrsr�rB�UNICODE�formatrzr�r�r�r�r�r�r�r,r�r�r�r�r`rerUrArrrr
�<module>sL	8](
��


{

© 2025 Cubjrnet7