U
    ð»ÑgÈ  ã                !   @   sd  d Z ddlZddlZzddlmZ W n   ddlmZ Y nX ddlmZ ddlm	Z	m
Z
mZ ddlZe d¡ZeeƒZe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dd„ Zdd„ Zdd „ Zd!d"„ Z d#d$„ Z!d%d&„ Z"eeeeeeeeeeeee eee!e"ej#ej#ej#ej$ej$ej%ej%ej%ej&ej&ej'ej'ej'ej(ej(d'œ Z)dS )(z¹
    jinja2.tests
    ~~~~~~~~~~~~

    Jinja test functions. Used with the "is" operator.

    :copyright: (c) 2017 by the Jinja Team.
    :license: BSD, see LICENSE for more details.
é    N)ÚMapping)Ú	Undefined)Ú	text_typeÚstring_typesÚinteger_typesz^-?\d+(\.\d+)?$c                 C   s   | d dkS )z#Return true if the variable is odd.é   é   © ©Úvaluer	   r	   ú./usr/lib/python3/dist-packages/jinja2/tests.pyÚtest_odd   s    r   c                 C   s   | d dkS )z$Return true if the variable is even.r   r   r	   r
   r	   r	   r   Ú	test_even#   s    r   c                 C   s   | | dkS )z-Check if a variable is divisible by a number.r   r	   )r   Znumr	   r	   r   Útest_divisibleby(   s    r   c                 C   s   t | tƒ S )a;  Return true if the variable is defined:

    .. sourcecode:: jinja

        {% if variable is defined %}
            value of variable: {{ variable }}
        {% else %}
            variable is not defined
        {% endif %}

    See the :func:`default` filter for a simple way to set undefined
    variables.
    ©Ú
isinstancer   r
   r	   r	   r   Útest_defined-   s    r   c                 C   s
   t | tƒS )z-Like :func:`defined` but the other way round.r   r
   r	   r	   r   Útest_undefined>   s    r   c                 C   s   | dkS )z$Return true if the variable is none.Nr	   r
   r	   r	   r   Ú	test_noneC   s    r   c                 C   s   t | ƒ ¡ S )z*Return true if the variable is lowercased.)r   Úislowerr
   r	   r	   r   Ú
test_lowerH   s    r   c                 C   s   t | ƒ ¡ S )z*Return true if the variable is uppercased.)r   Úisupperr
   r	   r	   r   Ú
test_upperM   s    r   c                 C   s
   t | tƒS )z&Return true if the object is a string.)r   r   r
   r	   r	   r   Útest_stringR   s    r   c                 C   s
   t | tƒS )zSReturn true if the object is a mapping (dict etc.).

    .. versionadded:: 2.6
    )r   r   r
   r	   r	   r   Útest_mappingW   s    r   c                 C   s   t | ttttjf ƒS )z(Return true if the variable is a number.)r   r   ÚfloatÚcomplexÚdecimalZDecimalr
   r	   r	   r   Útest_number_   s    r   c                 C   s&   zt | ƒ | j W n   Y dS X dS )z^Return true if the variable is a sequence. Sequences are variables
    that are iterable.
    FT)ÚlenÚ__getitem__r
   r	   r	   r   Útest_sequenced   s    
r!   c                 C   s   | |kS )zïCheck if an object points to the same memory address than another
    object:

    .. sourcecode:: jinja

        {% if foo.attribute is sameas false %}
            the foo attribute really is the `False` singleton
        {% endif %}
    r	   )r   Úotherr	   r	   r   Útest_sameasp   s    
r#   c                 C   s(   zt | ƒ W n tk
r"   Y dS X dS )z1Check if it's possible to iterate over an object.FT)ÚiterÚ	TypeErrorr
   r	   r	   r   Útest_iterable}   s
    r&   c                 C   s
   t | dƒS )zCheck if the value is escaped.Z__html__)Úhasattrr
   r	   r	   r   Útest_escaped†   s    r(   c                 C   s   | |kS )z:Check if value is in seq.

    .. versionadded:: 2.10
    r	   )r   Úseqr	   r	   r   Útest_in‹   s    r*   ) ZoddZevenZdivisiblebyZdefinedZ	undefinedZnoneÚlowerÚupperÚstringÚmappingZnumberZsequenceÚiterableÚcallableZsameasZescapedÚinz==ÚeqZequaltoz!=Úneú>ÚgtZgreaterthanÚgez>=ú<ÚltZlessthanz<=Úle)*Ú__doc__ÚoperatorÚreZcollections.abcr   ÚcollectionsZjinja2.runtimer   Zjinja2._compatr   r   r   r   ÚcompileZ	number_reÚtypeZ
regex_typer0   Ztest_callabler   r   r   r   r   r   r   r   r   r   r   r!   r#   r&   r(   r*   r2   r3   r5   r6   r8   r9   ZTESTSr	   r	   r	   r   Ú<module>   sz   	
		à