Ë
    ÆªbQV  ã            	       óP  — d Z ddlZddlZdZdZd„ Z G d„ d«      Zd„ Zd	„ Zd
„ Z	d„ Z
d„ Zd„ Z G d„ de«      Zh d£Zd ej                   dej"                  «      fd ej                   ddj%                  e«      › d�«      fd ej                   d«      fd ej                   d«      fd ej                   dej"                  «      fgZd„ Zd2d„Zd2d„Zd„ Zd „ Zd!„ Zd"„ Z G d#„ d$«      Zd%„ Zd&„ Zd'„ Z G d(„ d)«      Z G d*„ d+e«      Z  G d,„ d-e«      Z! G d.„ d/e!«      Z" G d0„ d1e«      Z#y)3z°
    babel.numbers
    ~~~~~~~~~~~~~

    CLDR Plural support.  See UTS #35.

    :copyright: (c) 2013-2022 by the Babel Team.
    :license: BSD, see LICENSE for more details.
é    N)ÚzeroÚoneÚtwoÚfewÚmanyÚotherr   c                 ó  — t        | «      }t        |«      }t        |t        «      r&||k(  r|}nt	        j
                  t        |«      «      }t        |t        j
                  «      r�|j                  «       }|j                  }|dk  r|j                  |d nd}dj                  d„ |D «       «      }|j                  d«      }t        |«      }t        |«      }	t        |xs d«      }
t        |xs d«      }ndx}x}	x}
}dx}}||||	|
|||fS )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]
    r   N© Ú c              3   ó2   K  — | ]  }t        |«      –— Œ y ­w©N©Ústr)Ú.0Úds     ú./usr/lib/python3/dist-packages/babel/plural.pyú	<genexpr>z#extract_operands.<locals>.<genexpr>A   s   è ø€ Ò; aœ3˜qŸ6Ñ;ùs   ‚Ú0)ÚabsÚintÚ
isinstanceÚfloatÚdecimalÚDecimalr   Úas_tupleÚexponentÚdigitsÚjoinÚrstripÚlen)ÚsourceÚnÚiÚ	dec_tupleÚexpÚfraction_digitsÚtrailingÚno_trailingÚvÚwÚfÚtÚcÚes                 r   Úextract_operandsr/      s  € ô2 	ˆF‹€AÜˆA‹€AÜ�!”UÔØ�Š6Ø‰Aô —‘¤ A£Ó'ˆAä�!”W—_‘_Ô%Ø—J‘J“Lˆ	Ø× Ñ ˆØ47¸!²G˜)×*Ñ*¨3¨4Ñ0ÀˆØ—7‘7Ñ;¨?Ô;Ó;ˆØ—o‘o cÓ*ˆÜ�‹MˆÜ�ÓˆÜ�’˜AÓˆÜ�Ò ˜qÓ!‰àÐˆÐˆAÐ��AØ€I€AˆØˆa��A�q˜!˜Q Ð!Ð!ó    c                   óh   — e Zd ZdZdZd„ Zd„ Zed„ «       Ze	d„ «       Z
 e	d„ d¬	«      Zd
