U
    (Q^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 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	   ú0/tmp/pip-install-bd4o36v9/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   Ú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 | ƒ ¡ S )z*Return true if the variable is lowercased.)r   Úislowerr
   r	   r	   r   Ú
test_lowerB   s    r   c                 C   s   t | ƒ ¡ S )z*Return true if the variable is uppercased.)r   Úisupperr
   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   ÚMappingr
   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ÚDecimalr
   r	   r	   r   Útest_numberY   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_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(   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_iterablew   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	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_typer6   Ztest_callabler   r   r   r   r   r   r   r   r   r   r!   r$   r&   r)   r+   r-   r9   r:   r<   r=   r?   r@   ZTESTSr	   r	   r	   r   Ú<module>   sr   	
		à