404

[ Avaa Bypassed ]




Upload:

Command:

elspacio@3.137.211.49: ~ $
3

H��X@S�@s�dZddlZddlmZdFZd	Zd
d�ZGdd
�d
e�Zdd�Z	dd�Z
dd�Zdd�Zdd�Z
dd�ZGdd�de�ZdZdejdej�fdejdje��fd ejd!�fd"ejd#�fd$ejd%ej�fgZd&d'�ZdGd(d)�ZdHd*d+�Zd,d-�Zd.d/�Zd0d1�Zd2d3�ZGd4d5�d5e�Zd6d7�Zd8d9�Zd:d;�Z Gd<d=�d=e�Z!Gd>d?�d?e!�Z"Gd@dA�dAe!�Z#GdBdC�dCe#�Z$GdDdE�dEe!�Z%dS)Iz�
    babel.numbers
    ~~~~~~~~~~~~~

    CLDR Plural support.  See UTS #35.

    :copyright: (c) 2013 by the Babel Team.
    :license: BSD, see LICENSE for more details.
�N)�decimal�zero�one�two�few�many�othercCs�t|�}t|�}t|t�r6||kr(|}ntjt|��}t|tj�r�|j�}|j}|dkrf|j	|d�nf}dj
dd�|D��}|jd�}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`: http://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�d�r
�/usr/lib/python3.6/plural.py�	<genexpr>Asz#extract_operands.<locals>.<genexpr>�0)
�abs�int�
isinstance�floatrZDecimalr
Zas_tupleZexponentZdigits�join�rstrip�len)�source�n�iZ	dec_tupleZexpZfraction_digitsZtrailingZno_trailing�v�w�f�tr
r
r�extract_operandss$

rc@sdeZdZdZdZdd�Zdd�Zedd	��Ze	d
d��Z
e	dd
�dd�Zdd�Zdd�Z
dd�ZdS)�
PluralRuleaeRepresents 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`: http://www.unicode.org/reports/tr35/tr35-33/tr35-numbers.html#Language_Plural_Rules
    �abstract�_funccCs�t|t�r|j�}t�}g|_xjtt|��D]Z\}}|tkrJtd|��n||kr^td|��|j	|�t
|�j}|r,|jj||f�q,WdS)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,r
r
r�__init__cs


zPluralRule.__init__cs,|j�dt|�jdj�fdd�tD��fS)Nz<%s %r>z, cs$g|]}|�krd|�|f�qS)z%s: %sr
)r�tag)r/r
r�
<listcomp>}sz'PluralRule.__repr__.<locals>.<listcomp>)r/�type�__name__rr()r.r
)r/r�__repr__yszPluralRule.__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)�clsr/r
r
r�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�qSr
r
)rr4r,)�_compiler
rr5�sz$PluralRule.rules.<locals>.<listcomp>)�_UnicodeCompiler�compiler#r!)r.r
)r;rr/�szPluralRule.rulescCstdd�|jD��S)NcSsg|]}|d�qS)rr
)rrr
r
rr5�sz'PluralRule.<lambda>.<locals>.<listcomp>)�	frozensetr!)�xr
r
r�<lambda>�szPluralRule.<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|jS)N)r!)r.r
r
r�__getstate__�szPluralRule.__getstate__cCs
||_dS)N)r!)r.r!r
r
r�__setstate__�szPluralRule.__setstate__cCst|d�st|�|_|j|�S)Nr")�hasattr�	to_pythonr")r.rr
r
r�__call__�s

zPluralRule.__call__N)r!r")r7�
__module__�__qualname__�__doc__�	__slots__r3r8�classmethodr:�propertyr/�tagsrBrCrFr
r
r
rr Lsr cCsVt�j}dg}x.tj|�jD]\}}|jd||�|f�qW|jdt�dj|�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	)�_JavaScriptCompilerr=r r:r!r-�
_fallback_tagr)�ruleZto_js�resultr4r,r
r
r�
to_javascript�srRcCs�ttttd�}t�j}ddg}x2tj|�jD]"\}}|j	d||�t
|�f�q,W|j	dt�tdj|�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
    )�INZWITHINZMODrzdef 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�_PythonCompilerr=r r:r!r-r