„ Zd„ Zd„ Zy)Ú
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Ú_funcc                 óz  — t        |t        «      r|j                  «       }t        «       }g | _        t        t        |«      «      D ]s  \  }}|t        vrt        d|z  «      ‚||v rt        d|z  «      ‚|j                  |«       t        |«      j                  }|sŒW| j                  j                  ||f«       Œu y)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 %rztag %r defined twiceN)r   ÚdictÚitemsÚsetr3   ÚsortedÚlistÚ_plural_tagsÚ
ValueErrorÚaddÚ_ParserÚastÚappend)ÚselfÚrulesÚfoundÚkeyÚexprr?   s         r   Ú__init__zPluralRule.__init__d   s§   € ô �eœTÔ"Ø—K‘K“MˆEÜ“ˆØˆŒÜ¤ U£Ó,ò 	1‰IˆC�Øœ,Ñ&Ü Ð!1°CÑ!7Ó8Ð8Ø˜‘Ü Ð!7¸#Ñ!=Ó>Ð>Ø�I‰I�cŒNÜ˜$“-×#Ñ#ˆCÚØ—‘×$Ñ$ c¨3 ZÕ0ñ	1r0   c                 ó¶   — | j                   }dt        | «      j                  ›ddj                  t        D �cg c]  }||v r
|›d||   ›�‘Œ c}«      ›d�S c c}w )Nú<ú ú, z: ú>)rB   ÚtypeÚ__name__r   r;   )rA   rB   Útags      r   Ú__repr__zPluralRule.__repr__z   sW   € Ø—
‘
‰ä�‹J×ÓØ�I‰I¼|ö (¸Ø ™,ò $'¨¨cª
Ò3ò (õ )ð
ð 	
ùò(s   ·Ac                 ó.   — 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   )ÚclsrB   s     r   ÚparsezPluralRule.parse‚   s   € ô �e˜SÔ!ØˆLÙ�5‹zÐr0   c                 ó‚   — t        «       j                  }| j                  D ��ci c]  \  }}| ||«      “Œ c}}S c c}}w )zŸThe `PluralRule` as a dict of unicode plural rules.

        >>> rule = PluralRule({'one': 'n is 1'})
        >>> rule.rules
        {'one': 'n is 1'}
        )Ú_UnicodeCompilerÚcompiler3   )rA   Ú_compilerN   r?   s       r   rB   zPluralRule.rulesŽ   s7   € ô $Ó%×-Ñ-ˆØ37·=±=×A¡x s¨C�‘X˜c“]Ñ"ÓAÐAùÓAs   ¤;c                 ó:   — t        d„ | j                  D «       «      S )Nc              3   ó&   K  — | ]	  }|d    –— Œ y­w)r   Nr
   )r   r#   s     r   r   z&PluralRule.<lambda>.<locals>.<genexpr>™   s   è ø€ Ò'A°¨¨!­Ñ'Aùs   ‚)Ú	frozensetr3   ©Úxs    r   ú<lambda>zPluralRule.<lambda>™   s   € œiÑ'A°a·j±jÔ'AÓA€ r0   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.)Údocc                 ó   — | j                   S r   ©r3   ©rA   s    r   Ú__getstate__zPluralRule.__getstate__ž   s   € Ø�}‰}Ðr0   c                 ó   — || _         y r   r_   )rA   r3   s     r   Ú__setstate__zPluralRule.__setstate__¡   s	   € Ø ˆ�r0   c                 ó\   — t        | d«      st        | «      | _        | j                  |«      S )Nr4   )ÚhasattrÚ	to_pythonr4   )rA   r"   s     r   Ú__call__zPluralRule.__call__¤   s%   € Ü�t˜WÔ%Ü" 4›ˆDŒJØ�z‰z˜!‹}Ðr0   N)rM   Ú
__module__Ú__qualname__Ú__doc__Ú	__slots__rF   rO   ÚclassmethodrR   ÚpropertyrB   Útagsra   rc   rg   r
   r0   r   r2   r2   M   sf   „ ñð( &€Iò1ò,
ð ñ	ó ð	ð ñBó ðBñ ÑAð Hô €Dò
ò!ór0   r2   c                 ó
  — t        «       j                  }dg}t        j                  | «      j                  D ]"  \  }}|j                   ||«      ›d|›d�«       Œ$ |j                  dt        z  «       dj                  |«      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 ? z : z%r; })r   )Ú_JavaScriptCompilerrU   r2   rR   r3   r@   Ú_fallback_tagr   )ÚruleÚto_jsÚresultrN   r?   s        r   Úto_javascriptru   ª   sr   € ô  Ó!×)Ñ)€EØ&Ð'€FÜ×$Ñ$ TÓ*×3Ñ3ò 8‰ˆˆSØ�‰¡e¨C¥j²#Ð6Õ7ð8à
