o2n`dZddlZddlZddlZddlZddlmZddlmZddlm Z ddl m Z ddl m Z ddl m Z d d lmZd d lmZd d lmZd d lmZd dlmZd dlmZd dlmZd dlmZd dlmZd dlmZd dlmZejdejZejdejZ dZ!dZ"dZ#dZ$ddZ%ddZ&dZ'dZ(dZ)e"dd Z*d!Z+d"Z,e"dd$Z-d%Z.d&Z/dd)Z0e#dd*Z1e#dd+Z2d,Z3e#dd-Z4e#dd.Z5dd0Z6e"dd1Z7dd3Z8e#d4Z9e#d5Z:e!d6Z;dd7Zdd;Z?e#dd>Z@e# dd@ZAdAZBddCZCddEZDdFZEddGZFdHZGddIZHddJZIddLZJedMdNdOgZKeLjMeK_MeLjNeK_Ne#dPZOe#ddQZPdRZQdSZRdTZSdUZTe#dVZUe!dWZVe!dXZWe!dYZXe!dZZYe!d[ZZe"dd\Z[d]Z\d^Z]d_Z^id`e_daeUdbeIdce.dde8dee`dfe6dge6dhe0die dje dke<dle9dmeDdne(doeEdpeOidqe?dreCdse7dte:due`dOeQdve,dweVdxe4dye5dze=d{e;d|eXd}eZd~e*deTdeJideRdeWdeYdeHde1de deGdePde/deFde@de2de+de)de>deBdeAe-e[dZadS)z7Built-in template filters used with the ``|`` operator.N) namedtuple)chain)groupby)escapeMarkup) soft_unicode)abc)imap) iteritems) string_types text_type)FilterArgumentError) Undefined)htmlsafe_json_dumpspformatunicode_urlencode)urlizez\w+z([-\s\(\{\[\<]+)cd|_|S)zxDecorator for marking context dependent filters. The current :class:`Context` will be passed as first argument. T) contextfilterfs n/builddir/build/BUILD/imunify360-venv-2.6.2/opt/imunify360/venv/lib/python3.11/site-packages/jinja2/filters.pyrrsAO Hcd|_|S)zDecorator for marking eval-context dependent filters. An eval context object is passed as first argument. For more information about the eval context, see :ref:`eval-context`. .. versionadded:: 2.4 T)evalcontextfilterrs rr r 'sA Hrcd|_|S)zDecorator for marking environment dependent filters. The current :class:`Environment` is passed to the filter as first argument. T)environmentfilterrs rr"r"2sA HrcXt|tr|n|S)zxFor use as a postprocessor for :func:`make_attrgetter`. Converts strings to lowercase and returns other types as-is.) isinstancerlowervalues r ignore_caser(:s%'ul;; F5;;===Frc<tfd}|S)zReturns a callable that looks up the given attribute from a passed object with the rules of the environment. Dots are allowed to access attributes of attributes. Integer parts in paths are looked up as integers. cD]1}||}rt|tr}2 |}|SN)getitemr$r)itempart attributedefault environment postprocesss r attrgetterz#make_attrgetter..attrgetterHs`  D&&tT22D :dI66   ";t$$D r_prepare_attribute_parts)r1r/r2r0r3s```` rmake_attrgetterr6@sE )33I         rcttrdng}d|Dfd}|S)aReturns a callable that looks up the given comma separated attributes from a passed object with the rules of the environment. Dots are allowed to access attributes of each attribute. Integer parts in paths are looked up as integers. The value returned by the returned callable is a list of extracted attribute values. Examples of attribute: "attr1,attr2", "attr1.inner1.0,attr2.inner2.0", etc. ,c,g|]}t|Sr4).0attribute_parts r z)make_multi_attrgetter..es.5C 00rcdgtz}tD]4\}}|}|D]}||} |}|||<5|Sr+)len enumerater,) r-itemsir<item_ir.r/r1r2s rr3z)make_multi_attrgetter..attrgetterisY'!*9!5!5   A~F& ; ;$,,VT::&$V,,E!HH rr$rsplit)r1r/r2attribute_partsr3s``` rmake_multi_attrgetterrGWsz!+9l C CT )GVI        rcx|gSt|trd|dDS|gS)NcXg|]'}|rt|n|(Sr:)isdigitint)r;xs rr=z,_prepare_attribute_parts..}s/FFF!))++,A1FFFr.rD)attrs rr5r5ysC | D, ' 'FFdjjooFFFFv rct|dr|}tt|S)zCEnforce HTML escaping. This will probably double escape variables.__html__)hasattrrPrrr&s rdo_forceescaperRs9uj!!!   )E"" # ##rc$t|tst|tjst |St|t rt |}nt|}dd|DS)a3Quote data for use in a URL path or query using UTF-8. Basic wrapper around :func:`urllib.parse.quote` when given a string, or :func:`urllib.parse.urlencode` for a dict or iterable. :param value: Data to quote. A string will be quoted directly. A dict or iterable of ``(key, value)`` pairs will be joined as a query string. When given a string, "/" is not quoted. HTTP servers treat "/" and "%2F" equivalently in paths. If you need quoted slashes, use the ``|replace("/", "%2F")`` filter. .. versionadded:: 2.7 &c3fK|],\}}t|ddt|dV-dS)T)for_qs=Nr)r;kvs r zdo_urlencode..sd Aq%Qt444446GRV6W6W6W6WXr) r$rr Iterablerdictr iterjoin)r'rAs r do_urlencoder_s %&&(j .M.M( '''%%  U  99  rc|d}|js>t|t|t||St|ds t|dr t|dst |}nt |}|t |t ||S)aReturn a copy of the value with all occurrences of a substring replaced with a new one. The first argument is the substring that should be replaced, the second is the replacement string. If the optional third argument ``count`` is given, only the first ``count`` occurrences are replaced: .. sourcecode:: jinja {{ "Hello World"|replace("Hello", "Goodbye") }} -> Goodbye World {{ "aaaaargh"|replace("a", "d'oh, ", 2) }} -> d'oh, d'oh, aaargh NrP) autoescaperreplacerQrr )eval_ctxsoldnewcounts r do_replaceris  }  K||##IcNNIcNNEJJJZ   3 # #:&& 1II OO 99\#&& S(9(95 A AArcDt|S)zConvert a value to uppercase.)r upperres rdo_upperrm ?? " ""rcDt|S)zConvert a value to lowercase.)r r%rls rdo_lowerrprnrTcddt|D}|r|rd|z}|jrt|}|S)acCreate an SGML/XML attribute string based on the items in a dict. All values that are neither `none` nor `undefined` are automatically escaped: .. sourcecode:: html+jinja ... Results in something like this: .. sourcecode:: html
    ...