rOr�eval)rP�	namespaceZto_python_funcrQr4r,�coder
r
rrE�s
rEcs�tj|�}|jttg�B�t�j}�fdd�tD�j}dt	��g}x,|j
D]"\}}|jd||�||�f�qLW|jd|t��dj|�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|]}|�kr|�qSr
r
)rr4)�	used_tagsr
rr5�szto_gettext.<locals>.<listcomp>znplurals=%d; plural=(z
%s ? %d : z%d)r	)
r r:rMr%rO�_GettextCompilerr=r(�indexrr!r-r)rPr;Z
_get_indexrQr4r,r
)r]r�
to_gettext�s

r`cCs|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
    )rrW)�num�
range_listr
r
rrV�srVcst�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�|kVqdS)Nr
)rZmin_Zmax_)rar
rr$sz$within_range_list.<locals>.<genexpr>)�any)rarbr
)rarrWsrWcCs@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����rerer
)�a�b�reverse�rvr
r
rrX'srXc@seZdZdZdS)�	RuleErrorzRaised if a rule is malformed.N)r7rGrHrIr
r
r
rrj>srjZnivwftz\s+�wordz)\b(and|or|is|(?:with)?in|not|mod|[{0}])\b�valuez\d+�symbolz%|,|!=|=�ellipsisz\.{2,3}|\u2026cCs�|jd�d}g}d}t|�}xb||kr�xTtD]<\}}|j||�}|dk	r.|j�}|rh|j||j�f�Pq.Wtd||��q W|ddd�S)N�@rz5malformed CLDR pluralization rule.  Got unexpected %rrdre)�splitr�_RULES�match�endr-�grouprj)�srQ�posrs�tokrPrrr
r
r�
tokenize_ruleMs
rxcCs,|o*|dd|ko*|dkp*|dd|kS)Nrdrrerer
)�tokens�type_rlr
r
r�test_next_token`sr{cCst|||�r|j�SdS)N)r{�pop)ryrzrlr
r
r�
skip_tokenesr}cCs
d|ffS)Nrlr
)rlr
r
r�
value_nodejsr~cCs|ffS)Nr
)�namer
r
r�
ident_nodensr�cCsd|fS)Nrbr
)rbr
r
r�range_list_nodersr�cCs
d|ffS)N�notr
)rir
r
r�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|j�|_|jr@td|jdd��dS)NzExpected end of rule, got %rrdre)rxryr,�	conditionrj)r.�stringr
r
rr3�s

z_Parser.__init__NcCsft|j||�}|dk	r|S|dkr6t|dkr0|p2|�}|jsHtd|��td||jddf��dS)Nz#expected %s but end of rule reachedzexpected %s but got %rrdre)r}ry�reprrj)r.rzrlZterm�tokenr
r
r�expect�sz_Parser.expectcCs0|j�}x"t|jdd�r*d||j�ff}q
W|S)Nrk�or)�
and_conditionr}ry)r.�opr
r
rr��sz_Parser.conditioncCs0|j�}x"t|jdd�r*d||j�ff}q
W|S)Nrk�and)�relationr}ry)r.r�r
r
rr��sz_Parser.and_conditioncCs�|j�}t|jdd�r8t|jdd�r(dp*d||j�ffSt|jdd�}d}t|jdd�r^d}n$t|jdd�s�|rxtd��|j|�Sd|||j�ff}|r�t|�S|S)	Nrk�isr�Zisnot�inZwithinz#Cannot negate operator based rules.r�)r2r}ryrlrj�newfangled_relationrbr�)r.�left�negated�methodrir
r
rr��s
z_Parser.relationcCsRt|jdd�rd}nt|jdd�r(d}ntd��dd||j�ff}|rNt|�S|S)	Nrm�=Fz!=Tz'Expected "=" or "!=" or legacy relationr�r�)r}ryrjrbr�)r.r�r�rir
r
rr��sz_Parser.newfangled_relationcCs,|j�}t|jd�r ||j�fS||fSdS)Nrn)rlr}ry)r.r�r
r
r�range_or_value�sz_Parser.range_or_valuecCs4|j�g}x t|jdd�r*|j|j��qWt|�S)Nrm�,)r�r}ryr-r�)r.rbr
r
rrb�s
z_Parser.range_listcCs|t|jd�}|dks |dtkr(td��|d}t|jdd�rRd|ff|j�ffSt|jdd�rtd|ff|j�ffSt|�S)NrkrdzExpected identifier variable�modrm�%)r}ry�_VARSrjrlr�)r.rkrr
r
rr2�sz_Parser.exprcCstt|jd�d��S)Nrlrd)r~rr�)r.r
r
rrl�sz
_Parser.value)NN)r7rGrHrIr3r�r�r�r�r�r�rbr2rlr
r
r
rr+zs 