‡M�M�(œ]Ñ*Ô+Ø�7‰7�6‹?Ðr0   c           	      ó„  — t         t        t        t        dœ}t	        «       j
                  }ddg}t        j                  | «      j                  D ]+  \  }}|j                  d ||«      ›dt        |«      ›�«       Œ- |j                  dt        z  «       t        dj                  |«      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
    )ÚINÚWITHINÚMODr/   zdef evaluate(n):z- n, i, v, w, f, t, c, e = extract_operands(n)z if (z
): return z
 return %rú
z<rule>ÚexecÚevaluate)Úin_range_listÚwithin_range_listÚcldr_modulor/   Ú_PythonCompilerrU   r2   rR   r3   r@   r   rq   r   Úeval)rr   Ú	namespaceÚto_python_funcrt   rN   r?   Úcodes          r   rf   rf   Á   s·   € ô( Ü#ÜÜ,ñ	€Iô %Ó&×.Ñ.€NàØ7ð€Fô ×$Ñ$ TÓ*×3Ñ3ò O‰ˆˆSð 	�Š©~¸cÕ/BÄCÈÄHÐMÕNðOð ‡M�M�,¤Ñ.Ô/Ü�4—9‘9˜VÓ$ h°Ó7€DÜˆˆyÔØ�ZÑ Ð r0   c                 ó´  — t         j                  | «      } | j                  t        hz  }t	        «       j
                  }t        D �cg c]	  }||v sŒ|‘Œ c}j                  }dt        |«      z  g}| j                  D ]'  \  }}|j                  d ||«       ||«      fz  «       Œ) |j                  d |t        «      z  «       dj                  |«      S c c}w )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
    znplurals=%d; plural=(z
%s ? %d : z%d);r   )r2   rR   rn   rq   Ú_GettextCompilerrU   r;   Úindexr    r3   r@   r   )rr   Ú	used_tagsrV   rN   Ú
_get_indexrt   r?   s          r   Ú
to_gettextrŠ   é   sÁ   € ô ×Ñ˜DÓ!€Dà—	‘	œ]˜OÑ+€IÜÓ!×)Ñ)€HÜ!-ÖB˜#°¸	Ò1A’#ÒB×HÑH€Jà%¬¨I«Ñ6Ð7€FØ—M‘Mò G‰ˆˆSØ�‰�l¡h¨s£m±ZÀ³_Ð%EÑEÕFðGà
‡M�M�&™:¤mÓ4Ñ4Ô5Ø�7‰7�6‹?Ðùò Cs   Á	CÁCc                 ó:   — | t        | «      k(  xr 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   r~   ©ÚnumÚ
range_lists     r   r}   r}      s   € ð" ”#�c“(‰?ÒAÔ0°°jÓAÐAr0   c                 ó,   ‡ — t        ˆ f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   ó<   •K  — | ]  \  }}‰|k\  xr ‰|k  –— Œ y ­wr   r
   )r   Úmin_Úmax_r�   s      €r   r   z$within_range_list.<locals>.<genexpr>%  s%   øè ø€ ÒH©z¨t°Tˆs�d‰{Ò*˜s d™{Ó*ÑHùs   ƒ)ÚanyrŒ   s   ` r   r~   r~     s   ø€ ô" ÓH¸ZÔHÓHÐHr0   c                 óN   — d}| dk  r| dz  } d}|dk  r|dz  }| |z  }|r|dz  }|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Úrvs       r   r   r   (  sH   € ð €GØˆ1‚uØ	ˆR‰ˆØˆØˆ1‚uØ	ˆR‰ˆØ	
ˆQ‰€BÙØ
ˆb‰ˆØ€Ir0   c                   ó   — e Zd ZdZy)Ú	RuleErrorzRaised if a rule is malformed.N)rM   rh   ri   rj   r
   r0   r   rœ   rœ   ?  s   „ Ú(r0   rœ   >   r-   r.   r+   r#   r"   r,   r)   r*   z\s+Úwordz"\b(and|or|is|(?:with)?in|not|mod|[r   z])\bÚvaluez\d+Úsymbolz%|,|!=|=Úellipsisz\.{2,3}|\u2026c                 ó>  — | j                  d«      d   } g }d}t        | «      }||k  rnt        D ]N  \  }}|j                  | |«      }|€Œ|j	                  «       }|r!|j                  ||j                  «       f«        n t        d| |   z  «      ‚||k  rŒn|d d d…   S )Nú@r   z5malformed CLDR pluralization rule.  Got unexpected %rr•   )Úsplitr    Ú_RULESÚmatchÚendr@   Úgrouprœ   )Úsrt   Úposr¦   Útokrr   r¥   s          r   Útokenize_ruler«   V  s·   € Ø	�‰�‹�Q‰€AØ€FØ
€CÜ
ˆa‹&€CØ
�Š)Üò 		:‰IˆC�Ø—J‘J˜q #Ó&ˆEØÑ Ø—i‘i“k�ÙØ—M‘M 3¨¯©«Ð"6Ô7Ùð		:ô ð 0Ø23°C±&ñ9ó :ð :ð �‹)ð ‘$�B�$‰<Ðr0   c                 óF   — | xr | d   d   |k(  xr |d u xs | d   d   |k(  S )Nr•   r   r–   r
   ©ÚtokensÚtype_rž   s      r   Útest_next_tokenr°   i  s<   € Øò 2�f˜R‘j ‘m uÑ,ò 2Ø	�$ˆÒ	0˜& ™* Q™-¨5Ñ0ð2r0   c                 ó>   — t        | ||«      r| j                  «       S y r   )r°   Úpopr­   s      r   Ú
skip_tokenr³   n  s   € Ü�v˜u eÔ,Ø�z‰z‹|Ðð -r0   c                 ó   — d| ffS )Nrž   r
   )rž   s    r   Ú
value_noderµ   s  s   € Ø�U�IÐÐr0   c                 ó
   — | dfS )Nr
   r
   )Únames    r   Ú
ident_noder¸   w  s   € Ø�ˆ8€Or0   c                 ó
   — d| fS )NrŽ   r
   )rŽ   s    r   Úrange_list_noderº   {  s   € Ø˜Ð#Ð#r0   c                 ó   — d| ffS )NÚnotr
   )rš   s    r   Únegater½     s   € Ø�2�%ˆ<Ðr0   c                   óN   — e Zd ZdZd„ Zdd„Zd„ Zd„ Zd„ Zd„ Z	d	„ Z
d
„ Zd„ Zd„ Zy)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`.
    c                 óÊ   — t        |«      | _        | j                  sd | _        y | j                  «       | _        | j                  rt	        d| j                  d   d   z  «      ‚y )NzExpected end of rule, got %rr•   r–   )r«   r®   r?   Ú	conditionrœ   )rA   Ústrings     r   rF   z_Parser.__init__¥  s`   € Ü# FÓ+ˆŒØ�{Š{ð ˆDŒHØØ—>‘>Ó#ˆŒØ�;Š;ÜÐ:Ø ŸK™K¨™O¨AÑ.ñ/ó 0ð 0ð r0   Nc                 óÜ   — t        | j                  ||«      }|�|S |€t        |d u xr |xs |«      }| j                  st        d|z  «      ‚t        d|›d| j                  d   d   ›�«      ‚)Nz#expected %s but end of rule reachedz	expected z	 but got r•   r–   )r³   r®   Úreprrœ   )rA   r¯   rž   ÚtermÚtokens        r   Úexpectz_Parser.expect±  sq   € Ü˜4Ÿ;™;¨¨uÓ5ˆØÐØˆLØˆ<Ü˜ ˜Ò/¨%Ò8°5Ó9ˆDØ�{Š{ÜÐAÀDÑHÓIÐIÝ²D¸$¿+¹+Àb¹/È!Ò:LÐMÓNÐNr0   c                 ó¬   — | j                  «       }t        | j                  dd«      r,d|| j                  «       ff}t        | j                  dd«      rŒ,|S )Nr�   Úor)Úand_conditionr³   r®   ©rA   Úops     r   rÀ   z_Parser.condition»  sO   € Ø×ÑÓ!ˆÜ˜Ÿ™ f¨dÔ3Ø˜˜D×.Ñ.Ó0Ð1Ð1ˆBô ˜Ÿ™ f¨dÕ3àˆ	r0   c                 ó¬   — | j                  «       }t        | j                  dd«      r,d|| j                  «       ff}t        | j                  dd«      rŒ,|S )Nr�   Úand)Úrelationr³   r®   rÊ   s     r   rÉ   z_Parser.and_conditionÁ  sI   € Ø�]‰]‹_ˆÜ˜Ÿ™ f¨eÔ4Ø˜˜TŸ]™]›_Ð-Ð-ˆBô ˜Ÿ™ f¨eÕ4àˆ	r0   c                 óÊ  — | j                  «       }t        | j                  dd«      r1t        | j                  dd«      xr dxs d|| j                  «       ffS t        | j                  dd«      }d}t        | j                  dd«      rd}n5t        | j                  dd«      s|rt	        d«      ‚| j                  |«      S d||| j                  «       ff}|rt        |«      S |S )	Nr�   Úisr¼   ÚisnotÚinÚwithinz#Cannot negate operator based rules.rÎ   )rE   r³   r®   rž   rœ   Únewfangled_relationrŽ   r½   )rA   ÚleftÚnegatedÚmethodrš   s        r   rÎ   z_Parser.relationÇ  sÔ   € Ø�y‰y‹{ˆÜ�d—k‘k 6¨4Ô0Ü˜dŸk™k¨6°5Ó9ÒE¸gÒMÈØ�t—z‘z“|Ð$ð%ð %ä˜TŸ[™[¨&°%Ó8ˆØˆÜ�d—k‘k 6¨8Ô4Ø‰Fä˜dŸk™k¨6°4Ô8ÙÜ#Ð$IÓJÐJØ×/Ñ/°Ó5Ð5Ø˜& $¨¯©Ó(9Ð:Ð:ˆÙ$Œv�b‹zÐ,¨"Ð,r0   c                 óÈ   — t        | j                  dd«      rd}n%t        | j                  dd«      rd}nt        d«      ‚dd|| j                  «       ff}|rt	        |«      S |S )	NrŸ   ú=Fz!=Tz'Expected "=" or "!=" or legacy relationrÎ   rÒ   )r³   r®   rœ   rŽ   r½   )rA   rÕ   rÖ   rš   s       r   rÔ   z_Parser.newfangled_relationØ  sa   € Ü�d—k‘k 8¨SÔ1Ø‰GÜ˜Ÿ™ X¨tÔ4Ø‰GäÐEÓFÐFØ˜$  d§o¡oÓ&7Ð8Ð8ˆÙ$Œv�b‹zÐ,¨"Ð,r0   c                 óz   — | j                  «       }t        | j                  d«      r|| j                  «       fS ||fS )Nr    )rž   r³   r®   )rA   rÕ   s     r   Úrange_or_valuez_Parser.range_or_valueâ  s6   € Ø�z‰z‹|ˆÜ�d—k‘k :Ô.Ø˜Ÿ™›Ð%Ð%à˜�:Ðr0   c                 óÖ   — | j                  «       g}t        | j                  dd«      r7|j                  | j                  «       «       t        | j                  dd«      rŒ7t	        |«      S )NrŸ   ú,)rÛ   r³   r®   r@   rº   )rA   rŽ   s     r   rŽ   z_Parser.range_listé  sW   € Ø×)Ñ)Ó+Ð,ˆ
Ü˜Ÿ™ h°Ô4Ø×Ñ˜d×1Ñ1Ó3Ô4ô ˜Ÿ™ h°Õ4ä˜zÓ*Ð*r0   c                 ó2  — t        | j                  d«      }|�|d   t        vrt        d«      ‚|d   }t        | j                  dd«      rd|df| j	                  «       ffS t        | j                  dd«      rd|df| j	                  «       ffS t        |«      S )Nr�   r–   zExpected identifier variableÚmodr
   rŸ   ú%)r³   r®   Ú_VARSrœ   rž   r¸   )rA   r�   r·   s      r   rE   z_Parser.exprï  s–   € Ü˜$Ÿ+™+ vÓ.ˆØˆ<˜4 ™7¬%Ñ/ÜÐ:Ó;Ð;Ø�A‰wˆÜ�d—k‘k 6¨5Ô1Ø˜D "˜: t§z¡z£|Ð4Ð4Ð4Ü˜Ÿ™ X¨sÔ3Ø˜D "˜: t§z¡z£|Ð4Ð4Ð4Ü˜$ÓÐr0   c                 óN   — t        t        | j                  d«      d   «      «      S )Nrž   r–   )rµ   r   rÆ   r`   s    r   rž   z_Parser.valueú  s    € Üœ#˜dŸk™k¨'Ó2°1Ñ5Ó6Ó7Ð7r0   )NN)rM   rh   ri   rj   rF   rÆ   rÀ   rÉ   rÎ   rÔ   rÛ   rŽ   rE   rž   r
   r0   r   r>   r>   ƒ  s;   „ ñòB