As you can see it automatically prepends a space in front of the item if the filter returned something unless the second parameter is false.  c3K|]@\}}|t|tt|dt|dVAdS)Nz="")r$rr)r;keyr's rrZzdo_xmlattr..s` C  Zy%A%A Skkkk6%====1    r)r^r rbr) _eval_ctxd autospacervs r do_xmlattrrzsn0 #A,,  B R BY BZZ IrcDt|S)zYCapitalize a value. The first character will be uppercase, all others lowercase. )r capitalizerls r do_capitalizer}s ?? % % ' ''rcddtt|DS)zReturn a titlecased version of the value. I.e. words will start with uppercase letters, all remaining characters are lowercase. cg|];}||d|ddz.sQ    GMMOOd122hnn.. .   r)r^_word_beginning_split_rerEr rls rdo_titlersJ 77  066|AGG     rFruc|dkrdn|dkrdntdfd}t|||S)afSort a dict and yield (key, value) pairs. Because python dicts are unsorted you may want to use this function to order them by either key or value: .. sourcecode:: jinja {% for item in mydict|dictsort %} sort the dict by key, case insensitive {% for item in mydict|dictsort(reverse=true) %} sort the dict by key, case insensitive, reverse order {% for item in mydict|dictsort(true) %} sort the dict by key, case sensitive {% for item in mydict|dictsort(false, 'value') %} sort the dict by value, case insensitive rurr'r z,You can only sort by either "key" or "value"c:|}st|}|Sr+)r()r-r'case_sensitiveposs r sort_funczdo_dictsort..sort_func"s&S  '&&E rrureverse)rsortedrA)r'rbyrrrs ` @r do_dictsortrsr& U{{ w!"PQQQ %++--Y @ @ @@rc\t|||stnd}t|||S)a*Sort an iterable using Python's :func:`sorted`. .. sourcecode:: jinja {% for city in cities|sort %} ... {% endfor %} :param reverse: Sort descending instead of ascending. :param case_sensitive: When sorting strings, sort upper and lower case separately. :param attribute: When sorting objects or dicts, an attribute or key to sort by. Can use dot notation like ``"address.city"``. Can be a list of attributes like ``"age,name"``. The sort is stable, it does not change the relative order of elements that compare equal. This makes it is possible to chain sorts on different attributes and ordering. .. sourcecode:: jinja {% for user in users|sort(attribute="name") |sort(reverse=true, attribute="age") %} ... {% endfor %} As a shortcut to chaining when the direction is the same for all attributes, pass a comma separate list of attributes. .. sourcecode:: jinja {% for user users|sort(attribute="age,name") %} ... {% endfor %} .. versionchanged:: 2.11.0 The ``attribute`` parameter can be a comma separated list of attributes, e.g. ``"age,name"``. .. versionchanged:: 2.6 The ``attribute`` parameter was added. Nr2r)rGr(r)r1r'rrr/key_funcs rdo_sortr-sAX%Y~,WKKSWH %Xw 7 7 77rc#Kt|||stnd}t}|D]*}||}||vr|||V+dS)aReturns a list of unique items from the given iterable. .. sourcecode:: jinja {{ ['foo', 'bar', 'foobar', 'FooBar']|unique|list }} -> ['foo', 'bar', 'foobar'] The unique items are yielded in the same order as their first occurrence in the iterable passed to the filter. :param case_sensitive: Treat upper and lower case strings as distinct. :param attribute: Filter objects with unique values for this attribute. Nr)r6r(setadd)r1r'rr/getterseenr-rus r do_uniquer_sY~,WKKSWF 55DfTll d?? HHSMMMJJJ rct|} t|}n%#t$r|dcYSwxYwt |||st nd}|t |g||S)Nz'No aggregated item, sequence was empty.rru)r]next StopIteration undefinedr6r(r)r1r'funcrr/itfirstrs r _min_or_maxr{s eBPR PPP$$%NOOOOOPY~,WKKSWH 4ugr"" 1 1 11s!AAc2t||t||S)aReturn the smallest item from the sequence. .. sourcecode:: jinja {{ [1, 2, 3]|min }} -> 1 :param case_sensitive: Treat upper and lower case strings as distinct. :param attribute: Get the object with the min value of this attribute. )rminr1r'rr/s rdo_minr {E3 J JJrc2t||t||S)aReturn the largest item from the sequence. .. sourcecode:: jinja {{ [1, 2, 3]|max }} -> 3 :param case_sensitive: Treat upper and lower case strings as distinct. :param attribute: Get the object with the max value of this attribute. )rmaxrs rdo_maxrrrrc<t|ts|r|s|S|S)a`If the value is undefined it will return the passed default value, otherwise the value of the variable: .. sourcecode:: jinja {{ my_variable|default('my_variable is not defined') }} This will output the value of ``my_variable`` if the variable was defined, otherwise ``'my_variable is not defined'``. If you want to use default with variables that evaluate to false you have to set the second parameter to `true`: .. sourcecode:: jinja {{ ''|default('the string was empty', true) }} .. versionchanged:: 2.11 It's now possible to configure the :class:`~jinja2.Environment` with :class:`~jinja2.ChainableUndefined` to make the `default` filter work on nested elements and attributes that may contain undefined values in the chain without getting an :exc:`~jinja2.UndefinedError`. )r$r)r' default_valuebooleans r do_defaultrs/.%## LrcP|#tt|j||}|js5t |tt|St |dst|}d}t|D]*\}}t |drd}t |||<+|rt|}nt |}||St|tt|S)a#Return a string which is the concatenation of the strings in the sequence. The separator between elements is an empty string per default, you can define it with the optional parameter: .. sourcecode:: jinja {{ [1, 2, 3]|join('|') }} -> 1|2|3 {{ [1, 2, 3]|join }} -> 123 It is also possible to join certain attributes of an object: .. sourcecode:: jinja {{ users|join(', ', attribute='username') }} .. versionadded:: 2.6 The `attribute` parameter was added. NrPFT) r r6r1rbrr^rQlistr@rr )rdr'rwr/ do_escapeidxr-s rdo_joinrs._X%99EEuMM  9||  i!7!7888 1j ! ! U  "5)) - -ICtZ(( - &t__c  q AA! Avve}} ??  \5 9 9 : ::rPcFt||S)z.Centers the value in a field of a given width.)rcenter)r'widths r do_centerrs U   " "5 ) ))rc tt|S#t$r|dcYSwxYw)z$Return the first item of a sequence.z"No first item, sequence was empty.)rr]rrr1seqs rdo_firstrsTKDII KKK$$%IJJJJJKsAAc ttt|S#t$r|dcYSwxYw)z Return the last item of a sequence. Note: Does not work with generators. You may want to explicitly convert it to a list: .. sourcecode:: jinja {{ data | selectattr('name', '==', 'Jinja') | list | last }} z!No last item, sequence was empty.)rr]reversedrrrs rdo_lastrs^JD#''((( JJJ$$%HIIIIIJs(+A  A c tj|S#t$r|jdcYSwxYw)z'Return a random item from the sequence.z#No random item, sequence was empty.)randomchoice IndexErrorr1r)contextrs r do_randomrsUT}S!!! TTT",,-RSSSSSTs $==c$t|}|rdpd}|rdpd|rdpd|rdpd|rd pd |rd pd |rd pd|rdpd|rdpdg}|dkrdS||krd|zSt|D]"\}}||dzz}||krd||z|z |fzcS#d||z|z |fzS)zFormat the value like a 'human-readable' file size (i.e. 13 kB, 4.1 MB, 102 Bytes, etc). Per default decimal prefixes are used (Mega, Giga, etc.), if the second parameter is set to `True` the binary prefixes are used (Mebi, Gibi). iiKiBkBMiBMBGiBGBTiBTBPiBPBEiBEBZiBZBYiBYBr z1 Bytez%d Bytesz%.1f %s)floatr@)r'binarybytesbaseprefixesrBprefixunits rdo_filesizeformatrs  %LLE ?d "dD  E !T  E !T  E !T  E !T  E !T  E !T  E !T  E !T H zzx E!!"8,, C CIAvAE?Dt|| TE\D%86#BBBBBTE\D06:::rc$t||S)zPretty print a variable. Useful for debugging. With Jinja 1.2 onwards you can pass it a parameter. If this parameter is truthy the output will be more verbose (this requires `pretty`) )verboser)r'rs r do_pprintr<s 5' * * **rc|jj}t|pdpg}|r|d||dpd||d}dt|pd}t||||}|j rt|}|S)aUConverts URLs in plain text into clickable links. If you pass the filter an additional integer it will shorten the urls to that number. Also a third argument exists that makes the urls "nofollow": .. sourcecode:: jinja {{ mytext|urlize(40, true) }} links are shortened to 40 chars and defined with rel="nofollow" If *target* is specified, the ``target`` attribute will be added to the ```` tag: .. sourcecode:: jinja {{ mytext|urlize(40, target='_blank') }} .. versionchanged:: 2.8+ The *target* parameter was added. rnofollowz urlize.relNz urlize.targetrr)reltarget) r1policiesrrErupdater^rrrbr)rdr'trim_url_limitrrrrrys r do_urlizerEs2#,H syb!!'R ( (C  JJ&,"3355666 ~/* ((6#;;   '4C ~3v > > >B BZZ Irc|tjdtd|}d|zd}t|trt t |}||z }|r+|z|}nR|}|d}|r'|||fd|Dzz }|r|z}|S) aReturn a copy of the string with each line indented by 4 spaces. The first line and blank lines are not indented by default. :param width: Number of spaces to indent by. :param first: Don't skip indenting the first line. :param blank: Don't skip indenting empty lines. .. versionchanged:: 2.10 Blank lines are not indented by default. Rename the ``indentfirst`` argument to ``first``. NzTThe 'indentfirst' argument is renamed to 'first' and will be removed in version 3.0.r) stacklevelrr rc3*K|] }|r|zn|VdSr+r:)r;line indentions rrZzdo_indent..sC))7;D2 D  d))))))r)warningswarnDeprecationWarningr$rr^ splitlinespop) rerrblank indentfirstnewlinerylinesrs @r do_indentrls$  *      u IG!V"9%% //LA  ! ' '  7 7  YYq\\   'GLL))))?D))) B  ^ Ir...c| |jd}|t|ksJdt|d||dks Jd|zt|||zkr|S|r|d|t|z |zS|d|t|z ddd}||zS) aReturn a truncated copy of the string. The length is specified with the first parameter which defaults to ``255``. If the second parameter is ``true`` the filter will cut the text at length. Otherwise it will discard the last word. If the text was in fact truncated it will append an ellipsis sign (``"..."``). If you want a different ellipsis sign than ``"..."`` you can specify it using the third parameter. Strings that only exceed the length by the tolerance margin given in the fourth parameter will not be truncated. .. sourcecode:: jinja {{ "foo bar baz qux"|truncate(9) }} -> "foo..." {{ "foo bar baz qux"|truncate(9, True) }} -> "foo ba..." {{ "foo bar baz qux"|truncate(11) }} -> "foo bar baz qux" {{ "foo bar baz qux"|truncate(11, False, '...', 0) }} -> "foo bar..." The default leeway on newer Jinja versions is 5 and was 0 before but can be reconfigured globally. Nztruncate.leewayzexpected length >= z, got rzexpected leeway >= 0, got %srrr )rr?rsplit)envrelength killwordsendleewayresults r do_truncaters2~/0 SXX    #c((((FFS    Q;;;6?;;; 1vv&  ,$6CHH$$%++ "#c(("" # * *3 2 21 5F C<rOcddls|jfd|DS)aWrap a string to the given width. Existing newlines are treated as paragraphs to be wrapped separately. :param s: Original text to wrap. :param width: Maximum length of wrapped lines. :param break_long_words: If a word is longer than ``width``, break it across lines. :param break_on_hyphens: If a word contains hyphens, it may be split across lines. :param wrapstring: String to join each wrapped line. Defaults to :attr:`Environment.newline_sequence`. .. versionchanged:: 2.11 Existing newlines are treated as paragraphs wrapped separately. .. versionchanged:: 2.11 Added the ``break_on_hyphens`` parameter. .. versionchanged:: 2.7 Added the ``wrapstring`` parameter. rNc lg|]0}|dd1S)F)r expand_tabsreplace_whitespacebreak_long_wordsbreak_on_hyphens)r^wrap)r;rr r textwrapr wrapstrings rr=zdo_wordwrap..sa  OO  %',%5%5    r)r newline_sequencer^r)r1rerr r r r s ````@r do_wordwraprs~>OOO 2 1 ??     rcjttt|S)zCount the words in that string.)r?_word_refindallr rls r do_wordcountrs$ x Q00 1 11r c  t|trt||St|S#ttf$r; tt |cYS#ttf$r|cYcYSwxYwwxYw)aConvert the value into an integer. If the conversion doesn't work it will return ``0``. You can override this default using the first parameter. You can also override the default base (10) in the second parameter, which handles input with prefixes such as 0b, 0o and 0x for bases 2, 8 and 16 respectively. The base is ignored for decimal numbers and non-string values. )r$rrK TypeError ValueErrorr)r'r0rs rdo_intrs  e\ * * $ud## #5zz z " uU||$$ $ $ $:&   NNNNN  s1$66BA&#B&A>9B=A>>BcT t|S#ttf$r|cYSwxYw)zConvert the value into a floating point number. If the conversion doesn't work it will return ``0.0``. You can override this default using the first parameter. )rrr)r'r0s rdo_floatrs< U|| z "s ''cP|r|rtdt||p|zS)aApply the given values to a `printf-style`_ format string, like ``string % values``. .. sourcecode:: jinja {{ "%s, %s!"|format(greeting, name) }} Hello, World! In most cases it should be more convenient and efficient to use the ``%`` operator or :meth:`str.format`. .. code-block:: text {{ "%s, %s!" % (greeting, name) }} {{ "{}, {}!".format(greeting, name) }} .. _printf-style: https://docs.python.org/library/stdtypes.html #printf-style-string-formatting z>can't handle positional and keyword arguments at the same time)rr )r'argskwargss r do_formatrsA(   ! L      &.D 11rcFt||S)z=Strip leading and trailing characters, by default whitespace.)r strip)r'charss rdo_trimr#:s    $ $U + ++rct|dr|}tt|S)zAStrip SGML/XML tags and replace adjacent whitespace by one space.rP)rQrPrr striptagsr&s r do_striptagsr&?sEuj!!!   )E"" # # - - / //rc#Kt|}t|}||z}||z}d}t|D]K}|||zz} ||kr|dz }||dz|zz} || | } |||kr| || VLdS)aFSlice an iterator and return a list of lists containing those items. Useful if you want to create a div containing three ul tags that represent columns: .. sourcecode:: html+jinja
{%- for column in items|slice(3) %}
    {%- for item in column %}
  • {{ item }}
  • {%- endfor %}
{%- endfor %}
If you pass it a second argument it's used to fill missing values on the last iteration. rr N)rr?rangeappend) r'slices fill_withrritems_per_sliceslices_with_extraoffset slice_numberstartrtmps rdo_slicer2Fs( u++C XXF&O Ff  77 + + + aKF q(O;;%)n  \5F%F%F JJy ! ! ! rc#Kg}|D]0}t||kr|Vg}||1|r4|,t||kr||g|t|z zz }|VdSdS)a  A filter that batches items. It works pretty much like `slice` just the other way round. It returns a list of lists with the given number of items. If you provide a second parameter this is used to fill up missing items. See this example: .. sourcecode:: html+jinja {%- for row in items|batch(3, ' ') %} {%- for column in row %} {%- endfor %} {%- endfor %}
{{ column }}
N)r?r))r' linecountr+r1r-s rdo_batchr5js& C s88y IIIC 4   SXX %9%9 I;)c#hh"67 7C rcommonc|dvrtd|dkrt||Stt|}||d|zzd|zz S)aRound the number to a given precision. The first parameter specifies the precision (default is ``0``), the second the rounding method: - ``'common'`` rounds either up or down - ``'ceil'`` always rounds up - ``'floor'`` always rounds down If you don't specify a method ``'common'`` is used. .. sourcecode:: jinja {{ 42.55|round }} -> 43.0 {{ 42.55|round(1, 'floor') }} -> 42.5 Note that even if rounded to 0 precision, a float is returned. If you need a real integer, pipe it through `int`: .. sourcecode:: jinja {{ 42.55|round|int }} -> 43 >ceilfloorr6z$method must be common, ceil or floorr6r)rroundgetattrmath)r' precisionmethodrs rdo_roundr?sk4000!"HIII UI&&& 4 D 4y) * *bIo >>r _GroupTuplegrouperrctt||}dtt|||DS)aGroup a sequence of objects by an attribute using Python's :func:`itertools.groupby`. The attribute can use dot notation for nested access, like ``"address.city"``. Unlike Python's ``groupby``, the values are sorted first so only one group is returned for each unique value. For example, a list of ``User`` objects with a ``city`` attribute can be rendered in groups. In this example, ``grouper`` refers to the ``city`` value of the group. .. sourcecode:: html+jinja
    {% for city, items in users|groupby("city") %}
  • {{ city }}
      {% for user in items %}
    • {{ user.name }} {% endfor %}
  • {% endfor %}
