Why Gemfury? Push, build, and install  RubyGems npm packages Python packages Maven artifacts PHP packages Go Modules Debian packages RPM packages NuGet packages

Repository URL to install this package:

Details    
Size: Mime:
ó
ô’EYc@sdZddlZddlZddlmZd5Zd	Zd
„Zdefd„ƒYZ	d
„Z
d„Zd„Zd„Z
d„Zd„Zdefd„ƒYZdZdejdƒfdejdjeƒƒfdejdƒfdejdƒfdejdejƒfgZd„Zdd „Zdd!„Zd"„Zd#„Zd$„Zd%„Zd&efd'„ƒYZd(„Z d)„Z!d*„Z"d+efd,„ƒYZ#d-e#fd.„ƒYZ$d/e#fd0„ƒYZ%d1e%fd2„ƒYZ&d3e#fd4„ƒYZ'dS(6s«
    babel.numbers
    ~~~~~~~~~~~~~

    CLDR Plural support.  See UTS #35.

    :copyright: (c) 2013 by the Babel Team.
    :license: BSD, see LICENSE for more details.
iÿÿÿÿN(tDecimaltzerotonettwotfewtmanytothercCs;t|ƒ}t|ƒ}t|tƒri||kr<|}qitjdkrZt|ƒ}nt|ƒ}nt|tƒr|jƒ}|j	}|dkr¦|j
|nd}djd„|Dƒƒ}|jdƒ}t
|ƒ}t
|ƒ}	t|pødƒ}
t|p
dƒ}nd}}	}
}||||	|
|fS(	s¶Extract operands from a decimal, a float or an int, according to
    `CLDR rules`_.

    .. _`CLDR rules`: http://www.unicode.org/reports/tr35/tr35-33/tr35-numbers.html#Operands
    iiitcss|]}t|ƒVqdS(N(tstr(t.0td((sA/home/tvault/.virtenv/lib/python2.7/site-packages/babel/plural.pys	<genexpr>*st0(ii((tabstintt
isinstancetfloattsystversion_infoRRtas_tupletexponenttdigitstjointrstriptlen(tsourcetntit	dec_tupletexptfraction_digitsttrailingtno_trailingtvtwtftt((sA/home/tvault/.virtenv/lib/python2.7/site-packages/babel/plural.pytextract_operandss(		t
PluralRulecBsteZdZd
Zd„Zd„Zed„ƒZed„ƒZ	ed„dd	ƒZ
d
„Zd„Zd„Z
RS(seRepresents 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
    tabstractt_funccCsÐt|tƒr|jƒ}ntƒ}g|_x™tt|ƒƒD]…\}}|tkrntd|ƒ‚n||krtd|ƒ‚n|j	|ƒt
|ƒj}|rC|jj||fƒqCqCWdS(s$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
        sunknown tag %rstag %r defined twiceN(
RtdicttitemstsetR&tsortedtlistt_plural_tagst
ValueErrortaddt_Parsertasttappend(tselftrulestfoundtkeytexprR1((sA/home/tvault/.virtenv/lib/python2.7/site-packages/babel/plural.pyt__init__Ls		
c	CsV|j}dt|ƒjdjgtD]&}||kr%d|||f^q%ƒfS(Ns<%s %r>s, s%s: %s(R4ttypet__name__RR-(R3R4ttag((sA/home/tvault/.virtenv/lib/python2.7/site-packages/babel/plural.pyt__repr__bs
	cCst||ƒr|S||ƒS(s
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(tclsR4((sA/home/tvault/.virtenv/lib/python2.7/site-packages/babel/plural.pytparsejscCs>tƒj}tg|jD]\}}|||ƒf^qƒS(sŸThe `PluralRule` as a dict of unicode plural rules.

        >>> rule = PluralRule({'one': 'n is 1'})
        >>> rule.rules
        {'one': 'n is 1'}
        (t_UnicodeCompilertcompileR(R&(R3t_compileR;R1((sA/home/tvault/.virtenv/lib/python2.7/site-packages/babel/plural.pyR4vscCs$tg|jD]}|d^q
ƒS(Ni(t	frozensetR&(txR((sA/home/tvault/.virtenv/lib/python2.7/site-packages/babel/plural.pyt<lambda>stdocs°
        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.cCs|jS(N(R&(R3((sA/home/tvault/.virtenv/lib/python2.7/site-packages/babel/plural.pyt__getstate__†scCs
||_dS(N(R&(R3R&((sA/home/tvault/.virtenv/lib/python2.7/site-packages/babel/plural.pyt__setstate__‰scCs.t|dƒs!t|ƒ|_n|j|ƒS(NR'(thasattrt	to_pythonR'(R3R((sA/home/tvault/.virtenv/lib/python2.7/site-packages/babel/plural.pyt__call__Œs(sabstracts_func(R:t
__module__t__doc__t	__slots__R8R<tclassmethodR>tpropertyR4ttagsRFRGRJ(((sA/home/tvault/.virtenv/lib/python2.7/site-packages/babel/plural.pyR%5s					cCsstƒj}dg}x=tj|ƒjD])\}}|jd||ƒ|fƒq(W|jdtƒdj|ƒS(s‚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
    s(function(n) { return s
%s ? %r : s%r; })R(t_JavaScriptCompilerR@R%R>R&R2t
_fallback_tagR(truletto_jstresultR;R1((sA/home/tvault/.virtenv/lib/python2.7/site-packages/babel/plural.pyt
to_javascript’s	!cCsÁitd6td6td6td6}tƒj}ddg}xCtj|ƒjD]/\}}|j	d||ƒt
|ƒfƒqMW|j	dtƒtd	j|ƒd
dƒ}t
||ƒ|dS(
s<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
    tINtWITHINtMODR$sdef evaluate(n):s' n, i, v, w, f, t = extract_operands(n)s if (%s): return %rs
 return %rs
s<rule>texectevaluate(t
in_range_listtwithin_range_listtcldr_moduloR$t_PythonCompilerR@R%R>R&R2RRRRteval(RSt	namespacetto_python_funcRUR;R1tcode((sA/home/tvault/.virtenv/lib/python2.7/site-packages/babel/plural.pyRI©s
	'
cCsÍtj|ƒ}|jttgƒB}tƒj}gtD]}||kr8|^q8j}dt	|ƒg}x:|j
D]/\}}|jd||ƒ||ƒfƒqvW|jd|tƒƒdj|ƒS(s~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
    snplurals=%d; plural=(s
%s ? %d : s%d)R(
R%R>RPR*RRt_GettextCompilerR@R-tindexRR&R2R(RSt	used_tagsRAR;t
_get_indexRUR1((sA/home/tvault/.virtenv/lib/python2.7/site-packages/babel/plural.pyt
to_gettextÑs
('cCs|t|ƒkot||ƒS(s™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](tnumt
range_list((sA/home/tvault/.virtenv/lib/python2.7/site-packages/babel/plural.pyR\èscst‡fd†|DƒƒS(s¶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(N((R	tmin_tmax_(Ri(sA/home/tvault/.virtenv/lib/python2.7/site-packages/babel/plural.pys	<genexpr>
s(tany(RiRj((RisA/home/tvault/.virtenv/lib/python2.7/site-packages/babel/plural.pyR]üscCs_d}|dkr%|d9}d}n|dkr>|d9}n||}|r[|d9}n|S(sî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
    iiÿÿÿÿi((tatbtreversetrv((sA/home/tvault/.virtenv/lib/python2.7/site-packages/babel/plural.pyR^s
	


t	RuleErrorcBseZdZRS(sRaised if a rule is malformed.(R:RKRL(((sA/home/tvault/.virtenv/lib/python2.7/site-packages/babel/plural.pyRr'stnivwfts\s+(?u)twords)\b(and|or|is|(?:with)?in|not|mod|[{0}])\btvalues\d+tsymbols%|,|!=|=tellipsiss\.{2,3}|\u2026cCsÊ|jdƒd}g}d}t|ƒ}x‹||kr¸xxtD]\\}}|j||ƒ}|dk	rA|jƒ}|r™|j||jƒfƒnPqAqAWtd||ƒ‚q.W|ddd…S(Nt@is5malformed CLDR pluralization rule.  Got unexpected %riÿÿÿÿ(	tsplitRt_RULEStmatchtNonetendR2tgroupRr(tsRUtposR}ttokRSR{((sA/home/tvault/.virtenv/lib/python2.7/site-packages/babel/plural.pyt
tokenize_rule6scCs8|o7|dd|ko7|dkp7|dd|kS(Niÿÿÿÿii(R|(ttokensttype_Ru((sA/home/tvault/.virtenv/lib/python2.7/site-packages/babel/plural.pyttest_next_tokenIscCs t|||ƒr|jƒSdS(N(R…tpop(RƒR„Ru((sA/home/tvault/.virtenv/lib/python2.7/site-packages/babel/plural.pyt
skip_tokenNscCs
d|ffS(NRu((Ru((sA/home/tvault/.virtenv/lib/python2.7/site-packages/babel/plural.pyt
value_nodeSscCs
|dfS(N(((tname((sA/home/tvault/.virtenv/lib/python2.7/site-packages/babel/plural.pyt
ident_nodeWscCs
d|fS(NRj((Rj((sA/home/tvault/.virtenv/lib/python2.7/site-packages/babel/plural.pytrange_list_node[scCs
d|ffS(Ntnot((Rq((sA/home/tvault/.virtenv/lib/python2.7/site-packages/babel/plural.pytnegate_sR0cBsneZdZd„Zddd„Zd„Zd„Zd„Zd„Z	d„Z
d„Zd	„Zd
„Z
RS(sò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`.
    cCs_t|ƒ|_|js%d|_dS|jƒ|_|jr[td|jddƒ‚ndS(NsExpected end of rule, got %riÿÿÿÿi(R‚RƒR|R1t	conditionRr(R3tstring((sA/home/tvault/.virtenv/lib/python2.7/site-packages/babel/plural.pyR8…s			cCs“t|j||ƒ}|dk	r%|S|dkrRt|dkrF|pI|ƒ}n|jsntd|ƒ‚ntd||jddfƒ‚dS(Ns#expected %s but end of rule reachedsexpected %s but got %riÿÿÿÿi(R‡RƒR|treprRr(R3R„Ruttermttoken((sA/home/tvault/.virtenv/lib/python2.7/site-packages/babel/plural.pytexpect‘s!	cCsD|jƒ}x1t|jddƒr?d||jƒff}qW|S(NRttor(t
and_conditionR‡Rƒ(R3top((sA/home/tvault/.virtenv/lib/python2.7/site-packages/babel/plural.pyRŽ›scCsD|jƒ}x1t|jddƒr?d||jƒff}qW|S(NRttand(trelationR‡Rƒ(R3R–((sA/home/tvault/.virtenv/lib/python2.7/site-packages/babel/plural.pyR•¡scCsñ|jƒ}t|jddƒrRt|jddƒr<dp?d||jƒffSt|jddƒ}d}t|jddƒr‹d}n7t|jddƒsÂ|rµtdƒ‚n|j|ƒSd|||jƒff}|rít|ƒS|S(	NRttisRŒtisnottintwithins#Cannot negate operator based rules.R˜(R7R‡RƒRuRrtnewfangled_relationRjR(R3tlefttnegatedtmethodRq((sA/home/tvault/.virtenv/lib/python2.7/site-packages/babel/plural.pyR˜§s	
cCswt|jddƒrt}n*t|jddƒr<t}ntdƒ‚dd||jƒff}|rst|ƒS|S(NRvt=s!=s'Expected "=" or "!=" or legacy relationR˜R›(R‡RƒtFalsetTrueRrRjR(R3RžRŸRq((sA/home/tvault/.virtenv/lib/python2.7/site-packages/babel/plural.pyR¸s		cCs<|jƒ}t|jdƒr.||jƒfS||fSdS(NRw(RuR‡Rƒ(R3Rž((sA/home/tvault/.virtenv/lib/python2.7/site-packages/babel/plural.pytrange_or_valueÂscCsH|jƒg}x,t|jddƒr=|j|jƒƒqWt|ƒS(NRvt,(R¤R‡RƒR2R‹(R3Rj((sA/home/tvault/.virtenv/lib/python2.7/site-packages/babel/plural.pyRjÉscCs³t|jdƒ}|dks.|dtkr=tdƒ‚n|d}t|jddƒrxd|df|jƒffSt|jddƒr©d|df|jƒffSt|ƒS(	NRtisExpected identifier variabletmodRvt%(((R‡RƒR|t_VARSRrRuRŠ(R3RtR‰((sA/home/tvault/.virtenv/lib/python2.7/site-packages/babel/plural.pyR7Ïs
cCstt|jdƒdƒƒS(NRui(RˆR
R“(R3((sA/home/tvault/.virtenv/lib/python2.7/site-packages/babel/plural.pyRuÚsN(R:RKRLR8R|R“RŽR•R˜RR¤RjR7Ru(((sA/home/tvault/.virtenv/lib/python2.7/site-packages/babel/plural.pyR0cs 	
				
			cs
‡fd†S(s%Compiler factory for the `_Compiler`.cs ˆ|j|ƒ|j|ƒfS(N(R@(R3tltr(ttmpl(sA/home/tvault/.virtenv/lib/python2.7/site-packages/babel/plural.pyRDàs((R«((R«sA/home/tvault/.virtenv/lib/python2.7/site-packages/babel/plural.pyt_binary_compilerÞscs
‡fd†S(s%Compiler factory for the `_Compiler`.csˆ|j|ƒS(N(R@(R3RC(R«(sA/home/tvault/.virtenv/lib/python2.7/site-packages/babel/plural.pyRDås((R«((R«sA/home/tvault/.virtenv/lib/python2.7/site-packages/babel/plural.pyt_unary_compilerãscCsdS(NR((RC((sA/home/tvault/.virtenv/lib/python2.7/site-packages/babel/plural.pyRDèst	_CompilercBs§eZdZd„Zd„Zd„Zd„Zd„Zd„Zd„Z	d„Z
ed	ƒZed
ƒZ
edƒZedƒZed
ƒZedƒZd„ZRS(sZThe compilers are able to transform the expressions into multiple
    output formats.
    cCs#|\}}t|d|ƒ|ŒS(Ntcompile_(tgetattr(R3targR–targs((sA/home/tvault/.virtenv/lib/python2.7/site-packages/babel/plural.pyR@ðscCsdS(NR((RC((sA/home/tvault/.virtenv/lib/python2.7/site-packages/babel/plural.pyRDôscCsdS(NR((RC((sA/home/tvault/.virtenv/lib/python2.7/site-packages/babel/plural.pyRDõscCsdS(NR ((RC((sA/home/tvault/.virtenv/lib/python2.7/site-packages/babel/plural.pyRDöscCsdS(NR!((RC((sA/home/tvault/.virtenv/lib/python2.7/site-packages/babel/plural.pyRD÷scCsdS(NR"((RC((sA/home/tvault/.virtenv/lib/python2.7/site-packages/babel/plural.pyRDøscCsdS(NR#((RC((sA/home/tvault/.virtenv/lib/python2.7/site-packages/babel/plural.pyRDùscCs
t|ƒS(N(R(RCR ((sA/home/tvault/.virtenv/lib/python2.7/site-packages/babel/plural.pyRDúss
(%s && %s)s
(%s || %s)s(!%s)s
(%s %% %s)s
(%s == %s)s
(%s != %s)cCs
tƒ‚dS(N(tNotImplementedError(R3R R7Rj((sA/home/tvault/.virtenv/lib/python2.7/site-packages/babel/plural.pytcompile_relations(R:RKRLR@t	compile_nt	compile_it	compile_vt	compile_wt	compile_ft	compile_tt
compile_valueR¬tcompile_andt
compile_orR­tcompile_nottcompile_modt
compile_ist
compile_isnotR´(((sA/home/tvault/.virtenv/lib/python2.7/site-packages/babel/plural.pyR®ës 								R_cBsGeZdZedƒZedƒZedƒZedƒZd„Z	RS(s!Compiles an expression to Python.s(%s and %s)s
(%s or %s)s(not %s)sMOD(%s, %s)c	Cs`ddjg|dD]"}dtt|j|ƒƒ^qƒ}d|jƒ|j|ƒ|fS(Ns[%s]R¥is(%s, %s)s
%s(%s, %s)(RttupletmapR@tupper(R3R R7Rjtrange_tcompile_range_list((sA/home/tvault/.virtenv/lib/python2.7/site-packages/babel/plural.pyR´s
	4(
R:RKRLR¬R¼R½R­R¾R¿R´(((sA/home/tvault/.virtenv/lib/python2.7/site-packages/babel/plural.pyR_sRdcBs8eZdZejZeZeZeZ	eZ
d„ZRS(s)Compile into a gettext plural expression.cCs«g}|j|ƒ}x‚|dD]v}|d|dkra|jd||j|dƒfƒq t|j|ƒ\}}|jd||||fƒq Wddj|ƒS(Niis
(%s == %s)s(%s >= %s && %s <= %s)s(%s)s || (R@R2RÃR(R3R R7RjRqtitemtmintmax((sA/home/tvault/.virtenv/lib/python2.7/site-packages/babel/plural.pyR´s		(R:RKRLR®RµR¶tcompile_zeroR·R¸R¹RºR´(((sA/home/tvault/.virtenv/lib/python2.7/site-packages/babel/plural.pyRds	RQcBs8eZdZd„ZeZeZeZeZd„Z	RS(s/Compiles the expression to plain of JavaScript.cCsdS(NsparseInt(n, 10)((RC((sA/home/tvault/.virtenv/lib/python2.7/site-packages/babel/plural.pyRD8scCsMtj||||ƒ}|dkrI|j|ƒ}d|||f}n|S(NR›s(parseInt(%s, 10) == %s && %s)(RdR´R@(R3R R7RjRc((sA/home/tvault/.virtenv/lib/python2.7/site-packages/babel/plural.pyR´>s(
R:RKRLR¶RÊR·R¸R¹RºR´(((sA/home/tvault/.virtenv/lib/python2.7/site-packages/babel/plural.pyRQ3s	R?cBs_eZdZedƒZedƒZedƒZedƒZedƒZd„Z	e
d„ZRS(s+Returns a unicode pluralization rule again.s%s is %ss%s is not %ss	%s and %ss%s or %ss	%s mod %scCs|jdt|dŒS(NRŸi(R´R£(R3R˜((sA/home/tvault/.virtenv/lib/python2.7/site-packages/babel/plural.pyR¾TscCs¡g}xf|dD]Z}|d|dkrH|j|j|dƒƒq|jdtt|j|ƒƒƒqWd|j|ƒ|rŠdpd|dj|ƒfS(Niis%s..%ss
%s%s %s %ss notRR¥(R2R@RÂRÃR(R3R R7RjRŸtrangesRÇ((sA/home/tvault/.virtenv/lib/python2.7/site-packages/babel/plural.pyR´Ws'(R:RKRLR¬RÀRÁR¼R½R¿R¾R¢R´(((sA/home/tvault/.virtenv/lib/python2.7/site-packages/babel/plural.pyR?Gs	(RsonestwoRRsother((RLtreRt
babel._compatRR-RRR$tobjectR%RVRIRhR\R]R^t	ExceptionRrR¨R|R@tformattUNICODERzR‚R…R‡RˆRŠR‹RR0R¬R­RÊR®R_RdRQR?(((sA/home/tvault/.virtenv/lib/python2.7/site-packages/babel/plural.pyt<module>
sJ	 ]		(									{