0óOòòò-ò"-òò+ò	 ó8r0   r>   c                 ó   ‡ — ˆ fd„S )ú%Compiler factory for the `_Compiler`.c                 óN   •— ‰| j                  |«      | j                  |«      fz  S r   ©rU   )rA   ÚlÚrÚtmpls      €r   r\   z"_binary_compiler.<locals>.<lambda>   s!   ø€ ˜d d§l¡l°1£o°t·|±|ÀA³Ð%GÑG€ r0   r
   ©ré   s   `r   Ú_binary_compilerrë   þ  s	   ø€ ãGÐGr0   c                 ó   ‡ — ˆ fd„S )rä   c                 ó,   •— ‰| j                  |«      z  S r   ræ   )rA   r[   ré   s     €r   r\   z!_unary_compiler.<locals>.<lambda>  s   ø€ ˜4 $§,¡,¨q£/Ñ1€ r0   r
   rê   s   `r   Ú_unary_compilerrî     s	   ø€ ã1Ð1r0   c                  ó   — y)Nr   r
   rZ   s    r   r\   r\     ó   � r0   c                   ó²   — e Zd ZdZd„ Zd„ Zd„ Zd„ Zd„ Zd„ Z	d„ Z
d	„ Zd
„ Zd„ Z ed«      Z ed«      Z ed«      Z ed«      Z ed«      Z ed«      Zd„ Zy)Ú	_CompilerzZThe compilers are able to transform the expressions into multiple
    output formats.
    c                 ó0   — |\  }} t        | d|z   «      |Ž S )NÚcompile_)Úgetattr)rA   ÚargrË   Úargss       r   rU   z_Compiler.compile  s#   € Ø‰ˆˆDØ-Œw�t˜Z¨"™_Ó-¨tÐ4Ð4r0   c                  ó   — y)Nr"   r
   rZ   s    r   r\   z_Compiler.<lambda>  rð   r0   c                  ó   — y)Nr#   r
   rZ   s    r   r\   z_Compiler.<lambda>  rð   r0   c                  ó   — y)Nr)   r
   rZ   s    r   r\   z_Compiler.<lambda>  rð   r0   c                  ó   — y)Nr*   r
   rZ   s    r   r\   z_Compiler.<lambda>  rð   r0   c                  ó   — y)Nr+   r
   rZ   s    r   r\   z_Compiler.<lambda>  rð   r0   c                  ó   — y)Nr,   r
   rZ   s    r   r\   z_Compiler.<lambda>  rð   r0   c                  ó   — y)Nr-   r
   rZ   s    r   r\   z_Compiler.<lambda>  rð   r0   c                  ó   — y)Nr.   r
   rZ   s    r   r\   z_Compiler.<lambda>  rð   r0   c                 ó   — t        |«      S r   r   )r[   r)   s     r   r\   z_Compiler.<lambda>  s
   € ¤ Q£€ r0   z