``groupby`` yields namedtuples of ``(grouper, list)``, which can be used instead of the tuple unpacking above. ``grouper`` is the value of the attribute, and ``list`` is the items with that value. .. sourcecode:: html+jinja
    {% for group in users|groupby("city") %}
  • {{ group.grouper }}: {{ group.list|join(", ") }} {% endfor %}
.. versionchanged:: 2.6 The attribute supports dot notation for nested access. cNg|]"\}}t|t|#Sr:)r@r)r;ruvaluess rr=zdo_groupby..s<    C Cf&&   rr)r6rr)r1r'r/exprs r do_groupbyrFsLF ; 2 2D  "6%T#:#:#:DAA   rcb|tt|||}t||S)aReturns the sum of a sequence of numbers plus the value of parameter 'start' (which defaults to 0). When the sequence is empty it returns start. It is also possible to sum up only certain attributes: .. sourcecode:: jinja Total: {{ items|sum(attribute='price') }} .. versionchanged:: 2.6 The `attribute` parameter was added to allow suming up over attributes. Also the `start` parameter was moved on to the right. )r r6sum)r1iterabler/r0s rdo_sumrJs3  Y??JJ x  rc t|S)zkConvert the value into a list. If it was a string the returned list will be a list of characters. )rr&s rdo_listrLs ;;rc t|S)zMark the value as safe which means that in an environment with automatic escaping enabled this variable will not be escaped. rr&s r do_mark_saferNs %==rc t|S)zHMark a value as unsafe. This is the reverse operation for :func:`safe`.rr&s rdo_mark_unsaferPs U  rct|tr |dddS t|S#t$rF t |}||cYS#t$rt dwxYwwxYw)z\Reverse the object or return an iterator that iterates over it the other way round. Nrazargument must be iterable)r$rrrrrr)r'rys r do_reverserRs%&&TTrT{C CCC CeB JJLLLIII C C C%&ABB B C Cs 1 B$A# B#A==Bc t|} t||}|jr-||||s|||S|S#t $rYnwxYw#t $rYnwxYw|||S)zGet an attribute of an object. ``foo|attr("bar")`` works like ``foo.bar`` just that always an attribute is returned and items are not looked up. See :ref:`Notes on subscriptions ` for more details. )objname)strr; sandboxedis_safe_attributeunsafe_undefinedAttributeError UnicodeErrorr)r1rTrUr's rdo_attrr\s4yy C&&E$ ?[-J-JT5.. ?#33C>>>L    D         St 4 44s"A(A A%$A%( A54A5c/\Kt||\}}|r|D]}||VdSdS)aApplies a filter on a sequence of objects or looks up an attribute. This is useful when dealing with lists of objects but you are really only interested in a certain value of it. The basic usage is mapping on an attribute. Imagine you have a list of users but you are only interested in a list of usernames: .. sourcecode:: jinja Users on this page: {{ users|map(attribute='username')|join(', ') }} You can specify a ``default`` value to use if an object in the list does not have the given attribute. .. sourcecode:: jinja {{ users|map(attribute="username", default="Anonymous")|join(", ") }} Alternatively you can let it invoke a filter by passing the name of the filter and the arguments afterwards. A good example would be applying a text conversion filter on a sequence: .. sourcecode:: jinja Users on this page: {{ titles|map('lower')|join(', ') }} Similar to a generator comprehension such as: .. code-block:: python (u.username for u in users) (u.username or "Anonymous" for u in users) (do_lower(x) for x in titles) .. versionchanged:: 2.11.0 Added the ``default`` parameter. .. versionadded:: 2.7 N) prepare_map)rrrrr-s rdo_mapr_2s^RD&))IC   D$t**      rc(t||ddS)aFilters a sequence of objects by applying a test to each object, and only selecting the objects with the test succeeding. If no test is specified, each object will be evaluated as a boolean. Example usage: .. sourcecode:: jinja {{ numbers|select("odd") }} {{ numbers|select("odd") }} {{ numbers|select("divisibleby", 3) }} {{ numbers|select("lessthan", 42) }} {{ strings|select("equalto", "mystring") }} Similar to a generator comprehension such as: .. code-block:: python (n for n in numbers if test_odd(n)) (n for n in numbers if test_divisibleby(n, 3)) .. versionadded:: 2.7 c|Sr+r:rLs rzdo_select..{ArFselect_or_rejectrrs r do_selectrhas4 D&++u = ==rc(t||ddS)aFilters a sequence of objects by applying a test to each object, and rejecting the objects with the test succeeding. If no test is specified, each object will be evaluated as a boolean. Example usage: .. sourcecode:: jinja {{ numbers|reject("odd") }} Similar to a generator comprehension such as: .. code-block:: python (n for n in numbers if not test_odd(n)) .. versionadded:: 2.7 c| Sr+r:rbs rrczdo_reject..ErFrergs r do_rejectrl~s* D&//5 A AArc(t||ddS)aWFilters a sequence of objects by applying a test to the specified attribute of each object, and only selecting the objects with the test succeeding. If no test is specified, the attribute's value will be evaluated as a boolean. Example usage: .. sourcecode:: jinja {{ users|selectattr("is_active") }} {{ users|selectattr("email", "none") }} Similar to a generator comprehension such as: .. code-block:: python (u for user in users if user.is_active) (u for user in users if test_none(user.email)) .. versionadded:: 2.7 c|Sr+r:rbs rrczdo_selectattr..rdrTrergs r do_selectattrros2 D&++t < <.rkrTrergs r do_rejectattrrrs. D&//4 @ @@rc|jj}|d}|d}|t|}||d<t|fd|i|S)aDumps a structure to JSON so that it's safe to use in ``