
 `Tc           @   s  d  Z  d d l Z d d l Z d d l m Z d d l m Z d d l m Z d d l	 m
 Z
 m Z m Z m Z m Z m Z d d l m Z d d l m Z d d	 l m Z m Z m Z m Z m Z e j d
  Z d   Z d   Z d   Z d   Z d   Z  d   Z! e d d   Z# d   Z$ d   Z% e e& d   Z' d   Z( d   Z) e* d d  Z+ e e* e* d d   Z, d e* d  Z- e d d d   Z. d d  Z/ e d    Z0 e d     Z1 e d!    Z2 e* d"  Z3 e* d#  Z4 e d e* d$   Z5 d% e* d&  Z6 d' e* d( d)  Z7 e d* e& d d+   Z8 d,   Z9 d- d.  Z: d/ d0  Z; d1   Z< d2   Z= d3   Z> d d4  Z? d d5  Z@ d- d6 d7  ZA e d8    ZB d9 eC f d:     YZD e d d- d;   ZE d<   ZF d=   ZG d>   ZH d?   ZI e d@    ZJ e dA    ZK e dB    ZL e dC    ZM e dD    ZN e dE    ZO dF   ZP i3 eJ dG 6e# dH 6e$ dI 6e% dJ 6e dK 6e dL 6e  dM 6e( dN 6e) dO 6e- dP 6e- dQ 6e. dR 6eQ dS 6e+ dT 6e, dU 6eQ dV 6eI dW 6e/ dX 6e6 dY 6e) dO 6e( dN 6e0 dZ 6e1 d[ 6eK d\ 6e2 d] 6eM d^ 6eO d_ 6e3 d` 6e4 da 6e7 db 6e8 dc 6e9 dd 6e: de 6e; df 6e dg 6eF dh 6e5 di 6e< dj 6e= dk 6e> dl 6eL dm 6eN dn 6e? do 6e@ dp 6eE dq 6eR dr 6eA ds 6eB dt 6eG du 6e' dv 6e! dw 6ZS d S(x   s   
    jinja2.filters
    ~~~~~~~~~~~~~~

    Bundled jinja filters.

    :copyright: (c) 2010 by the Jinja Team.
    :license: BSD, see LICENSE for more details.