(%s && %s)z
(%s || %s)z(!%s)z
(%s %% %s)z
(%s == %s)z
(%s != %s)c                 ó   — t        «       ‚r   )ÚNotImplementedError)rA   r×   rE   rŽ   s       r   Úcompile_relationz_Compiler.compile_relation$  s   € Ü!Ó#Ð#r0   N)rM   rh   ri   rj   rU   Ú	compile_nÚ	compile_iÚ	compile_vÚ	compile_wÚ	compile_fÚ	compile_tÚ	compile_cÚ	compile_eÚcompile_valuerë   Úcompile_andÚ
compile_orrî   Úcompile_notÚcompile_modÚ
compile_isÚcompile_isnotr  r
   r0   r   rò   rò     s|   „ ñò5ñ €IÙ€IÙ€IÙ€IÙ€IÙ€IÙ€IÙ€IÙ'€MÙ" <Ó0€KÙ! ,Ó/€JÙ! 'Ó*€KÙ" <Ó0€KÙ! ,Ó/€JÙ$ \Ó2€Mó$r0   rò   c                   óV   — e Zd ZdZ ed«      Z ed«      Z ed«      Z ed«      Z	d„ Z
y)r€   z!Compiles an expression to Python.z(%s and %s)z
(%s or %s)z(not %s)zMOD(%s, %s)c                 óæ   — ddj                  |d   D �cg c]$  }dt        t        | j                  |«      «      z  ‘Œ& c}«      z  }|j	                  «       ›d| j                  |«      ›d|›d�S c c}w )Nz[%s]rÝ   r–   z(%s, %s)ú(rJ   ú))r   ÚtupleÚmaprU   Úupper)rA   r×   rE   rŽ   Úrange_Úcompile_range_lists         r   r  z _PythonCompiler.compile_relation0  so   € Ø# c§h¡hà% a™=ö*Øð œ%¤ D§L¡L°&Ó 9Ó:Ó:ò *ó'+ñ +Ðð  &Ÿ|™|�~¨t¯|©|¸DÕ/AÚ1ð3ð 	3ùò*s   ”)A.
N)rM   rh   ri   rj   rë   r  r  rî   r  r  r  r
   r0   r   r€   r€   (  s2   „ Ù+á" =Ó1€KÙ! ,Ó/€JÙ! *Ó-€KÙ" =Ó1€Kó3r0   r€   c                   ó>   — e Zd ZdZej
                  ZeZeZ	eZ
eZd„ Zy)r†   z)Compile into a gettext plural expression.c                 ó>  — g }| j                  |«      }|d   D ]o  }|d   |d   k(  r+|j                  d|›d| j                  |d   «      ›d�«       Œ9t        | j                   |«      \  }}|j                  d|›d|›d|›d|›d�	«       Œq d	d
j                  |«      z  S )Nr–   r   r  z == r  z >= ú && z <= z(%s)z || )rU   r@   r  r   )rA   r×   rE   rŽ   rš   ÚitemÚminÚmaxs           r   r  z!_GettextCompiler.compile_relationA  s¤   € ØˆØ�|‰|˜DÓ!ˆØ˜q‘Mò 	ˆDØ�A‰w˜$˜q™'Ò!Ø—	’	ÚØ—L‘L  a¡Õ)ðõ ô
 ˜tŸ|™|¨TÓ2‘��SØ—	’	ÚÚÚÚð	õ ð	ð ˜Ÿ™ B›Ñ'Ð'r0   N)rM   rh   ri   rj   rò   r  r  Úcompile_zeror  r  r  r	  r  r
   r0   r   r†   r†   8  s)   „ Ù3à×#Ñ#€IØ€IØ€IØ€IØ€Ió(r0   r†   c                   ó,   — e Zd ZdZd„ ZeZeZeZeZ	d„ Z