r+cs�fdd�S)z%Compiler factory for the `_Compiler`.cs�|j|�|j|�fS)N)r=)r.�l�r)�tmplr
rr@�sz"_binary_compiler.<locals>.<lambda>r
)r�r
)r�r�_binary_compiler�sr�cs�fdd�S)z%Compiler factory for the `_Compiler`.cs�|j|�S)N)r=)r.r?)r�r
rr@�sz!_unary_compiler.<locals>.<lambda>r
)r�r
)r�r�_unary_compiler�sr�cCsdS)Nrr
)r?r
r
rr@�sr@c@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��argsr
r
rr=sz_Compiler.compilecCsdS)Nrr
)r?r
r
rr@sz_Compiler.<lambda>cCsdS)Nrr
)r?r
r
rr@scCsdS)Nrr
)r?r
r
rr@
scCsdS)Nrr
)r?r
r
rr@scCsdS)Nrr
)r?r
r
rr@scCsdS)Nrr
)r?r
r
rr@scCst|�S)N)r
)r?rr
r
rr@sz
(%s && %s)z
(%s || %s)z(!%s)z
(%s %% %s)z
(%s == %s)z
(%s != %s)cCs
t��dS)N)�NotImplementedError)r.r�r2rbr
r
r�compile_relationsz_Compiler.compile_relationN)r7rGrHrIr=�	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�r
r
r
rr�s r�c@s8eZdZdZed�Zed�Zed�Zed�Z	dd�Z
dS)	rYz!Compiles an expression to Python.z(%s and %s)z
(%s or %s)z(not %s)zMOD(%s, %s)cs8ddj�fdd�|dD��}d|j��j|�|fS)Nz[%s]r�cs g|]}dtt�j|���qS)z(%s, %s))�tuple�mapr=)rZrange_)r.r
rr5'sz4_PythonCompiler.compile_relation.<locals>.<listcomp>rdz
%s(%s, %s))r�upperr=)r.r�r2rbZcompile_range_listr
)r.rr�%s

z _PythonCompiler.compile_relationN)r7rGrHrIr�r�r�r�r�r�r�r
r
r
rrYsrYc@s.eZdZdZejZeZeZ	eZ
eZdd�ZdS)r^z)Compile into a gettext plural expression.cCs�g}|j|�}xd|dD]X}|d|dkrJ|jd||j|d�f�qt|j|�\}}|jd||||f�qWddj|�S)Nrdrz
(%s == %s)z(%s >= %s && %s <= %s)z(%s)z || )r=r-r�r)r.r�r2rbri�item�min�maxr
r
rr�6s
z!_GettextCompiler.compile_relationN)
r7rGrHrIr�r�r��compile_zeror�r�r�r�r�r
r
r
rr^-sr^c@s0eZdZdZdd�ZeZeZeZeZ	dd�Z
dS)rNz/Compiles the expression to plain of JavaScript.cCsdS)NzparseInt(n, 10)r
)r?r
r
rr@Osz_JavaScriptCompiler.<lambda>cCs4tj||||�}|dkr0|j|�}d|||f}|S)Nr�z(parseInt(%s, 10) == %s && %s))r^r�r=)r.r�r2rbr\r
r
rr�Us
z$_JavaScriptCompiler.compile_relationN)r7rGrHrIr�r�r�r�r�r�r�r
r
r
rrNJsrNc@sJeZdZdZed�Zed�Zed�Zed�Zed�Z	dd�Z
d
d
d�ZdS)r<z+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)Nrdr�T)r�)r.r�r
r
rr�ksz_UnicodeCompiler.compile_notFcCszg}xP|dD]D}|d|dkr8|j|j|d��q|jdtt|j|���qWd|j|�|rhdpjd|dj|�fS)Nrdrz%s..%sz
%s%s %s %sz notr	r�)r-r=r�r�r)r.r�r2rbr�Zrangesr�r
r
rr�nsz!_UnicodeCompiler.compile_relationN)F)r7rGrHrIr�r�r�r�r�r�r�r�r
r
r
rr<^sr<)rrrrrr)N)N)&rI�reZ
babel._compatrr(rOr�objectr rRrEr`rVrWrX�	Exceptionrjr�r=�UNICODE�formatrqrxr{r}r~r�r�r�r+r�r�r�r�rYr^rNr<r
r
r
r�<module>
sH8](


{

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