a
    ¦Q•h“Z  ã                	   @  sJ  U d Z ddlmZ ddlZddlZddlmZmZ ddlm	Z	m
Z
mZ e	rVddlmZ dZdZd	d
dœdd„ZG dd„ dƒZdddœdd„Zdddœdd„Zdddœdd„Zd	dddœdd„Zd	dddœdd „Zd!d!d!d"œd#d$„ZG d%d&„ d&eƒZh d'£Zde d(ej¡fd)e d*d+ e¡› d,�¡fd-e d.¡fd/e d0¡fd1e d2ej¡fgZd3ed4< dd5d6œd7d8„Z ded5dd9d:d;œd<d=„Z!dfd5dd9d>œd?d@„Z"dAdBdCœdDdE„Z#ddFdGœdHdI„Z$ddJdKœdLdM„Z%dNdOdPœdQdR„Z&G dSdT„ dTƒZ'dUdV„ Z(dWdX„ Z)dYdZ„ Z*G d[d\„ d\ƒZ+G d]d^„ d^e+ƒZ,G d_d`„ d`e+ƒZ-G dadb„ dbe-ƒZ.G dcdd„ dde+ƒZ/dS )gz°
    babel.numbers
    ~~~~~~~~~~~~~

    CLDR Plural support.  See UTS #35.

    :copyright: (c) 2013-2024 by the Babel Team.
    :license: BSD, see LICENSE for more details.
é    )ÚannotationsN)ÚIterableÚMapping)ÚTYPE_CHECKINGÚAnyÚCallable)ÚLiteral)ÚzeroÚoneÚtwoÚfewÚmanyÚotherr   úfloat | decimal.DecimalzMtuple[decimal.Decimal | int, int, int, int, int, int, Literal[0], Literal[0]])ÚsourceÚreturnc                 C  sÞ   t | ƒ}t|ƒ}t|tƒr6||kr(|}nt t|ƒ¡}t|tjƒr²| ¡ }|j}|dk rf|j	|d… nd}d 
dd„ |D ƒ¡}| d¡}t|ƒ}t|ƒ}	t|p dƒ}
t|p¬dƒ}nd } }	 }
}d }}||||	|
|||fS )u÷  Extract operands from a decimal, a float or an int, according to `CLDR rules`_.

    The result is an 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]
    r   N© Ú c                 s  s   | ]}t |ƒV  qd S ©N©Ústr)Ú.0Údr   r   úE/var/www/sistema_ama/venv/lib/python3.9/site-packages/babel/plural.pyÚ	<genexpr>G   ó    z#extract_operands.<locals>.<genexpr>Ú0)ÚabsÚintÚ
isinstanceÚfloatÚdecimalÚDecimalr   Úas_tupleÚexponentÚdigitsÚjoinÚrstripÚlen)r   ÚnÚiZ	dec_tupleÚexpZfraction_digitsZtrailingZno_trailingÚvÚwÚfÚtÚcÚer   r   r   Úextract_operands   s&    