y)rp   z/Compiles the expression to plain of JavaScript.c                  ó   — y)NzparseInt(n, 10)r
   rZ   s    r   r\   z_JavaScriptCompiler.<lambda>Z  rð   r0   c                 óz   — t         j                  | |||«      }|dk(  r| j                  |«      }d|›d|›d|›d�}|S )NrÒ   z
(parseInt(z	, 10) == r  r  )r†   r  rU   )rA   r×   rE   rŽ   r„   s        r   r  z$_JavaScriptCompiler.compile_relation`  sA   € Ü×0Ñ0Ø�&˜$ 
ó,ˆà�TŠ>Ø—<‘< Ó%‰DÚ7;ºTÂ4ÐHˆDØˆr0   N)rM   rh   ri   rj   r  r"  r  r  r  r	  r  r
   r0   r   rp   rp   U  s%   „ Ù9ñ ,€IØ€IØ€IØ€IØ€Iór0   rp   c                   ón   — e Zd ZdZ ed«      Z ed«      Z ed«      Z ed«      Z ed«      Z	d„ Z
d
d„Zy	)rT   z+Returns a unicode pluralization rule again.z%s is %sz%s is not %sz	%s and %sz%s or %sz	%s mod %sc                 ó,   —  | j                   |d   ddiŽS )Nr–   rÖ   T)r  )rA   rÎ   s     r   r  z_UnicodeCompiler.compile_notv  s   € Ø$ˆt×$Ñ$°H¸Q±KÐ@¨TÑ@Ð@r0   c           
      ó>  — g }|d   D ]b  }|d   |d   k(  r$|j                  | j                  |d   «      «       Œ2|j                  dt        t        | j                  |«      «      z  «       Œd | j                  |«      ›|xr dxs d›d|›ddj	                  |«      ›�S )Nr–   r   z%s..%sz notr   rI   rÝ   )r@   rU   r  r  r   )rA   r×   rE   rŽ   rÖ   Úrangesr  s          r   r  z!_UnicodeCompiler.compile_relationy  s›   € ØˆØ˜q‘Mò 	IˆDØ�A‰w˜$˜q™'Ò!Ø—‘˜dŸl™l¨4°©7Ó3Õ4à—‘˜h¬¬s°4·<±<ÀÓ/FÓ)GÑGÕHð		Ið �L‰L˜Ô Ò 2¨FÒ 8°bÑ 8Ú�C—H‘H˜VÔ$ð
ð 	
r0   N)F)rM   rh   ri   rj   rë   r  r  r  r  r  r  r  r
   r0   r   rT   rT   i  sD   „ Ù5ñ " *Ó-€JÙ$ ^Ó4€MÙ" ;Ó/€KÙ! *Ó-€JÙ" ;Ó/€KòAô

r0   rT   r   )$rj   r   Úrer;   rq   r/   r2   ru   rf   rŠ   r}   r~   r   Ú	Exceptionrœ   rá   rU   ÚUNICODEr   r¤   r«   r°   r³   rµ   r¸   rº   r½   r>   rë   rî   r"  rò   r€   r†   rp   rT   r
   r0   r   ú<module>r-     sj  ðñó Û 	ð >€Ø€ò8"÷vZñ Zòzò.%!òPò.Bò(Iò(ô.)�	ô )ò		€ð 
ˆ:ˆ2�:‰:�f˜bŸj™jÓ)Ð*ØˆZˆR�Z‰ZÐ=¸b¿g¹gÀe»nÐ=MÈTÐRÓSÐTØˆjˆb�j‰j˜Ó Ð!Øˆzˆr�z‰z˜+Ó&Ð'Ø��—‘Ð-¨r¯z©zÓ:Ð;ð
€òó&2ó
ò
òò$ò÷x8ñ x8òvHò
2ñ
 €÷$ñ $ô:3�iô 3ô (�yô (ô:Ð*ô ô(
�yõ 
r0   