3 C\!@sFdZddlZddlZddlmZddlmZddlmZm Z m Z ddl Z ej dZ ee ZeZddZd d Zd d Zd dZddZddZddZddZddZddZddZddZdd Zd!d"Zd#d$Z d%d&Z!eeeeeeeeeeeeeeee e!ej"ej"ej"ej#ej#ej$ej$ej$ej%ej%ej&ej&ej&ej'ej'd' Z(dS)(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+)?$cCs |ddkS)z#Return true if the variable is odd.)valuer r d/private/var/folders/pf/wv4htv3x0qs2c2mp0dnn0kchsvlck3/T/pip-install-emcbgzcf/jinja2/jinja2/tests.pytest_oddsr cCs |ddkS)z$Return true if the variable is even.rrr )r r r r test_evensr cCs ||dkS)z-Check if a variable is divisible by a number.rr )r numr r r test_divisibleby#srcCs 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(srcCs t|tS)z-Like :func:`defined` but the other way round.)rr)r r r r test_undefined9srcCs|dkS)z$Return true if the variable is none.Nr )r r r r test_none>srcCs t|jS)z*Return true if the variable is lowercased.)rislower)r r r r test_lowerCsrcCs t|jS)z*Return true if the variable is uppercased.)risupper)r r r r test_upperHsrcCs t|tS)z&Return true if the object is a string.)rr)r r r r test_stringMsrcCs t|tS)zSReturn true if the object is a mapping (dict etc.). .. versionadded:: 2.6 )rr)r r r r test_mappingRsrcCst|ttttjfS)z(Return true if the variable is a number.)rrfloatcomplexdecimalDecimal)r r r r test_numberZsrc Cs"yt||jWn dSdS)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!cCs||kS)zCheck 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_sameasks r#c Cs&y t|Wntk r dSXdS)z1Check if it's possible to iterate over an object.FT)iter TypeError)r r r r test_iterablexs  r&cCs t|dS)zCheck if the value is escaped.Z__html__)hasattr)r r r r test_escapedsr(cCs||kS)z:Check if value is in seq. .. versionadded:: 2.10 r )r seqr r r test_insr*) ZoddZevenZ divisiblebyZdefinedZ undefinednonelowerupperstringmappingnumbersequenceiterablecallableZsameasescapedinz==eqZequaltoz!=ne>gtZ greaterthangez>=<ltZlessthanz<=le))__doc__operatorre collectionsrZjinja2.runtimerZjinja2._compatrrrrcompileZ number_retypeZ regex_typer3Z test_callabler r rrrrrrrrrr!r#r&r(r*r6r7r9r:r<r=ZTESTSr r r r  sr