iN(   t   choice(   t
   itemgetter(   t   groupby(   t   Markupt   escapet   pformatt   urlizet   soft_unicodet   unicode_urlencode(   t	   Undefined(   t   FilterArgumentError(   t   nextt   imapt   string_typest	   text_typet	   iteritemss   \w+(?u)c         C   s   t  |  _ |  S(   sx   Decorator for marking context dependent filters. The current
    :class:`Context` will be passed as first argument.
    (   t   Truet   contextfilter(   t   f(    (    sT   /var/www/send.findwatt.com/datamanager/lib/python2.7/site-packages/jinja2/filters.pyR      s    	c         C   s   t  |  _ |  S(   s   Decorator 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
    (   R   t   evalcontextfilter(   R   (    (    sT   /var/www/send.findwatt.com/datamanager/lib/python2.7/site-packages/jinja2/filters.pyR   #   s    	c         C   s   t  |  _ |  S(   s   Decorator for marking evironment dependent filters.  The current
    :class:`Environment` is passed to the filter as first argument.
    (   R   t   environmentfilter(   R   (    (    sT   /var/www/send.findwatt.com/datamanager/lib/python2.7/site-packages/jinja2/filters.pyR   .   s    	c            s^   t   t  s) d  k r9  j   r9    f d   S j d      f d   } | S(   s   Returns 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.
    t   .c            s     j  |    S(   N(   t   getitem(   t   x(   t   environmentt	   attribute(    sT   /var/www/send.findwatt.com/datamanager/lib/python2.7/site-packages/jinja2/filters.pyt   <lambda>>   s    c            sB   x;  D]3 } | j    r( t |  } n    j |  |  }  q W|  S(   N(   t   isdigitt   intR   (   t   itemt   part(   R   R   (    sT   /var/www/send.findwatt.com/datamanager/lib/python2.7/site-packages/jinja2/filters.pyt
   attrgetter@   s
    (   t
   isinstanceR   R   t   split(   R   R   R   (    (   R   R   sT   /var/www/send.findwatt.com/datamanager/lib/python2.7/site-packages/jinja2/filters.pyt   make_attrgetter6   s    c         C   s.   t  |  d  r |  j   }  n  t t |    S(   sC   Enforce HTML escaping.  This will probably double escape variables.t   __html__(   t   hasattrR#   R   R   (   t   value(    (    sT   /var/www/send.findwatt.com/datamanager/lib/python2.7/site-packages/jinja2/filters.pyt   do_forceescapeI   s    c         C   s   d } t |  t  r$ t |   } n6 t |  t  sZ y t |   } WqZ t k
 rV qZ Xn  | d k rp t |   Sd j d   | D  S(   s   Escape strings for use in URLs (uses UTF-8 encoding).  It accepts both
    dictionaries and regular strings as well as pairwise iterables.

    .. versionadded:: 2.7
    u   &c         s   s/   |  ]% \ } } t  |  d  t  |  Vq d S(   t   =N(   R   (   t   .0t   kt   v(    (    sT   /var/www/send.findwatt.com/datamanager/lib/python2.7/site-packages/jinja2/filters.pys	   <genexpr>`   s   N(	   t   NoneR    t   dictR   R   t   itert	   TypeErrorR   t   join(   R%   t   itemiter(    (    sT   /var/www/send.findwatt.com/datamanager/lib/python2.7/site-packages/jinja2/filters.pyt   do_urlencodeP   s    
c         C   s   | d k r d } n  |  j sC t |  j t |  t |  |  St | d  sq t | d  r t | d  r t |  } n t |  } | j t |  t |  |  S(   s  Return 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
    iR#   N(   R+   t
   autoescapeR   t   replaceR$   R   R   (   t   eval_ctxt   st   oldt   newt   count(    (    sT   /var/www/send.findwatt.com/datamanager/lib/python2.7/site-packages/jinja2/filters.pyt
   do_replaced   s    		%c         C   s   t  |   j   S(   s   Convert a value to uppercase.(   R   t   upper(   R5   (    (    sT   /var/www/send.findwatt.com/datamanager/lib/python2.7/site-packages/jinja2/filters.pyt   do_upper   s    c         C   s   t  |   j   S(   s   Convert a value to lowercase.(   R   t   lower(   R5   (    (    sT   /var/www/send.findwatt.com/datamanager/lib/python2.7/site-packages/jinja2/filters.pyt   do_lower   s    c         C   sT   d j  d   t |  D  } | r8 | r8 d | } n  |  j rP t |  } n  | S(   sc  Create 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

        <ul{{ {'class': 'my_list', 'missing': none,
                'id': 'list-%d'|format(variable)}|xmlattr }}>
        ...
        </ul>

    Results in something like this:

    .. sourcecode:: html

        <ul class="my_list" id="list-42">
        ...
        </ul>

    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.
    u    c         s   sM   |  ]C \ } } | d k	 r t | t  r d  t |  t |  f Vq d S(   u   %s="%s"N(   R+   R    R	   R   (   R(   t   keyR%   (    (    sT   /var/www/send.findwatt.com/datamanager/lib/python2.7/site-packages/jinja2/filters.pys	   <genexpr>   s   	(   R/   R   R2   R   (   t	   _eval_ctxt   dt	   autospacet   rv(    (    sT   /var/www/send.findwatt.com/datamanager/lib/python2.7/site-packages/jinja2/filters.pyt
   do_xmlattr   s    	c         C   s   t  |   j   S(   sY   Capitalize a value. The first character will be uppercase, all others
    lowercase.
    (   R   t
   capitalize(   R5   (    (    sT   /var/www/send.findwatt.com/datamanager/lib/python2.7/site-packages/jinja2/filters.pyt   do_capitalize   s    c         C   sg   g  } xQ t  j d  j |   D]7 } | s1 q n  | j | d j   | d j    q Wd j |  S(   s   Return a titlecased version of the value. I.e. words will start with
    uppercase letters, all remaining characters are lowercase.
    s   ([-\s]+)(?u)i    i   t    (   t   ret   compileR!   t   appendR:   R<   R/   (   R5   RB   R   (    (    sT   /var/www/send.findwatt.com/datamanager/lib/python2.7/site-packages/jinja2/filters.pyt   do_title   s    )R>   c            s^   | d k r d   n! | d k r* d   n t  d      f d   } t |  j   d | S(   s  Sort 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(true) %}
            sort the dict by key, case sensitive

        {% for item in mydict|dictsort(false, 'value') %}
            sort the dict by key, case insensitive, sorted
            normally and ordered by value.
    R>   i    R%   i   s,   You can only sort by either "key" or "value"c            s3   |    } t  | t  r/  r/ | j   } n  | S(   N(   R    R   R<   (   R   R%   (   t   post   case_sensitive(    sT   /var/www/send.findwatt.com/datamanager/lib/python2.7/site-packages/jinja2/filters.pyt	   sort_func   s    
(   R
   t   sortedt   items(   R%   RL   t   byRM   (    (   RK   RL   sT   /var/www/send.findwatt.com/datamanager/lib/python2.7/site-packages/jinja2/filters.pyt   do_dictsort   s    		c            sg   | s d   } n d } | d k	 rQ t |  |    | p? d     f d  } n  t | d | d | S(   s  Sort an iterable.  Per default it sorts ascending, if you pass it
    true as first argument it will reverse the sorting.

    If the iterable is made of strings the third parameter can be used to
    control the case sensitiveness of the comparison which is disabled by
    default.

    .. sourcecode:: jinja

        {% for item in iterable|sort %}
            ...
        {% endfor %}

    It is also possible to sort by an attribute (for example to sort
    by the date of an object) by specifying the `attribute` parameter:

    .. sourcecode:: jinja

        {% for item in iterable|sort(attribute='date') %}
            ...
        {% endfor %}

    .. versionchanged:: 2.6
       The `attribute` parameter was added.
    c         S   s"   t  |  t  r |  j   }  n  |  S(   N(   R    R   R<   (   R   (    (    sT   /var/www/send.findwatt.com/datamanager/lib/python2.7/site-packages/jinja2/filters.pyRM      s    c         S   s   |  S(   N(    (   R   (    (    sT   /var/www/send.findwatt.com/datamanager/lib/python2.7/site-packages/jinja2/filters.pyR     s    c            s   |   |    S(   N(    (   R   t	   processor(   t   getter(    sT   /var/www/send.findwatt.com/datamanager/lib/python2.7/site-packages/jinja2/filters.pyRM     s    R>   t   reverseN(   R+   R"   RN   (   R   R%   RT   RL   R   RM   (    (   RS   sT   /var/www/send.findwatt.com/datamanager/lib/python2.7/site-packages/jinja2/filters.pyt   do_sort   s    u    c         C   s$   t  |  t  s | r  |  r  | S|  S(   s  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) }}
    (   R    R	   (   R%   t   default_valuet   boolean(    (    sT   /var/www/send.findwatt.com/datamanager/lib/python2.7/site-packages/jinja2/filters.pyt
   do_default  s    c         C   s   | d k	 r* t t |  j |  |  } n  |  j sO t |  j t t |   St | d  s t |  } t	 } xB t
 |  D]4 \ } } t | d  r t } q} t |  | | <q} W| r t |  } n t |  } | j |  St |  j t t |   S(   s#  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.
    R#   N(   R+   R   R"   R   R2   R   R/   R$   t   listt   Falset	   enumerateR   R   R   (   R4   R%   R@   R   t	   do_escapet   idxR   (    (    sT   /var/www/send.findwatt.com/datamanager/lib/python2.7/site-packages/jinja2/filters.pyt   do_join"  s     		iP   c         C   s   t  |   j |  S(   s.   Centers the value in a field of a given width.(   R   t   center(   R%   t   width(    (    sT   /var/www/send.findwatt.com/datamanager/lib/python2.7/site-packages/jinja2/filters.pyt	   do_centerT  s    c         C   s6   y t  t |   SWn t k
 r1 |  j d  SXd S(   s$   Return the first item of a sequence.s"   No first item, sequence was empty.N(   R   R-   t   StopIterationt	   undefined(   R   t   seq(    (    sT   /var/www/send.findwatt.com/datamanager/lib/python2.7/site-packages/jinja2/filters.pyt   do_firstY  s    c         C   s<   y t  t t |    SWn t k
 r7 |  j d  SXd S(   s#   Return the last item of a sequence.s!   No last item, sequence was empty.N(   R   R-   t   reversedRb   Rc   (   R   Rd   (    (    sT   /var/www/send.findwatt.com/datamanager/lib/python2.7/site-packages/jinja2/filters.pyt   do_lastb  s    c         C   s0   y t  |  SWn t k
 r+ |  j d  SXd S(   s'   Return a random item from the sequence.s#   No random item, sequence was empty.N(   R    t
   IndexErrorRc   (   R   Rd   (    (    sT   /var/www/send.findwatt.com/datamanager/lib/python2.7/site-packages/jinja2/filters.pyt	   do_randomk  s    c         C   s'  t  |   } | r d p d } | r* d p- d | r9 d p< d | rH d pK d | rW d	 pZ d
 | rf d pi d | ru d px d | r d p d | r d p d g } | d k r d S| | k  r d | SxJ t |  D]< \ } } | | d } | | k  r d | | | | f Sq Wd | | | | f Sd S(   s   Format 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).
    i   i  t   KiBt   kBt   MiBt   MBt   GiBt   GBt   TiBt   TBt   PiBt   PBt   EiBt   EBt   ZiBt   ZBt   YiBt   YBi   s   1 Bytes   %d Bytesi   s   %.1f %sN(   t   floatR[   (   R%   t   binaryt   bytest   baset   prefixest   it   prefixt   unit(    (    sT   /var/www/send.findwatt.com/datamanager/lib/python2.7/site-packages/jinja2/filters.pyt   do_filesizeformatt  s&    c         C   s   t  |  d | S(   s   Pretty 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`)
    t   verbose(   R   (   R%   R   (    (    sT   /var/www/send.findwatt.com/datamanager/lib/python2.7/site-packages/jinja2/filters.pyt	   do_pprint  s    c         C   s.   t  | | |  } |  j r* t |  } n  | S(   sd  Converts 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"
    (   R   R2   R   (   R4   R%   t   trim_url_limitt   nofollowRB   (    (    sT   /var/www/send.findwatt.com/datamanager/lib/python2.7/site-packages/jinja2/filters.pyt	   do_urlize  s    	i   c         C   s:   d | } d | j  |  j    } | r6 | | } n  | S(   so  Return a copy of the passed string, each line indented by
    4 spaces. The first line is not indented. If you want to
    change the number of spaces or indent the first line too
    you can pass additional parameters to the filter:

    .. sourcecode:: jinja

        {{ mytext|indent(2, true) }}
            indent by two spaces and indent the first line too.
    u    u   
(   R/   t
   splitlines(   R5   R`   t   indentfirstt	   indentionRB   (    (    sT   /var/www/send.findwatt.com/datamanager/lib/python2.7/site-packages/jinja2/filters.pyt	   do_indent  s
    
i   s   ...c         C   s   t  |   | k r |  S| r( |  |  | S|  j d  } g  } d } x? | D]7 } | t  |  d 7} | | k rt Pn  | j |  qJ W| j |  d j |  S(   sS  Return 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.

    .. sourcecode:: jinja

        {{ "foo bar"|truncate(5) }}
            -> "foo ..."
        {{ "foo bar"|truncate(5, True) }}
            -> "foo b..."
    t    i    i   u    (   t   lenR!   RI   R/   (   R5   t   lengtht	   killwordst   endt   wordst   resultt   mt   word(    (    sT   /var/www/send.findwatt.com/datamanager/lib/python2.7/site-packages/jinja2/filters.pyt   do_truncate  s    iO   c         C   sL   | s |  j  } n  d d l } | j | j | d | d t d t d |  S(   s  
    Return a copy of the string passed to the filter wrapped after
    ``79`` characters.  You can override this default using the first
    parameter.  If you set the second parameter to `false` Jinja will not
    split words apart if they are longer than `width`. By default, the newlines
    will be the default newlines for the environment, but this can be changed
    using the wrapstring keyword argument.

    .. versionadded:: 2.7
       Added support for the `wrapstring` parameter.
    iNR`   t   expand_tabst   replace_whitespacet   break_long_words(   t   newline_sequencet   textwrapR/   t   wrapRZ   (   R   R5   R`   R   t
   wrapstringR   (    (    sT   /var/www/send.findwatt.com/datamanager/lib/python2.7/site-packages/jinja2/filters.pyt   do_wordwrap  s    c         C   s   t  t j |    S(   s   Count the words in that string.(   R   t   _word_ret   findall(   R5   (    (    sT   /var/www/send.findwatt.com/datamanager/lib/python2.7/site-packages/jinja2/filters.pyt   do_wordcount  s    i    c         C   s[   y t  |   SWnF t t f k
 rV y t  t |    SWqW t t f k
 rR | SXn Xd S(   s   Convert the value into an integer. If the
    conversion doesn't work it will return ``0``. You can
    override this default using the first parameter.
    N(   R   R.   t
   ValueErrorRz   (   R%   t   default(    (    sT   /var/www/send.findwatt.com/datamanager/lib/python2.7/site-packages/jinja2/filters.pyt   do_int  s    g        c         C   s-   y t  |   SWn t t f k
 r( | SXd S(   s   Convert 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.
    N(   Rz   R.   R   (   R%   R   (    (    sT   /var/www/send.findwatt.com/datamanager/lib/python2.7/site-packages/jinja2/filters.pyt   do_float	  s    c         O   s/   | r | r t  d   n  t |   | p- | S(   s   
    Apply python string formatting on an object:

    .. sourcecode:: jinja

        {{ "%s - %s"|format("Hello?", "Foo!") }}
            -> Hello? - Foo!
    s>   can't handle positional and keyword arguments at the same time(   R
   R   (   R%   t   argst   kwargs(    (    sT   /var/www/send.findwatt.com/datamanager/lib/python2.7/site-packages/jinja2/filters.pyt	   do_format  s    	c         C   s   t  |   j   S(   s&   Strip leading and trailing whitespace.(   R   t   strip(   R%   (    (    sT   /var/www/send.findwatt.com/datamanager/lib/python2.7/site-packages/jinja2/filters.pyt   do_trim#  s    c         C   s4   t  |  d  r |  j   }  n  t t |    j   S(   sF   Strip SGML/XML tags and replace adjacent whitespace by one space.
    R#   (   R$   R#   R   R   t	   striptags(   R%   (    (    sT   /var/www/send.findwatt.com/datamanager/lib/python2.7/site-packages/jinja2/filters.pyt   do_striptags(  s    c         c   s   t  |   } t |  } | | } | | } d } x t |  D]y } | | | }	 | | k  rl | d 7} n  | | d | }
 | |	 |
 !} | d k	 r | | k r | j |  n  | Vq? Wd S(   sE  Slice 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

        <div class="columwrapper">
          {%- for column in items|slice(3) %}
            <ul class="column-{{ loop.index }}">
            {%- for item in column %}
              <li>{{ item }}</li>
            {%- endfor %}
            </ul>
          {%- endfor %}
        </div>

    If you pass it a second argument it's used to fill missing
    values on the last iteration.
    i    i   N(   RY   R   t   rangeR+   RI   (   R%   t   slicest	   fill_withRd   R   t   items_per_slicet   slices_with_extrat   offsett   slice_numbert   startR   t   tmp(    (    sT   /var/www/send.findwatt.com/datamanager/lib/python2.7/site-packages/jinja2/filters.pyt   do_slice0  s    

c         c   s   g  } g  } x; |  D]3 } t  |  | k r9 | Vg  } n  | j |  q W| r | d k	 r t  |  | k  r | | g | t  |  7} n  | Vn  d S(   s  
    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

        <table>
        {%- for row in items|batch(3, '&nbsp;') %}
          <tr>
          {%- for column in row %}
            <td>{{ column }}</td>
          {%- endfor %}
          </tr>
        {%- endfor %}
        </table>
    N(   R   RI   R+   (   R%   t	   linecountR   R   R   R   (    (    sT   /var/www/send.findwatt.com/datamanager/lib/python2.7/site-packages/jinja2/filters.pyt   do_batchT  s    	t   commonc         C   s]   | d k r t  d   n  | d k r4 t |  |  St t |  } | |  d |  d | S(   s  Round 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
    R   t   ceilt   floors$   method must be common, ceil or floori
   (   R   R   R   (   R
   t   roundt   getattrt   math(   R%   t	   precisiont   methodt   func(    (    sT   /var/www/send.findwatt.com/datamanager/lib/python2.7/site-packages/jinja2/filters.pyt   do_roundt  s    c         C   s7   t  |  |  } t t t t t | d | |    S(   s  Group a sequence of objects by a common attribute.

    If you for example have a list of dicts or objects that represent persons
    with `gender`, `first_name` and `last_name` attributes and you want to
    group all users by genders you can do something like the following
    snippet:

    .. sourcecode:: html+jinja

        <ul>
        {% for group in persons|groupby('gender') %}
            <li>{{ group.grouper }}<ul>
            {% for person in group.list %}
                <li>{{ person.first_name }} {{ person.last_name }}</li>
            {% endfor %}</ul></li>
        {% endfor %}
        </ul>

    Additionally it's possible to use tuple unpacking for the grouper and
    list:

    .. sourcecode:: html+jinja

        <ul>
        {% for grouper, list in persons|groupby('gender') %}
            ...
        {% endfor %}
        </ul>

    As you can see the item we're grouping by is stored in the `grouper`
    attribute and the `list` contains all the objects that have this grouper
    in common.

    .. versionchanged:: 2.6
       It's now possible to use dotted notation to group by the child
       attribute of another attribute.
    R>   (   R"   RN   t   mapt   _GroupTupleR   (   R   R%   R   t   expr(    (    sT   /var/www/send.findwatt.com/datamanager/lib/python2.7/site-packages/jinja2/filters.pyt
   do_groupby  s    'R   c           B   s;   e  Z d Z e e d    Z e e d   Z d   Z RS(   i    i   c         C   s(   | \ } } t  j |  | t |  f  S(   N(   t   tuplet   __new__RY   (   t   clst   xxx_todo_changemeR>   R%   (    (    sT   /var/www/send.findwatt.com/datamanager/lib/python2.7/site-packages/jinja2/filters.pyR     s    (    (   t   __name__t
   __module__t	   __slots__t   propertyR   t   grouperRY   R   (    (    (    sT   /var/www/send.findwatt.com/datamanager/lib/python2.7/site-packages/jinja2/filters.pyR     s   c         C   s4   | d k	 r' t t |  |  |  } n  t | |  S(   s  Returns 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.
    N(   R+   R   R"   t   sum(   R   t   iterableR   R   (    (    sT   /var/www/send.findwatt.com/datamanager/lib/python2.7/site-packages/jinja2/filters.pyt   do_sum  s    c         C   s
   t  |   S(   sk   Convert the value into a list.  If it was a string the returned list
    will be a list of characters.
    (   RY   (   R%   (    (    sT   /var/www/send.findwatt.com/datamanager/lib/python2.7/site-packages/jinja2/filters.pyt   do_list  s    c         C   s
   t  |   S(   s   Mark the value as safe which means that in an environment with automatic
    escaping enabled this variable will not be escaped.
    (   R   (   R%   (    (    sT   /var/www/send.findwatt.com/datamanager/lib/python2.7/site-packages/jinja2/filters.pyt   do_mark_safe  s    c         C   s
   t  |   S(   sH   Mark a value as unsafe.  This is the reverse operation for :func:`safe`.(   R   (   R%   (    (    sT   /var/www/send.findwatt.com/datamanager/lib/python2.7/site-packages/jinja2/filters.pyt   do_mark_unsafe  s    c         C   s   t  |  t  r  |  d d d  Sy t |   SWnO t k
 r y t |   } | j   | SWq t k
 r{ t d   q Xn Xd S(   s[   Reverse the object or return an iterator the iterates over it the other
    way round.
    Nis   argument must be iterable(   R    R   Rf   R.   RY   RT   R
   (   R%   RB   (    (    sT   /var/www/send.findwatt.com/datamanager/lib/python2.7/site-packages/jinja2/filters.pyt
   do_reverse  s    
c         C   s   y t  |  } Wn t k
 r# n[ Xy t | |  } Wn t k
 rJ n4 X|  j rz |  j | | |  rz |  j | |  S| S|  j d | d |  S(   s   Get 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 <notes-on-subscriptions>` for more details.
    t   objt   name(   t   strt   UnicodeErrorR   t   AttributeErrort	   sandboxedt   is_safe_attributet   unsafe_undefinedRc   (   R   R   R   R%   (    (    sT   /var/www/send.findwatt.com/datamanager/lib/python2.7/site-packages/jinja2/filters.pyt   do_attr  s    	c          /   s     d    d } t     d k r{ d  k r{  j d  }  rf t d t t      n  t  j |  } nP y   d    d   Wn t k
 r t d   n X     f d   } | r x | D] } | |  Vq Wn  d	 S(
   s  Applies 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(', ') }}

    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(', ') }}

    .. versionadded:: 2.7
    i    i   i   R   s   Unexpected keyword argument %ri   s   map requires a filter argumentc            s    j  j  |     d  S(   Nt   context(   R   t   call_filter(   R   (   R   R   R   R   (    sT   /var/www/send.findwatt.com/datamanager/lib/python2.7/site-packages/jinja2/filters.pyR   C  s   	N(   R   t   popR
   R   R-   R"   R   t   LookupError(   R   R   Rd   R   R   R   (    (   R   R   R   R   sT   /var/www/send.findwatt.com/datamanager/lib/python2.7/site-packages/jinja2/filters.pyt   do_map  s"    


c          O   s   t  |  | d   t  S(   s  Filters a sequence of objects by appying a test to either the object
    or the attribute and only selecting the ones with the test succeeding.

    Example usage:

    .. sourcecode:: jinja

        {{ numbers|select("odd") }}

    .. versionadded:: 2.7
    c         S   s   |  S(   N(    (   R   (    (    sT   /var/www/send.findwatt.com/datamanager/lib/python2.7/site-packages/jinja2/filters.pyR   X  s    (   t   _select_or_rejectRZ   (   R   R   (    (    sT   /var/www/send.findwatt.com/datamanager/lib/python2.7/site-packages/jinja2/filters.pyt	   do_selectK  s    c          O   s   t  |  | d   t  S(   s   Filters a sequence of objects by appying a test to either the object
    or the attribute and rejecting the ones with the test succeeding.

    Example usage:

    .. sourcecode:: jinja

        {{ numbers|reject("odd") }}

    .. versionadded:: 2.7
    c         S   s   |  S(   N(    (   R   (    (    sT   /var/www/send.findwatt.com/datamanager/lib/python2.7/site-packages/jinja2/filters.pyR   h  s    (   R   RZ   (   R   R   (    (    sT   /var/www/send.findwatt.com/datamanager/lib/python2.7/site-packages/jinja2/filters.pyt	   do_reject[  s    c          O   s   t  |  | d   t  S(   s;  Filters a sequence of objects by appying a test to either the object
    or the attribute and only selecting the ones with the test succeeding.

    Example usage:

    .. sourcecode:: jinja

        {{ users|selectattr("is_active") }}
        {{ users|selectattr("email", "none") }}

    .. versionadded:: 2.7
    c         S   s   |  S(   N(    (   R   (    (    sT   /var/www/send.findwatt.com/datamanager/lib/python2.7/site-packages/jinja2/filters.pyR   y  s    (   R   R   (   R   R   (    (    sT   /var/www/send.findwatt.com/datamanager/lib/python2.7/site-packages/jinja2/filters.pyt   do_selectattrk  s    c          O   s   t  |  | d   t  S(   s"  Filters a sequence of objects by appying a test to either the object
    or the attribute and rejecting the ones with the test succeeding.

    .. sourcecode:: jinja

        {{ users|rejectattr("is_active") }}
        {{ users|rejectattr("email", "none") }}

    .. versionadded:: 2.7
    c         S   s   |  S(   N(    (   R   (    (    sT   /var/www/send.findwatt.com/datamanager/lib/python2.7/site-packages/jinja2/filters.pyR     s    (   R   R   (   R   R   (    (    sT   /var/www/send.findwatt.com/datamanager/lib/python2.7/site-packages/jinja2/filters.pyt   do_rejectattr|  s    c   
      #   s   d   d } | rc y  d } Wn t  k
 rG t d   n Xt  j |  } d } n d } d   } y8  d |   d |       f d   } Wn t  k
 r t } n X| r x1 | D]& }	 | | | |	    r |	 Vq q Wn  d  S(   Ni    i   i   s$   Missing parameter for attribute namec         S   s   |  S(   N(    (   R   (    (    sT   /var/www/send.findwatt.com/datamanager/lib/python2.7/site-packages/jinja2/filters.pyR     s    i   c            s    j  j  |      S(   N(   R   t	   call_test(   R   (   R   R   R   R   (    sT   /var/www/send.findwatt.com/datamanager/lib/python2.7/site-packages/jinja2/filters.pyR     s   	(   R   R
   R"   R   t   bool(
   R   R   t   modfunct   lookup_attrRd   t   attrt	   transfunct   offR   R   (    (   R   R   R   R   sT   /var/www/send.findwatt.com/datamanager/lib/python2.7/site-packages/jinja2/filters.pyR     s*    

		
R   R3   R:   R<   R   t   et   forceescapeRD   t   titleR   R@   R/   R8   t   dictsortt   sortR   RT   R_   t   indentt   firstt   lastR   t   randomt   rejectt
   rejectattrt   filesizeformatt   pprintt   truncatet   wordwrapt	   wordcountR   Rz   t   stringRY   R   t   formatt   trimR   t   selectt
   selectattrt   slicet   batchR   t   absR   R   t   safet   xmlattrt	   urlencode(T   t   __doc__RG   R   R   R    t   operatorR   t	   itertoolsR   t   jinja2.utilsR   R   R   R   R   R   t   jinja2.runtimeR	   t   jinja2.exceptionsR
   t   jinja2._compatR   R   R   R   R   RH   R   R   R   R   R"   R&   R1   R+   R9   R;   R=   R   RC   RE   RJ   RZ   RQ   RU   RX   R^   Ra   Re   Rg   Ri   R   R   R   R   R   R   R   R   R   R   R   R   R   R   R   R   R   R   R   R   R   R   R   R   R   R   R   R   R   R   R   R  t   FILTERS(    (    (    sT   /var/www/send.findwatt.com/datamanager/lib/python2.7/site-packages/jinja2/filters.pyt   <module>
   s   .(								#		!(1								$ "+
				.	