ó
~9Vc           @   s  d  Z  d d l Z d d l m Z d d l m Z d d l m Z m Z m	 Z	 d d l
 Z
 e j d  Z e e  Z e Z d   Z d   Z d	   Z d
   Z d   Z d   Z d   Z d   Z d   Z d   Z d   Z d   Z d   Z d   Z d   Z d   Z  i e d 6e d 6e d 6e d 6e d 6e d 6e d 6e d 6e d 6e d  6e d! 6e d" 6e d# 6e d$ 6e d% 6e d& 6e  d' 6Z! d S((   sš   
    jinja2.tests
    ~~~~~~~~~~~~

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

    :copyright: (c) 2010 by the Jinja Team.
    :license: BSD, see LICENSE for more details.
i˙˙˙˙N(   t   Mapping(   t	   Undefined(   t	   text_typet   string_typest   integer_typess   ^-?\d+(\.\d+)?$c         C   s   |  d d k S(   s#   Return true if the variable is odd.i   i   (    (   t   value(    (    s,   /tmp/pip-build-zHWFj_/Jinja2/jinja2/tests.pyt   test_odd   s    c         C   s   |  d d k S(   s$   Return true if the variable is even.i   i    (    (   R   (    (    s,   /tmp/pip-build-zHWFj_/Jinja2/jinja2/tests.pyt	   test_even   s    c         C   s   |  | d k S(   s-   Check if a variable is divisible by a number.i    (    (   R   t   num(    (    s,   /tmp/pip-build-zHWFj_/Jinja2/jinja2/tests.pyt   test_divisibleby"   s    c         C   s   t  |  t  S(   s;  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.
    (   t
   isinstanceR   (   R   (    (    s,   /tmp/pip-build-zHWFj_/Jinja2/jinja2/tests.pyt   test_defined'   s    c         C   s   t  |  t  S(   s-   Like :func:`defined` but the other way round.(   R
   R   (   R   (    (    s,   /tmp/pip-build-zHWFj_/Jinja2/jinja2/tests.pyt   test_undefined8   s    c         C   s
   |  d k S(   s$   Return true if the variable is none.N(   t   None(   R   (    (    s,   /tmp/pip-build-zHWFj_/Jinja2/jinja2/tests.pyt	   test_none=   s    c         C   s   t  |   j   S(   s*   Return true if the variable is lowercased.(   R   t   islower(   R   (    (    s,   /tmp/pip-build-zHWFj_/Jinja2/jinja2/tests.pyt
   test_lowerB   s    c         C   s   t  |   j   S(   s*   Return true if the variable is uppercased.(   R   t   isupper(   R   (    (    s,   /tmp/pip-build-zHWFj_/Jinja2/jinja2/tests.pyt
   test_upperG   s    c         C   s   t  |  t  S(   s&   Return true if the object is a string.(   R
   R   (   R   (    (    s,   /tmp/pip-build-zHWFj_/Jinja2/jinja2/tests.pyt   test_stringL   s    c         C   s   t  |  t  S(   sS   Return true if the object is a mapping (dict etc.).

    .. versionadded:: 2.6
    (   R
   R    (   R   (    (    s,   /tmp/pip-build-zHWFj_/Jinja2/jinja2/tests.pyt   test_mappingQ   s    c         C   s   t  |  t t t t j f  S(   s(   Return true if the variable is a number.(   R
   R   t   floatt   complext   decimalt   Decimal(   R   (    (    s,   /tmp/pip-build-zHWFj_/Jinja2/jinja2/tests.pyt   test_numberY   s    c         C   s$   y t  |   |  j Wn t SXt S(   s^   Return true if the variable is a sequence. Sequences are variables
    that are iterable.
    (   t   lent   __getitem__t   Falset   True(   R   (    (    s,   /tmp/pip-build-zHWFj_/Jinja2/jinja2/tests.pyt   test_sequence^   s    
c         C   s
   |  | k S(   sţ  Check if an object has the same value as another object:

    .. sourcecode:: jinja

        {% if foo.expression is equalto 42 %}
            the foo attribute evaluates to the constant 42
        {% endif %}

    This appears to be a useless test as it does exactly the same as the
    ``==`` operator, but it can be useful when used together with the
    `selectattr` function:

    .. sourcecode:: jinja

        {{ users|selectattr("email", "equalto", "foo@bar.invalid") }}

    .. versionadded:: 2.8
    (    (   R   t   other(    (    s,   /tmp/pip-build-zHWFj_/Jinja2/jinja2/tests.pyt   test_equaltoj   s    c         C   s
   |  | k S(   sď   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   (    (    s,   /tmp/pip-build-zHWFj_/Jinja2/jinja2/tests.pyt   test_sameas   s    
c         C   s'   y t  |   Wn t k
 r" t SXt S(   s1   Check if it's possible to iterate over an object.(   t   itert	   TypeErrorR   R   (   R   (    (    s,   /tmp/pip-build-zHWFj_/Jinja2/jinja2/tests.pyt   test_iterable   s
    c         C   s   t  |  d  S(   s   Check if the value is escaped.t   __html__(   t   hasattr(   R   (    (    s,   /tmp/pip-build-zHWFj_/Jinja2/jinja2/tests.pyt   test_escaped   s    t   oddt   event   divisiblebyt   definedt	   undefinedt   nonet   lowert   uppert   stringt   mappingt   numbert   sequencet   iterablet   callablet   sameast   equaltot   escaped("   t   __doc__t   ret   collectionsR    t   jinja2.runtimeR   t   jinja2._compatR   R   R   R   t   compilet	   number_ret   typet
   regex_typeR5   t   test_callableR   R   R	   R   R   R   R   R   R   R   R   R   R    R!   R$   R'   t   TESTS(    (    (    s,   /tmp/pip-build-zHWFj_/Jinja2/jinja2/tests.pyt   <module>
   sT   																	