r2   c                   @  s˜   e Zd ZdZdZdddœdd„Zdd	œd
d„Zedd dœdd„ƒZe	dd	œdd„ƒZ
e	dd	œdd„ƒZdd	œdd„Zdddœdd„Zdddœdd„ZdS ) Ú
PluralRuleaf  Represents 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)Úrulesr   c                 C  sŒ   t |tƒr| ¡ }tƒ }g | _t|ƒD ]`\}}|tvrFtd|›�ƒ‚n||v r^td|›d�ƒ‚| |¡ t	|ƒj
}|r&| j ||f¡ q&dS )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 ztag z defined twiceN)r   r   ÚitemsÚsetr4   ÚsortedÚ_plural_tagsÚ
ValueErrorÚaddÚ_ParserÚastÚappend)Úselfr7   ÚfoundÚkeyÚexprr?   r   r   r   Ú__init__j   s    


zPluralRule.__init__r   )r   c                   s6   | j ‰ d ‡ fdd„tD ƒ¡}dt| ƒj› d|›d�S )Nú, c                   s&   g | ]}|ˆ v r|› d ˆ | › �‘qS )z: r   ©r   Útag©r7   r   r   Ú
<listcomp>‚   r   z'PluralRule.__repr__.<locals>.<listcomp>ú<ú ú>)r7   r&   r;   ÚtypeÚ__name__)rA   Úargsr   rI   r   Ú__repr__€   s    zPluralRule.__repr__ú:Mapping[str, str] | Iterable[tuple[str, str]] | PluralRulec                 C  s   t |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
        )r   r3   )Úclsr7   r   r   r   Úparse…   s    
zPluralRule.parsezMapping[str, str]c                   s   t ƒ j‰ ‡ fdd„| jD ƒS )zŸThe `PluralRule` as a dict of unicode plural rules.

        >>> rule = PluralRule({'one': 'n is 1'})
        >>> rule.rules
        {'one': 'n is 1'}
        c                   s   i | ]\}}|ˆ |ƒ“qS r   r   )r   rH   r?   ©Ú_compiler   r   Ú
<dictcomp>š   r   z$PluralRule.rules.<locals>.<dictcomp>)Ú_UnicodeCompilerÚcompiler4   ©rA   r   rU   r   r7   ‘   s    zPluralRule.ruleszfrozenset[str]c                 C  s   t dd„ | jD ƒƒ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.
        c                 s  s   | ]}|d  V  qdS )r   Nr   )r   r*   r   r   r   r   ¢   r   z"PluralRule.tags.<locals>.<genexpr>)Ú	frozensetr4   rZ   r   r   r   Útagsœ   s    zPluralRule.tagszlist[tuple[str, Any]]c                 C  s   | j S r   ©r4   rZ   r   r   r   Ú__getstate__¤   s    zPluralRule.__getstate__)r4   r   c                 C  s
   || _ d S r   r]   )rA   r4   r   r   r   Ú__setstate__§   s    zPluralRule.__setstate__r   )r)   r   c                 C  s   t | dƒst| ƒ| _|  |¡S )Nr5   )ÚhasattrÚ	to_pythonr5   )rA   r)   r   r   r   Ú__call__ª   s    

zPluralRule.__call__N)rO   Ú
__module__Ú__qualname__Ú__doc__Ú	__slots__rE   rQ   ÚclassmethodrT   Úpropertyr7   r\   r^   r_   rb   r   r   r   r   r3   S   s   
r3   rR   r   )Úruler   c                 C  sV   t ƒ j}dg}t | ¡jD ]"\}}| ||ƒ› d|›d�¡ q| dt ¡ 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   )Ú_JavaScriptCompilerrY   r3   rT   r4   r@   Ú_fallback_tagr&   )ri   Zto_jsÚresultrH   r?   r   r   r   Úto_javascript°   s    ro   z(Callable[[float | decimal.Decimal], str]c                 C  s†   t tttdœ}tƒ j}ddg}t | ¡jD ]&\}}| 	d||ƒ› dt
|ƒ›�¡ q*| 	dt›�¡ td |¡dd	ƒ}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
    )ÚINZWITHINÚMODr2   zdef evaluate(n):z- n, i, v, w, f, t, c, e = extract_operands(n)z if (z
): return z return Ú
z<rule>ÚexecÚevaluate)Úin_range_listÚwithin_range_listÚcldr_modulor2   Ú_PythonCompilerrY   r3   rT   r4   r@   r   rm   r&   Úeval)ri   Ú	namespaceZto_python_funcrn   rH   r?   Úcoder   r   r   ra   Ç   s    üþ 
ra   c                   s�   t  | ¡} | jthB ‰ tƒ j}‡ fdd„tD ƒj}dtˆ ƒ› d�g}| j	D ]&\}}| 
||ƒ› d||ƒ› d�¡ qJ| 
|tƒ› d�¡ 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
    c                   s   g | ]}|ˆ v r|‘qS r   r   rG   ©Z	used_tagsr   r   rJ   ý   r   zto_gettext.<locals>.<listcomp>z	nplurals=z
; plural=(rj   rk   z);r   )r3   rT   r\   rm   Ú_GettextCompilerrY   r;   Úindexr(   r4   r@   r&   )ri   rV   Z
_get_indexrn   rH   r?   r   r|   r   Ú
to_gettextï   s    

 r   z+Iterable[Iterable[float | decimal.Decimal]]Úbool)ÚnumÚ
range_listr   c                 C  s   | t | ƒkot| |ƒ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
    )r   rv   ©r�   r‚   r   r   r   ru     s    ru   c                   s   t ‡ fdd„|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
    c                 3  s"   | ]\}}ˆ |koˆ |kV  qd S r   r   )r   Zmin_Zmax_©r�   r   r   r   +  r   z$within_range_list.<locals>.<genexpr>)Úanyrƒ   r   r„   r   rv     s    rv   r    )ÚaÚbr   c                 C  s@   d}| dk r| d9 } d}|dk r(|d9 }| | }|r<|d9 }|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Úrvr   r   r   rw   .  s    rw   c                   @  s   e Zd ZdZdS )Ú	RuleErrorzRaised if a rule is malformed.N)rO   rc   rd   re   r   r   r   r   rŒ   E  s   rŒ   >   r)   r1   r.   r*   r-   r,   r/   r0   z\s+Úwordz"\b(and|or|is|(?:with)?in|not|mod|[r   z])\bÚvaluez\d+Úsymbolz%|,|!=|=Úellipsisz\.{2,3}|\u2026z(list[tuple[str | None, re.Pattern[str]]]Ú_RULESzlist[tuple[str, str]])Úsr   c                 C  sŒ   |   d¡d } g }d}t| ƒ}||k r~tD ]>\}}| | |¡}|d ur*| ¡ }|rd| || ¡ f¡  qq*td| | ›�ƒ‚q|d d d… S )Nú@r   z3malformed CLDR pluralization rule.  Got unexpected rˆ   )Úsplitr(   r‘   ÚmatchÚendr@   ÚgrouprŒ   )r’   rn   Úposr–   Útokri   r•   r   r   r   Útokenize_rule]  s    rš   z
str | Nonezlist[tuple[str, str]] | bool)ÚtokensÚtype_rŽ   r   c                 C  s,   | o*| d d |ko*|d u p*| d d |kS )Nrˆ   r   r‰   r   ©r›   rœ   rŽ   r   r   r   Útest_next_tokeno  s    ÿrž   r�   c                 C  s   t | ||ƒr|  ¡ S d S r   )rž   Úpopr�   r   r   r   Ú
skip_tokenx  s    r    r   z#tuple[Literal['value'], tuple[int]])rŽ   r   c                 C  s
   d| ffS )NrŽ   r   )rŽ   r   r   r   Ú
value_node}  s    r¡   ztuple[str, tuple[()]])Únamer   c                 C  s   | dfS )Nr   r   )r¢   r   r   r   Ú
ident_node�  s    r£   zItuple[Literal['range_list'], Iterable[Iterable[float | decimal.Decimal]]])r‚   r   c                 C  s   d| fS )Nr‚   r   )r‚   r   r   r   Úrange_list_node…  s    r¤   ztuple[Any, ...]z-tuple[Literal['not'], tuple[tuple[Any, ...]]])r‹   r   c                 C  s
   d| ffS )NÚnotr   )r‹   r   r   r   Únegate‹  s    r¦   c                   @  sb   e Zd ZdZdd„ Zddd„Zdd„ Zd	d
„ Zdd„ Zdd„ Z	dd„ Z
dd„ Zdd„ Zdd„ ZdS )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 instantiation into an attribute
    called `ast`.
    c                 C  sF   t |ƒ| _| jsd | _d S |  ¡ | _| jrBtd| jd d ›�ƒ‚d S )NzExpected end of rule, got rˆ   r‰   )rš   r›   r?   Ú	conditionrŒ   )rA   Ústringr   r   r   rE   ±  s    

z_Parser.__init__Nc                 C  sn   t | j||ƒ}|d ur|S |d u r6t|d u r0|p2|ƒ}| jsLtd|› d�ƒ‚td|› d| jd d ›�ƒ‚d S )Nz	expected z but end of rule reachedz	 but got rˆ   r‰   )r    r›   ÚreprrŒ   )rA   rœ   rŽ   ÚtermÚtokenr   r   r   Úexpect¼  s    z_Parser.expectc                 C  s,   |   ¡ }t| jddƒr(d||   ¡ ff}q|S )Nr�   Úor)Úand_conditionr    r›   ©rA   Úopr   r   r   r§   Æ  s    z_Parser.conditionc                 C  s,   |   ¡ }t| jddƒr(d||   ¡ ff}q|S )Nr�   Úand)Úrelationr    r›   r¯   r   r   r   r®   Ì  s    z_Parser.and_conditionc                 C  s¤   |   ¡ }t| jddƒr8t| jddƒr(dp*d||  ¡ ffS t| jddƒ}d}t| jddƒr^d}n$t| jddƒs‚|rxtdƒ‚|  |¡S d|||  ¡ ff}|r t|ƒS |S )	Nr�   Úisr¥   ZisnotÚinÚwithinz#Cannot negate operator based rules.r²   )rD   r    r›   rŽ   rŒ   Únewfangled_relationr‚   r¦   )rA   ÚleftÚnegatedÚmethodr‹   r   r   r   r²   Ò  s    
ÿ
z_Parser.relationc                 C  sR   t | jddƒrd}nt | jddƒr(d}ntdƒ‚dd||  ¡ ff}|rNt|ƒS |S )	Nr�   ú=Fz!=Tz'Expected "=" or "!=" or legacy relationr²   r´   )r    r›   rŒ   r‚   r¦   )rA   r·   r¸   r‹   r   r   r   r¶   ã  s    z_Parser.newfangled_relationc                 C  s,   |   ¡ }t| jdƒr ||   ¡ fS ||fS d S )Nr�   )rŽ   r    r›   )rA   r·   r   r   r   Úrange_or_valueí  s    z_Parser.range_or_valuec                 C  s0   |   ¡ g}t| jddƒr(| |   ¡ ¡ q
t|ƒS )Nr�   ú,)r»   r    r›   r@   r¤   )rA   r‚   r   r   r   r‚   ô  s    
z_Parser.range_listc                 C  s|   t | jdƒ}|d u s |d tvr(tdƒ‚|d }t | jddƒrRd|df|  ¡ ffS t | jddƒrtd|df|  ¡ ffS t|ƒS )Nr�   r‰   zExpected identifier variableÚmodr   r�   ú%)r    r›   Ú_VARSrŒ   rŽ   r£   )rA   r�   r¢   r   r   r   rD   ú  s    z_Parser.exprc                 C  s   t t|  d¡d ƒƒS )NrŽ   r‰   )r¡   r   r¬   rZ   r   r   r   rŽ     s    z_Parser.value)NN)rO   rc   rd   re   rE   r¬   r§   r®   r²   r¶   r»   r‚   rD   rŽ   r   r   r   r   r>   �  s   !


r>   c                   s   ‡ fdd„S )ú%Compiler factory for the `_Compiler`.c                   s   ˆ |   |¡|   |¡f S r   ©rY   )rA   r·   Úright©Útmplr   r   Ú<lambda>  r   z"_binary_compiler.<locals>.<lambda>r   rÃ   r   rÃ   r   Ú_binary_compiler	  s    rÆ   c                   s   ‡ fdd„S )rÀ   c                   s   ˆ |   |¡ S r   rÁ   )rA   ÚxrÃ   r   r   rÅ     r   z!_unary_compiler.<locals>.<lambda>r   rÃ   r   rÃ   r   Ú_unary_compiler  s    rÈ   c                 C  s   dS )Nr   r   ©rÇ   r   r   r   rÅ     r   rÅ   c                   @  s˜   e Zd ZdZdd„ Zdd„ Zdd„ Zdd„ Zdd„ Zd	d„ Z	d
d„ Z
dd„ Zdd„ Zdd„ ZedƒZedƒZedƒZedƒZedƒZedƒZdd„ ZdS )Ú	_CompilerzZThe compilers are able to transform the expressions into multiple
    output formats.
    c                 C  s   |\}}t | d|› �ƒ|Ž S )NZcompile_)Úgetattr)rA   Úargr°   rP   r   r   r   rY     s    z_Compiler.compilec                 C  s   dS )Nr)   r   rÉ   r   r   r   rÅ     r   z_Compiler.<lambda>c                 C  s   dS )Nr*   r   rÉ   r   r   r   rÅ      r   c                 C  s   dS )Nr,   r   rÉ   r   r   r   rÅ   !  r   c                 C  s   dS )Nr-   r   rÉ   r   r   r   rÅ   "  r   c                 C  s   dS )Nr.   r   rÉ   r   r   r   rÅ   #  r   c                 C  s   dS )Nr/   r   rÉ   r   r   r   rÅ   $  r   c                 C  s   dS )Nr0   r   rÉ   r   r   r   rÅ   %  r   c                 C  s   dS )Nr1   r   rÉ   r   r   r   rÅ   &  r   c                 C  s   t |ƒS r   r   )rÇ   r,   r   r   r   rÅ   '  r   z
(%s && %s)z
(%s || %s)z(!%s)z
(%s %% %s)z
(%s == %s)z
(%s != %s)c                 C  s
   t ƒ ‚d S r   )ÚNotImplementedError)rA   r¹   rD   r‚   r   r   r   Úcompile_relation/  s    z_Compiler.compile_relationN)rO   rc   rd   re   rY   Ú	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Î   r   r   r   r   rÊ     s$   rÊ   c                   @  s8   e Zd ZdZedƒZedƒZedƒZedƒZ	dd„ Z
dS )	rx   z!Compiles an expression to Python.z(%s and %s)z
(%s or %s)z(not %s)zMOD(%s, %s)c                   s<   d  ‡ fdd„|d D ƒ¡}| ¡ › dˆ  |¡› d|› d�S )Nr¼   c                   s.   g | ]&\}}d ˆ   |¡› dˆ   |¡› d�‘qS )ú(rF   ú)rÁ   )r   r†   r‡   rZ   r   r   rJ   <  r   z4_PythonCompiler.compile_relation.<locals>.<listcomp>r‰   rÛ   z, [z]))r&   ÚupperrY   )rA   r¹   rD   r‚   Úrangesr   rZ   r   rÎ   ;  s    z _PythonCompiler.compile_relationN)rO   rc   rd   re   rÆ   rÕ   rÖ   rÈ   r×   rØ   rÎ   r   r   r   r   rx   3  s   rx   c                   @  s.   e Zd ZdZejZeZeZ	eZ
eZdd„ ZdS )r}   z)Compile into a gettext plural expression.c                 C  s–   g }|   |¡}|d D ]l}|d |d krN| d|› d|   |d ¡› d�¡ qt| j |ƒ\}}| d|› d|› d|› d|› d�	¡ qdd	 |¡› d�S )
Nr‰   r   rÛ   z == rÜ   z >= ú && z <= z || )rY   r@   Úmapr&   )rA   r¹   rD   r‚   r‹   ÚitemÚminÚmaxr   r   r   rÎ   I  s    
$&z!_GettextCompiler.compile_relationN)rO   rc   rd   re   rÊ   rÏ   rÐ   Úcompile_zerorÑ   rÒ   rÓ   rÔ   rÎ   r   r   r   r   r}   @  s   r}   c                   @  s0   e Zd ZdZdd„ ZeZeZeZeZ	dd„ Z
dS )rl   z/Compiles the expression to plain of JavaScript.c                 C  s   dS )NzparseInt(n, 10)r   rÉ   r   r   r   rÅ   Z  r   z_JavaScriptCompiler.<lambda>c                 C  s>   t  | |||¡}|dkr:|  |¡}d|› d|› d|› d�}|S )Nr´   z
(parseInt(z	, 10) == rß   rÜ   )r}   rÎ   rY   )rA   r¹   rD   r‚   r{   r   r   r   rÎ   `  s    ÿ
z$_JavaScriptCompiler.compile_relationN)rO   rc   rd   re   rÐ   rä   rÑ   rÒ   rÓ   rÔ   rÎ   r   r   r   r   rl   U  s   rl   c                   @  sJ   e Zd ZdZedƒZedƒZedƒZedƒZedƒZ	dd„ Z
dd
d„ZdS )rX   z+Returns a unicode pluralization rule again.z%s is %sz%s is not %sz	%s and %sz%s or %sz	%s mod %sc                 C  s   | j |d ddiŽS )Nr‰   r¸   T)rÎ   )rA   r²   r   r   r   r×   v  s    z_UnicodeCompiler.compile_notFc              	   C  sŒ   g }|d D ]R}|d |d kr6|  |  |d ¡¡ q|  |  |d ¡› d|  |d ¡› �¡ q|  |¡› |rrdnd› d|› dd |¡› �S )Nr‰   r   z..z notr   rL   r¼   )r@   rY   r&   )rA   r¹   rD   r‚   r¸   rÞ   rá   r   r   r   rÎ   y  s    *z!_UnicodeCompiler.compile_relationN)F)rO   rc   rd   re   rÆ   rÙ   rÚ   rÕ   rÖ   rØ   r×   rÎ   r   r   r   r   rX   i  s   rX   )N)N)0re   Ú
__future__r   r!   ÚreÚcollections.abcr   r   Útypingr   r   r   Útyping_extensionsr   r;   rm   r2   r3   ro   ra   r   ru   rv   rw   Ú	ExceptionrŒ   r¿   rY   ÚUNICODEr&   r‘   Ú__annotations__rš   rž   r    r¡   r£   r¤   r¦   r>   rÆ   rÈ   rä   rÊ   rx   r}   rl   rX   r   r   r   r   Ú<module>   sT   	;](û	 ý	z