3
[ð]v  ã            !   @   s>  d Z ddlZddlZddlmZ ddlmZmZmZm	Z	 ddl
Z
ej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)Ú	Undefined)Ú	text_typeÚstring_typesÚinteger_typesÚabcz^-?\d+(\.\d+)?$c             C   s   | d dkS )z#Return true if the variable is odd.é   é   © )Úvaluer	   r	   ú./tmp/pip-build-w1as9q70/Jinja2/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
   Ú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	   r   Útest_undefined8   s    r   c             C   s   | dkS )z$Return true if the variable is none.Nr	   )r
   r	   r	   r   Ú	test_none=   s    r   c             C   s   t | ƒjƒ S )z*Return true if the variable is lowercased.)r   Úislower)r
   r	   r	   r   Ú
test_lowerB   s    r   c             C   s   t | ƒjƒ S )z*Return true if the variable is uppercased.)r   Úisupper)r
   r	   r	   r   Ú
test_upperG   s    r   c             C   s
   t | tƒS )z&Return true if the object is a string.)r   r   )r
   r	   r	   r   Útest_stringL   s    r   c             C   s   t | tjƒS )zSReturn true if the object is a mapping (dict etc.).

    .. versionadded:: 2.6
    )r   r   ÚMapping)r
   r	   r	   r   Útest_mappingQ   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ÚdecimalÚDecimal)r
   r	   r	   r   Útest_numberY   s    r   c          	   C   s"   yt | ƒ | j W n
   dS 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_sequence^   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_sameasj   s    
r$   c             C   s&   yt | ƒ W n tk
r    dS X dS )z1Check if it's possible to iterate over an object.FT)ÚiterÚ	TypeError)r
   r	   r	   r   Útest_iterablew   s
    r'   c             C   s
   t | dƒS )zCheck if the value is escaped.Z__html__)Úhasattr)r
   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	undefinedÚnoneÚlowerÚupperÚstringÚmappingÚnumberÚsequenceÚiterableÚcallableZsameasÚescapedÚinz==ÚeqZequaltoz!=Úneú>ÚgtZgreaterthanÚgez>=ú<ÚltZlessthanz<=Úle)(Ú__doc__ÚoperatorÚreZjinja2.runtimer   Zjinja2._compatr   r   r   r   r   ÚcompileZ	number_reÚtypeZ
regex_typer4   Ztest_callabler   r   r   r   r   r   r   r   r   r   r   r"   r$   r'   r)   r+   r7   r8   r:   r;   r=   r>   ZTESTSr	   r	   r	   r   Ú<module>
   sp   
		