
~9Vc           @   s  d  Z  d d l m Z d d l m Z d d l m Z d d l m	 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 d d
 l m Z m Z m Z m Z m Z m Z i d d 6d d 6d d 6d d 6d d 6d d 6d d 6d d 6Z e e d  rd Z n d Z d   Z e  e! e   d d1   Z d1 e# d  Z$ d   Z% d    Z& d! e' f d"     YZ( d# e' f d$     YZ) d% e* f d&     YZ+ d' e f d(     YZ, d) e f d*     YZ- d+ e f d,     YZ. d- e/ f d.     YZ0 d/ e f d0     YZ1 d1 S(2   s   
    jinja2.compiler
    ~~~~~~~~~~~~~~~

    Compiles nodes into python code.

    :copyright: (c) 2010 by the Jinja Team.
    :license: BSD, see LICENSE for more details.
i(   t   chain(   t   deepcopy(   t	   iskeyword(   t   nodes(   t   EvalContext(   t   NodeVisitor(   t   TemplateAssertionError(   t   Markupt   concatt   escape(   t
   range_typet	   text_typet   string_typest	   iteritemst   NativeStringIOt   imaps   ==t   eqs   !=t   net   >t   gts   >=t   gteqt   <t   lts   <=t   lteqt   ins   not int   notinR   t   itemsc             s   d     f d   }  |  S(   Ni*   c              s   d  S(   N(    (    (   t   x(    s/   /tmp/pip-build-zHWFj_/Jinja2/jinja2/compiler.pyt   f-   s    (    (   R   (    (   R   s/   /tmp/pip-build-zHWFj_/Jinja2/jinja2/compiler.pyt   unoptimize_before_dead_code+   s    t   __closure__c         C   sf   t  |  t j  s! t d   n  | j | | | | |  } | j |   | d k rb | j j   Sd S(   s+   Generate the python source for a node tree.s    Can't compile non template nodesN(	   t
   isinstanceR   t   Templatet	   TypeErrort   code_generator_classt   visitt   Nonet   streamt   getvalue(   t   nodet   environmentt   namet   filenameR%   t
   defer_initt	   generator(    (    s/   /tmp/pip-build-zHWFj_/Jinja2/jinja2/compiler.pyt   generate7   s    c      
   C   s   |  d k s$ |  t k s$ |  t k r( t St |  t t t t t	 t
 f t  rQ t St |  t t t t f  r x |  D] } t |  ss t Sqs Wt St |  t  r x: t |   D], \ } }  t |  s t St |   s t Sq Wt St S(   s)   Does the node have a safe representation?N(   R$   t   NotImplementedt   Ellipsist   TrueR   t   boolt   intt   floatt   complexR
   R   R   t   tuplet   listt   sett	   frozensett   has_safe_reprt   Falset   dictR   (   t   valuet   itemt   key(    (    s/   /tmp/pip-build-zHWFj_/Jinja2/jinja2/compiler.pyR9   C   s$    $c         C   sI   t  |  } y" x |  D] } | j |  q WWn t k
 rA n X| j S(   s   Check if the names passed are accessed undeclared.  The return value
    is a set of all the undeclared names from the sequence of names found.
    (   t   UndeclaredNameVisitorR#   t   VisitorExitt
   undeclared(   R   t   namest   visitorR'   (    (    s/   /tmp/pip-build-zHWFj_/Jinja2/jinja2/compiler.pyt   find_undeclaredY   s    t   Identifiersc           B   s2   e  Z d  Z d   Z d   Z d   Z d   Z RS(   s+   Tracks the status of identifiers in frames.c         C   s@   t    |  _ t    |  _ t    |  _ t    |  _ t    |  _ d  S(   N(   R7   t   declaredt   outer_undeclaredRA   t   declared_locallyt   declared_parameter(   t   self(    (    s/   /tmp/pip-build-zHWFj_/Jinja2/jinja2/compiler.pyt   __init__i   s
    c         C   s$   |  j  j |  |  j j |  d S(   s$   Register a special name like `loop`.N(   RA   t   discardRF   t   add(   RJ   R)   (    (    s/   /tmp/pip-build-zHWFj_/Jinja2/jinja2/compiler.pyt   add_special|   s    c         C   s/   | |  j  k s | |  j k r" t S| |  j k S(   s6   Check if a name is declared in this or an outer scope.(   RH   RI   R0   RF   (   RJ   R)   (    (    s/   /tmp/pip-build-zHWFj_/Jinja2/jinja2/compiler.pyt   is_declared   s    c         C   s
   t  |   S(   N(   R   (   RJ   (    (    s/   /tmp/pip-build-zHWFj_/Jinja2/jinja2/compiler.pyt   copy   s    (   t   __name__t
   __module__t   __doc__RK   RN   RO   RP   (    (    (    s/   /tmp/pip-build-zHWFj_/Jinja2/jinja2/compiler.pyRE   f   s
   			t   Framec           B   sP   e  Z d  Z d d  Z d   Z d   Z d d  Z d   Z d   Z	 e Z
 RS(	   s&   Holds compile time information for us.c         C   s   | |  _  t   |  _ t |  _ t |  _ | o3 | j |  _ d  |  _ | rQ | j	 pT d  |  _	 t
   |  _ | |  _ | d  k	 r |  j j j | j j | j j B| j B |  j j j | j j |  j j  | j |  _ n  d  S(   N(   t   eval_ctxRE   t   identifiersR:   t   toplevelt	   rootlevelt   require_output_checkR$   t   buffert   blockR7   t   assigned_namest   parentRF   t   updateRI   RG   RA   (   RJ   RU   R]   (    (    s/   /tmp/pip-build-zHWFj_/Jinja2/jinja2/compiler.pyRK      s"    						c         C   sZ   t  j |  j  } | j j |  j  t  j |  j j  | _ | j j j |  j j  | S(   s!   Create a copy of the current one.(   t   objectt   __new__t	   __class__t   __dict__R^   RV   (   RJ   t   rv(    (    s/   /tmp/pip-build-zHWFj_/Jinja2/jinja2/compiler.pyRP      s
    c         C   s1   t  |  j  } x | D] } | j |  q Wd S(   s   Walk the node and check for identifiers.  If the scope is hard (eg:
        enforce on a python level) overrides from outer scopes are tracked
        differently.
        N(   t   FrameIdentifierVisitorRV   R#   (   RJ   R   RC   R'   (    (    s/   /tmp/pip-build-zHWFj_/Jinja2/jinja2/compiler.pyt   inspect   s    c            s?   |  j      j   j B  j   j B@t   f d   | D  BS(   s   Find all the shadowed names.  extra is an iterable of variables
        that may be defined with `add_special` which may occour scoped.
        c         3   s$   |  ] }   j  |  r | Vq d  S(   N(   RO   (   t   .0R   (   t   i(    s/   /tmp/pip-build-zHWFj_/Jinja2/jinja2/compiler.pys	   <genexpr>   s    (   RV   RF   RG   RH   RI   R7   (   RJ   t   extra(    (   Rg   s/   /tmp/pip-build-zHWFj_/Jinja2/jinja2/compiler.pyt   find_shadowed   s    	c         C   s   t  |  j |   S(   s   Return an inner frame.(   RT   RU   (   RJ   (    (    s/   /tmp/pip-build-zHWFj_/Jinja2/jinja2/compiler.pyt   inner   s    c         C   s   |  j    } t | _ | S(   s   Return a soft frame.  A soft frame may not be modified as
        standalone thing as it shares the resources with the frame it
        was created of, but it's not a rootlevel frame any longer.
        (   RP   R:   RX   (   RJ   Rc   (    (    s/   /tmp/pip-build-zHWFj_/Jinja2/jinja2/compiler.pyt   soft   s    	N(    (   RQ   RR   RS   R$   RK   RP   Re   Ri   Rj   Rk   t   __copy__(    (    (    s/   /tmp/pip-build-zHWFj_/Jinja2/jinja2/compiler.pyRT      s   +							R@   c           B   s   e  Z d  Z RS(   s?   Exception used by the `UndeclaredNameVisitor` to signal a stop.(   RQ   RR   RS   (    (    (    s/   /tmp/pip-build-zHWFj_/Jinja2/jinja2/compiler.pyR@      s   t   DependencyFinderVisitorc           B   s2   e  Z d  Z d   Z d   Z d   Z d   Z RS(   s.   A visitor that collects filter and test calls.c         C   s   t    |  _ t    |  _ d  S(   N(   R7   t   filterst   tests(   RJ   (    (    s/   /tmp/pip-build-zHWFj_/Jinja2/jinja2/compiler.pyRK      s    c         C   s$   |  j  |  |  j j | j  d  S(   N(   t   generic_visitRn   RM   R)   (   RJ   R'   (    (    s/   /tmp/pip-build-zHWFj_/Jinja2/jinja2/compiler.pyt   visit_Filter   s    c         C   s$   |  j  |  |  j j | j  d  S(   N(   Rp   Ro   RM   R)   (   RJ   R'   (    (    s/   /tmp/pip-build-zHWFj_/Jinja2/jinja2/compiler.pyt
   visit_Test   s    c         C   s   d S(   s   Stop visiting at blocks.N(    (   RJ   R'   (    (    s/   /tmp/pip-build-zHWFj_/Jinja2/jinja2/compiler.pyt   visit_Block   s    (   RQ   RR   RS   RK   Rq   Rr   Rs   (    (    (    s/   /tmp/pip-build-zHWFj_/Jinja2/jinja2/compiler.pyRm      s
   			R?   c           B   s)   e  Z d  Z d   Z d   Z d   Z RS(   s   A visitor that checks if a name is accessed without being
    declared.  This is different from the frame visitor as it will
    not stop at closure frames.
    c         C   s   t  |  |  _ t    |  _ d  S(   N(   R7   RB   RA   (   RJ   RB   (    (    s/   /tmp/pip-build-zHWFj_/Jinja2/jinja2/compiler.pyRK      s    c         C   sl   | j  d k rU | j |  j k rU |  j j | j  |  j |  j k rh t    qh n |  j j | j  d  S(   Nt   load(   t   ctxR)   RB   RA   RM   R@   RL   (   RJ   R'   (    (    s/   /tmp/pip-build-zHWFj_/Jinja2/jinja2/compiler.pyt
   visit_Name  s
    !c         C   s   d S(   s   Stop visiting a blocks.N(    (   RJ   R'   (    (    s/   /tmp/pip-build-zHWFj_/Jinja2/jinja2/compiler.pyRs     s    (   RQ   RR   RS   RK   Rv   Rs   (    (    (    s/   /tmp/pip-build-zHWFj_/Jinja2/jinja2/compiler.pyR?      s   		Rd   c           B   s   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 RS(   s   A visitor for `Frame.inspect`.c         C   s   | |  _  d  S(   N(   RV   (   RJ   RV   (    (    s/   /tmp/pip-build-zHWFj_/Jinja2/jinja2/compiler.pyRK     s    c         C   s   | j  d k r( |  j j j | j  nf | j  d k rP |  j j j | j  n> | j  d k r |  j j | j  r |  j j j | j  n  d S(   s2   All assignments to names go through this function.t   storet   paramRt   N(   Ru   RV   RH   RM   R)   RI   RO   RA   (   RJ   R'   (    (    s/   /tmp/pip-build-zHWFj_/Jinja2/jinja2/compiler.pyRv     s    c            s    j  | j   j   j  j B      f d   } | | j  } | | j p\ d  }  j j | j	 |   j
   j j | | B d  S(   Nc            sm   |  s t    S j    _ x |  D] }  j |  q# W j j   }  j j  j j    _ | S(   N(   R7   RP   RV   R#   RH   RA   R^   (   R   t   subnodeRc   (   t	   old_namest   real_identifiersRJ   (    s/   /tmp/pip-build-zHWFj_/Jinja2/jinja2/compiler.pyt   inner_visit'  s    	(    (   R#   t   testRV   RH   RI   t   bodyt   else_RA   R^   t   symmetric_differenceRF   (   RJ   R'   R|   R~   R   (    (   Rz   R{   RJ   s/   /tmp/pip-build-zHWFj_/Jinja2/jinja2/compiler.pyt   visit_If   s    	
c         C   s   |  j  j j | j  d  S(   N(   RV   RH   RM   R)   (   RJ   R'   (    (    s/   /tmp/pip-build-zHWFj_/Jinja2/jinja2/compiler.pyt   visit_Macro?  s    c         C   s'   |  j  |  |  j j j | j  d  S(   N(   Rp   RV   RH   RM   t   target(   RJ   R'   (    (    s/   /tmp/pip-build-zHWFj_/Jinja2/jinja2/compiler.pyt   visit_ImportB  s    c         C   sa   |  j  |  xM | j D]B } t | t  rF |  j j j | d  q |  j j j |  q Wd  S(   Ni   (   Rp   RB   R   R5   RV   RH   RM   (   RJ   R'   R)   (    (    s/   /tmp/pip-build-zHWFj_/Jinja2/jinja2/compiler.pyt   visit_FromImportF  s
    c         C   s$   |  j  | j  |  j  | j  d S(   s'   Visit assignments in the correct order.N(   R#   R'   R   (   RJ   R'   (    (    s/   /tmp/pip-build-zHWFj_/Jinja2/jinja2/compiler.pyt   visit_AssignN  s    c         C   s   |  j  | j  d S(   sq   Visiting stops at for blocks.  However the block sequence
        is visited as part of the outer scope.
        N(   R#   t   iter(   RJ   R'   (    (    s/   /tmp/pip-build-zHWFj_/Jinja2/jinja2/compiler.pyt	   visit_ForS  s    c         C   s   |  j  | j  d  S(   N(   R#   t   call(   RJ   R'   (    (    s/   /tmp/pip-build-zHWFj_/Jinja2/jinja2/compiler.pyt   visit_CallBlockY  s    c         C   s   |  j  | j  d  S(   N(   R#   t   filter(   RJ   R'   (    (    s/   /tmp/pip-build-zHWFj_/Jinja2/jinja2/compiler.pyt   visit_FilterBlock\  s    c         C   s   d S(   s   Stop visiting at block assigns.N(    (   RJ   R'   (    (    s/   /tmp/pip-build-zHWFj_/Jinja2/jinja2/compiler.pyt   visit_AssignBlock_  s    c         C   s   d S(   s   Stop visiting at scopes.N(    (   RJ   R'   (    (    s/   /tmp/pip-build-zHWFj_/Jinja2/jinja2/compiler.pyt   visit_Scopeb  s    c         C   s   d S(   s   Stop visiting at blocks.N(    (   RJ   R'   (    (    s/   /tmp/pip-build-zHWFj_/Jinja2/jinja2/compiler.pyRs   e  s    (   RQ   RR   RS   RK   Rv   R   R   R   R   R   R   R   R   R   R   Rs   (    (    (    s/   /tmp/pip-build-zHWFj_/Jinja2/jinja2/compiler.pyRd     s   		
										t   CompilerExitc           B   s   e  Z d  Z RS(   s   Raised if the compiler encountered a situation where it just
    doesn't make sense to further process the code.  Any block that
    raises such an exception is not further processed.
    (   RQ   RR   RS   (    (    (    s/   /tmp/pip-build-zHWFj_/Jinja2/jinja2/compiler.pyR   i  s   t   CodeGeneratorc           B   sn  e  Z dU e d   Z d   Z d   Z d   Z d   Z d   Z	 d d  Z
 dU d  Z d	   Z dU d
  Z d   Z d   Z dU d d  Z dU d d  Z dU d  Z d   Z d   Z d   Z dV d  Z d   Z dU e d  Z dU d  Z d   Z d   Z dU 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, d*   Z- d+   Z. d,   Z/ d-   Z0 d.   Z1 d/   Z2 d0   Z3 e d1  Z4 e d2  Z5 e4 d3  Z6 e4 d4  Z7 e4 d5  Z8 e4 d6  Z9 e4 d7  Z: e4 d8  Z; e4 d9  Z< e4 d: d; e Z= e4 d< d; e Z> e5 d3  Z? e5 d4  Z@ e5 d= d; e ZA [4 [5 d>   ZB d?   ZC d@   ZD dA   ZE dB   ZF dC   ZG dD   ZH dE   ZI dF   ZJ e dG  ZK dH   ZL dI   ZM dJ   ZN dK   ZO dL   ZP dM   ZQ dN   ZR dO   ZS dP   ZT dQ   ZU dR   ZV dS   ZW dT   ZX RS(W   c         C   s   | d  k r t   } n  | |  _ | |  _ | |  _ | |  _ t |  _ | |  _ i  |  _	 i  |  _
 d |  _ t |  _ d |  _ i  |  _ i  |  _ g  |  _ d  |  _ d |  _ d |  _ t |  _ d |  _ d |  _ d  S(   Ni    i   (   R$   R   R(   R)   R*   R%   R:   t   created_block_contextR+   t   import_aliasest   blockst   extends_so_fart   has_known_extendst   code_linenoRo   Rn   t
   debug_infot   _write_debug_infot
   _new_linest
   _last_lineR0   t   _first_writet   _last_identifiert   _indentation(   RJ   R(   R)   R*   R%   R+   (    (    s/   /tmp/pip-build-zHWFj_/Jinja2/jinja2/compiler.pyRK   r  s,    																			c         C   s   t  | | |  j |  j   d S(   s*   Fail with a :exc:`TemplateAssertionError`.N(   R   R)   R*   (   RJ   t   msgt   lineno(    (    s/   /tmp/pip-build-zHWFj_/Jinja2/jinja2/compiler.pyt   fail  s    c         C   s   |  j  d 7_  d |  j  S(   s   Get a new unique identifier.i   s   t_%d(   R   (   RJ   (    (    s/   /tmp/pip-build-zHWFj_/Jinja2/jinja2/compiler.pyt   temporary_identifier  s    c         C   s'   |  j    | _ |  j d | j  d S(   s7   Enable buffering for the frame from that point onwards.s   %s = []N(   R   RZ   t	   writeline(   RJ   t   frame(    (    s/   /tmp/pip-build-zHWFj_/Jinja2/jinja2/compiler.pyRZ     s    c         C   s   | j  j ry |  j d  |  j   |  j d | j  |  j   |  j d  |  j   |  j d | j  |  j   n7 | j  j r |  j d | j  n |  j d | j  d S(   s(   Return the buffer contents of the frame.s   if context.eval_ctx.autoescape:s   return Markup(concat(%s))s   else:s   return concat(%s)N(   RU   t   volatileR   t   indentRZ   t   outdentt
   autoescape(   RJ   R   (    (    s/   /tmp/pip-build-zHWFj_/Jinja2/jinja2/compiler.pyt   return_buffer_contents  s    


c         C   s   |  j  d 7_  d S(   s   Indent by one.i   N(   R   (   RJ   (    (    s/   /tmp/pip-build-zHWFj_/Jinja2/jinja2/compiler.pyR     s    i   c         C   s   |  j  | 8_  d S(   s   Outdent by step.N(   R   (   RJ   t   step(    (    s/   /tmp/pip-build-zHWFj_/Jinja2/jinja2/compiler.pyR     s    c         C   s=   | j  d k r" |  j d |  n |  j d | j  |  d S(   s%   Yield or write into the frame buffer.s   yield s
   %s.append(N(   RZ   R$   R   (   RJ   R   R'   (    (    s/   /tmp/pip-build-zHWFj_/Jinja2/jinja2/compiler.pyt   start_write  s    c         C   s#   | j  d k	 r |  j d  n  d S(   s1   End the writing process started by `start_write`.t   )N(   RZ   R$   t   write(   RJ   R   (    (    s/   /tmp/pip-build-zHWFj_/Jinja2/jinja2/compiler.pyt	   end_write  s    c         C   s.   |  j  | |  |  j |  |  j |  d S(   s4   Simple shortcut for start_write + write + end_write.N(   R   R   R   (   RJ   t   sR   R'   (    (    s/   /tmp/pip-build-zHWFj_/Jinja2/jinja2/compiler.pyt   simple_write  s    c         C   si   | j  d k r |  j d  n |  j d  y% x | D] } |  j | |  q6 WWn t k
 rd n Xd S(   s   Visit a list of nodes as block in a frame.  If the current frame
        is no buffer a dummy ``if 0: yield None`` is written automatically
        unless the force_generator parameter is set to False.
        s   if 0: yield Nonet   passN(   RZ   R$   R   R#   R   (   RJ   R   R   R'   (    (    s/   /tmp/pip-build-zHWFj_/Jinja2/jinja2/compiler.pyt
   blockvisit  s    c         C   s   |  j  r |  j su |  j j d |  j   |  j |  j  7_ |  j d k	 ru |  j j |  j |  j f  d |  _ qu n  t	 |  _ |  j j d |  j
  d |  _  n  |  j j |  d S(   s&   Write a string into the output stream.s   
s       i    N(   R   R   R%   R   R   R   R$   R   t   appendR:   R   (   RJ   R   (    (    s/   /tmp/pip-build-zHWFj_/Jinja2/jinja2/compiler.pyR     s    			i    c         C   s!   |  j  | |  |  j |  d S(   s!   Combination of newline and write.N(   t   newlineR   (   RJ   R   R'   Rh   (    (    s/   /tmp/pip-build-zHWFj_/Jinja2/jinja2/compiler.pyR     s    c         C   sV   t  |  j d |  |  _ | d k	 rR | j |  j k rR | j |  _ | j |  _ n  d S(   s/   Add one or more newlines before the next write.i   N(   t   maxR   R$   R   R   R   (   RJ   R'   Rh   (    (    s/   /tmp/pip-build-zHWFj_/Jinja2/jinja2/compiler.pyR     s    c   	      C   se  t  } x@ t d   | j D | p% d  D] } t |  r) t } Pq) q) Wx. | j D]# } |  j d  |  j | |  qS W| s x. | j D]# } |  j d  |  j | |  q W| d k	 r x4 t	 |  D]# \ } } |  j d | | f  q Wq n  | j
 r#|  j d  |  j | j
 |  n  | r/| j d k	 rH|  j d  n |  j d  xE | j D]: } |  j d | j  |  j | j |  |  j d  q_W| d k	 rx4 t	 |  D]# \ } } |  j d | | f  qWn  | j d k	 r|  j d	  |  j | j |  |  j d
  qa|  j d  n2 | j d k	 ra|  j d  |  j | j |  n  d S(   s,  Writes a function call to the stream for the current node.
        A leading comma is added automatically.  The extra keyword
        arguments may not include python keywords otherwise a syntax
        error could occour.  The extra keyword arguments should be given
        as python dict.
        c         s   s   |  ] } | j  Vq d  S(   N(   R>   (   Rf   R   (    (    s/   /tmp/pip-build-zHWFj_/Jinja2/jinja2/compiler.pys	   <genexpr>  s    s   , s   , %s=%ss   , *s
   , **dict({s   , **{s   %r: s   %r: %s, s   }, **R   t   }s   , **N(    (   R:   R    t   kwargst   is_python_keywordR0   t   argsR   R#   R$   R   t   dyn_argst
   dyn_kwargsR>   R<   (	   RJ   R'   R   t   extra_kwargst   kwarg_workaroundt   kwargt   argR>   R<   (    (    s/   /tmp/pip-build-zHWFj_/Jinja2/jinja2/compiler.pyt	   signature  sJ    	)!	c         C   s2   x+ | j  j D] } |  j d | | f  q Wd S(   s9   Pull all the references identifiers into the local scope.s   l_%s = context.resolve(%r)N(   RV   RA   R   (   RJ   R   R)   (    (    s/   /tmp/pip-build-zHWFj_/Jinja2/jinja2/compiler.pyt   pull_locals@  s    c         C   s   t    } x | D] } | j |  q Wxt d D]l } t |  |  } xT t | |  D]C } | | k rx |  j   | | <n  |  j d | | | | f  qS Wq. Wd S(   s   Pull all the dependencies.Rn   Ro   s   %s = environment.%s[%r]N(   s   filterss   tests(   Rm   R#   t   getattrR   R   (   RJ   R   RC   R'   t
   dependencyt   mappingR)   (    (    s/   /tmp/pip-build-zHWFj_/Jinja2/jinja2/compiler.pyt   pull_dependenciesE  s    		c         C   sO   | j  j rK |  j d t r! d p$ d d j d   | j  j D  f  n  d S(   s+   Disable Python optimizations for the frame.s   %sdummy(%s)s   if 0: t    s   , c         s   s   |  ] } d  | Vq d S(   t   l_N(    (   Rf   R)   (    (    s/   /tmp/pip-build-zHWFj_/Jinja2/jinja2/compiler.pys	   <genexpr>[  s    N(   RV   RF   R   R   t   join(   RJ   R   (    (    s/   /tmp/pip-build-zHWFj_/Jinja2/jinja2/compiler.pyt   unoptimize_scopeR  s    	c         C   s   i  } xB | j  |  D]1 } |  j   | | <} |  j d | | f  q Wt   } x4 | j j D]& } | | k ra | j d |  qa qa W| r |  j d j |  d  n  | S(   s  This function returns all the shadowed variables in a dict
        in the form name: alias and will write the required assignments
        into the current scope.  No indentation takes place.

        This also predefines locally declared variables from the loop
        body because under some circumstances it may be the case that

        `extra_vars` is passed to `Frame.find_shadowed`.
        s	   %s = l_%sR   s    = s
    = missing(   Ri   R   R   R7   RV   RH   RM   R   (   RJ   R   t
   extra_varst   aliasesR)   t   identt
   to_declare(    (    s/   /tmp/pip-build-zHWFj_/Jinja2/jinja2/compiler.pyt
   push_scope^  s    
	c         C   s   x1 t  |  D]# \ } } |  j d | | f  q Wt   } x4 | j j D]& } | | k rJ | j d |  qJ qJ W| r |  j d j |  d  n  d S(   s0   Restore all aliases and delete unused variables.s	   l_%s = %sR   s    = s
    = missingN(   R   R   R7   RV   RH   RM   R   (   RJ   R   R   R)   t   aliast	   to_delete(    (    s/   /tmp/pip-build-zHWFj_/Jinja2/jinja2/compiler.pyt	   pop_scopet  s    	c   
      C   s  | d
 k r | j   } n  t |  } | j   } | j |  | j j | j j @| j j | j j	 B@} | r |  j
 d d j t |   | j  n  | j j | j j | j j @8_ | s | St | _ t | _ t | _ g  | j D] } d | j ^ q | _ } t | d  }	 d |	 k rNt | _ | j j d  | j d  n  d |	 k rt | _ | j j d  | j d  n  d |	 k rt | _ | j j d  | j d	  n  | S(   sM  In Jinja a few statements require the help of anonymous
        functions.  Those are currently macros and call blocks and in
        the future also recursive loops.  As there is currently
        technical limitation that doesn't allow reading and writing a
        variable in a scope where the initial value is coming from an
        outer scope, this function tries to fall back with a common
        error message.  Additionally the frame passed is modified so
        that the argumetns are collected and callers are looked up.

        This will return the modified frame.
        sX   It's not possible to set and access variables derived from an outer scope! (affects: %s)s   , R   t   callerR   t   varargst   l_callert   l_kwargst	   l_varargsN(   R   s   kwargsR   (   R$   t   iter_child_nodesR6   Rj   Re   RV   RA   RF   RH   RI   R   R   t   sortedR   R:   t   accesses_kwargst   accesses_varargst   accesses_callerR   R)   t	   argumentsRD   R0   RN   R   (
   RJ   R'   R   t   childrent   find_specialt
   func_framet   overridden_closure_varsR   R   RA   (    (    s/   /tmp/pip-build-zHWFj_/Jinja2/jinja2/compiler.pyt   function_scoping  sD    
		 
				*			c         C   s   |  j  | | |  } t | _ | j } d | j j k rI | d g } n  |  j d d j |  |  |  j   |  j	 |  |  j
 |  |  j | j |  |  j |  |  j   | S(   s/   Dump the function def of a macro or call block.t   loops   l_loop=l_loops   def macro(%s):s   , (   R   R:   RY   R   RV   RF   R   R   R   RZ   R   R   R~   R   R   (   RJ   R'   R   R   R   (    (    s/   /tmp/pip-build-zHWFj_/Jinja2/jinja2/compiler.pyt
   macro_body  s    		

c         C   s   d j  d   | j D  } t | d d  } t | j  d k rP | d 7} n  |  j d | | f  x. | j D]# } |  j | |  |  j d  qq W|  j d t | j	  t | j
  t | j  f  d S(	   s<   Dump the macro definition for the def created by macro_body.s   , c         s   s   |  ] } t  | j  Vq d  S(   N(   t   reprR)   (   Rf   R   (    (    s/   /tmp/pip-build-zHWFj_/Jinja2/jinja2/compiler.pys	   <genexpr>  s    R)   i   t   ,s%   Macro(environment, macro, %r, (%s), (s   ), %r, %r, %r)N(   R   R   R   R$   t   lenR   t   defaultsR#   R1   R   R   R   (   RJ   R'   R   t	   arg_tupleR)   R   (    (    s/   /tmp/pip-build-zHWFj_/Jinja2/jinja2/compiler.pyt	   macro_def  s    		c         C   s:   d | j  } |  j d k	 r6 | d t |  j  7} n  | S(   s.   Return a human readable position for the node.s   line %ds    in N(   R   R)   R$   R   (   RJ   R'   Rc   (    (    s/   /tmp/pip-build-zHWFj_/Jinja2/jinja2/compiler.pyt   position  s    c         C   s  | d  k s t d   t |  j |  j  } d d l m } |  j d  |  j d d j |   t	 sz |  j d  n  |  j
 r d p d	 } | j t j  d  k	 } xY | j t j  D]E } | j |  j k r |  j d
 | j | j  n  | |  j | j <q Wx | j t j  D] } | j |  j k r| j }	 |  j   |  j |	 <}
 d |	 k r|	 j d d  \ } } |  j d | | |
 f  q|  j d |	 |
 f  qqW|  j d |  j  |  j d | d d t |  } | j | j  t | _ | _ | o|  j | _ |  j    | r8|  j d  n  d t! | j d!  k rp| j" j# d  |  j d  n  |  j$ |  |  j% | j  |  j& | j |  |  j'   | r|  j s|  j    |  j d  n  |  j    |  j d  |  j    |  j d  |  j' d |  j  n  xt( |  j  D]\ } } t |  } | j | j  | | _) |  j d | | f | d  |  j    t! | j d"  } d | k r| j" j# d  |  j d  n  d | k r| j" j# d  |  j d | | f  n  |  j$ |  |  j% | j  |  j& | j |  |  j'   q)W|  j d d j d   |  j D  d d |  j d d j d    |  j* D   d  S(#   Ns   no root frame allowedi(   t   __all__s   from __future__ import divisions   from jinja2.runtime import s   , s   dummy = lambda *x: Nones   , environment=environmentR   s   block %r defined twicet   .i   s   from %s import %s as %ss   import %s as %ss	   name = %rs   def root(context%s):Rh   s   parent_template = NoneRJ   s#   l_self = TemplateReference(context)s   if parent_template is not None:s7   for event in parent_template.root_render_func(context):s   yield eventi   s   def block_%s(context%s):t   supers%   l_super = context.super(%r, block_%s)s   blocks = {%s}c         s   s   |  ] } d  | | f Vq d S(   s   %r: block_%sN(    (   Rf   R   (    (    s/   /tmp/pip-build-zHWFj_/Jinja2/jinja2/compiler.pys	   <genexpr>T  s   s   debug_info = %rt   &c         s   s   |  ] } d  | Vq d S(   s   %s=%sN(    (   Rf   R   (    (    s/   /tmp/pip-build-zHWFj_/Jinja2/jinja2/compiler.pys	   <genexpr>Y  s    (   s   self(   s   selfs   super(+   R$   t   AssertionErrorR   R(   R)   t   jinja2.runtimeR   R   R   R   R+   t   findR   t   Extendst   find_allt   BlockR   R   R   t   ImportedNamet
   importnameR   R   t   rsplitRT   Re   R~   R0   RW   RX   R   RY   R   RD   RV   RN   R   R   R   R   R   R[   R   (   RJ   R'   R   RU   t   exportedt   envenvt   have_extendsR[   t   import_t   impR   t   modulet   objR)   t   block_frameRA   (    (    s/   /tmp/pip-build-zHWFj_/Jinja2/jinja2/compiler.pyt   visit_Template  s    		

	


	

	c         C   s   d } | j  rR |  j r d S|  j d k rR |  j d  |  j   | d 7} qR n  | j ra d pd d } |  j d | j | f |  |  j   |  j d |  |  j |  d S(	   s.   Call a block and register it for the template.i   Ni    s   if parent_template is None:s   context.derived(locals())t   contexts'   for event in context.blocks[%r][0](%s):t   event(	   RW   R   R   R   R   t   scopedR)   R   R   (   RJ   R'   R   t   levelR   (    (    s/   /tmp/pip-build-zHWFj_/Jinja2/jinja2/compiler.pyRs   \  s    		
	
c         C   s  | j  s |  j d | j  n  |  j d k r |  j sQ |  j d  |  j   n  |  j d d  |  j rw t    q |  j   n  |  j d |  |  j	 | j
 |  |  j d |  j  |  j d t  |  j   |  j d	  |  j   | j rt |  _ n  |  j d
 7_ d S(   s   Calls the extender.s,   cannot use extend from a non top-level scopei    s   if parent_template is not None:s   raise TemplateRuntimeError(%r)s   extended multiple timess+   parent_template = environment.get_template(s   , %r)s6   for name, parent_block in parent_template.blocks.%s():s8   context.blocks.setdefault(name, []).append(parent_block)i   N(   RW   R   R   R   R   R   R   R   R   R#   t   templateR   R)   t   dict_item_iterRX   R0   (   RJ   R'   R   (    (    s/   /tmp/pip-build-zHWFj_/Jinja2/jinja2/compiler.pyt   visit_Extendso  s.    						

	c         C   s  | j  r |  j |  n  | j r< |  j d  |  j   n  d } t | j t j  r t | j j	 t
  ru d } q t | j j	 t t f  r d } q n' t | j t j t j f  r d } n  |  j d | |  |  j | j |  |  j d |  j  | j rY|  j   |  j d  |  j   |  j d  |  j   |  j d	  |  j   n  | j  rr|  j d
  n |  j d  |  j   |  j d |  |  j   | j r|  j   n  d S(   s   Handles includes.s   try:t   get_or_select_templatet   get_templatet   select_templates   template = environment.%s(s   , %r)s   except TemplateNotFound:R   s   else:s]   for event in template.root_render_func(template.new_context(context.parent, True, locals())):s*   for event in template.module._body_stream:R  N(   t   with_contextR   t   ignore_missingR   R   R   R  R   t   ConstR<   R   R5   R6   t   Tuplet   ListR#   R   R)   R   R   (   RJ   R'   R   t	   func_name(    (    s/   /tmp/pip-build-zHWFj_/Jinja2/jinja2/compiler.pyt   visit_Include  s@    					


	

	c         C   s   | j  r |  j |  n  |  j d | j |  | j rP |  j d | j  n  |  j d  |  j | j |  |  j d |  j  | j  r |  j d  n |  j d  | j r | j j	 d  r |  j d | j  n  | j
 j | j  d	 S(
   s   Visit regular imports.s   l_%s = s   context.vars[%r] = s   environment.get_template(s   , %r).s+   make_module(context.parent, True, locals())R   t   _s!   context.exported_vars.discard(%r)N(   R
  R   R   R   RW   R   R#   R  R)   t
   startswithR\   RM   (   RJ   R'   R   (    (    s/   /tmp/pip-build-zHWFj_/Jinja2/jinja2/compiler.pyR     s    			c         C   s  |  j  |  |  j d  |  j | j |  |  j d |  j  | j rZ |  j d  n |  j d  g  } g  } x | j D] } t | t  r | \ } } n | } |  j	 d | | f  |  j	 d |  |  j
   |  j	 d | d |  j |  t |  f | f  |  j   | j rN| j |  | j d	  sN| j |  qNn  | j j |  q} W| rt |  d
 k r| d } |  j	 d | | f  q|  j	 d d j d   | D   n  | rt |  d
 k r|  j	 d | d  q|  j	 d d j t t |    n  d S(   s   Visit named imports.s-   included_template = environment.get_template(s   , %r).s!   make_module(context.parent, True)R   s.   l_%s = getattr(included_template, %r, missing)s   if l_%s is missing:sG   l_%s = environment.undefined(%r %% included_template.__name__, name=%r)sG   the template %%r (imported on %s) does not export the requested name %sR  i   i    s   context.vars[%r] = l_%ss   context.vars.update({%s})s   , c         s   s   |  ] } d  | | f Vq d S(   s   %r: l_%sN(    (   Rf   R)   (    (    s/   /tmp/pip-build-zHWFj_/Jinja2/jinja2/compiler.pys	   <genexpr>  s    s!   context.exported_vars.discard(%r)s-   context.exported_vars.difference_update((%s))N(   R   R   R#   R  R)   R
  RB   R   R5   R   R   R   R   R   RW   R   R  R\   RM   R   R   R   (   RJ   R'   R   t	   var_namest   discarded_namesR)   R   (    (    s/   /tmp/pip-build-zHWFj_/Jinja2/jinja2/compiler.pyR     sP    		
	
	
		c   
      C   s  | j  d d"  } | j r9 |  j | | | d t } n | j   } | j |  | j py d t | j  d d#  d$  k } | j s |  j | d%  } n- |  j d |  |  j	   |  j
 |  i  } | r |  j d  | j j d  n  xN | j t j  D]: } | j d	 k r | j d k r |  j d
 | j  q q W|  j |  | j rt|  j   } |  j d |  n  d | k rd t | j  d d&  d'  k r|  j d d |  j |   n  |  j d |  |  j | j |  |  j | rd pd  | r| j d  k	 r|  j d  |  j | j |  |  j d  |  j | j |  |  j d  | j ry|  j d  n |  j | j |  |  j d  | j   }	 |  j | j |	  |  j d  n, | j r|  j d  n |  j | j |  | j r|  j d  n |  j | rd p"d  | r| j d  k	 r|  j	   |  j d  |  j | j |  |  j d  |  j	   |  j d  |  j d  n  |  j	   |  j  | j! |  | j r|  j d |  n  |  j   | j r"|  j d |  |  j	   |  j  | j |  |  j   n  | j s>|  j" | |  n  | j r|  j# |  |  j   |  j$ | |  |  j d   |  j | j |  |  j d!  |  j% |  n  d  S((   Nt   excludeR   R   R   t   onlyR~   s-   def loop(reciter, loop_render_func, depth=0):s   l_loop = missingRw   s8   Can't assign to special loop variable in for-loop targets   %s = 1R   R}   s/   l_loop = environment.undefined(%r, name='loop')s   'loop' is undefined. the filter section of a loop as well as the else block don't have access to the special 'loop' variable of the current loop.  Because there is no parent loop it's undefined.  Happened in loop on %ss   for s   , l_loop in LoopContext(s    in t   (s    for t   reciters    if (s   ))s   , loop_render_func, depth):s   ):t   :s   if not t   continuei   s   %s = 0s   if %s:s   loop(s   , loop)(   s   iter(   s   body(   s   loop(   s   loop(   s   else_s   test(   s   loop(&   R   t	   recursiveR   R:   Rj   Re   RD   R   R   R   RZ   RV   RN   R   R   t   NameRu   R)   R   R   R   R   R   R   R#   R   R   R}   R$   R   RP   R   R   R~   R   R   R   R   (
   RJ   R'   R   R   t
   loop_framet   extended_loopR   R)   t   iteration_indicatort
   test_frame(    (    s/   /tmp/pip-build-zHWFj_/Jinja2/jinja2/compiler.pyR     s    		
						


	
	
		
c         C   s   | j    } |  j d |  |  j | j |  |  j d  |  j   |  j | j |  |  j   | j	 r |  j d  |  j   |  j | j	 |  |  j   n  d  S(   Ns   if R  s   else:(
   Rk   R   R#   R}   R   R   R   R~   R   R   (   RJ   R'   R   t   if_frame(    (    s/   /tmp/pip-build-zHWFj_/Jinja2/jinja2/compiler.pyR     s    

	
c         C   s   |  j  | |  } |  j   | j re | j j d  sN |  j d | j  n  |  j d | j  n  |  j d | j  |  j | |  | j j	 | j  d  S(   NR  s   context.exported_vars.add(%r)s   context.vars[%r] = s   l_%s = (
   R   R   RW   R)   R  R   R   R   R\   RM   (   RJ   R'   R   t   macro_frame(    (    s/   /tmp/pip-build-zHWFj_/Jinja2/jinja2/compiler.pyR     s    
	c         C   s~   | j  d d  } |  j | | |  } |  j d  |  j | |  |  j | |  |  j | j | d t |  j |  d  S(   NR  R   s	   caller = t   forward_caller(   s   call(	   R   R   R   R   R   t
   visit_CallR   R0   R   (   RJ   R'   R   R   t
   call_frame(    (    s/   /tmp/pip-build-zHWFj_/Jinja2/jinja2/compiler.pyR     s    c         C   s   | j    } | j | j    |  j |  } |  j |  |  j |  |  j | j |  |  j | |  |  j	 | j
 |  |  j |  |  j | |  d  S(   N(   Rj   Re   R   R   R   RZ   R   R~   R   Rq   R   R   R   (   RJ   R'   R   t   filter_frameR   (    (    s/   /tmp/pip-build-zHWFj_/Jinja2/jinja2/compiler.pyR     s    c         C   s$   |  j  |  |  j | j |  d  S(   N(   R   R#   R'   (   RJ   R'   R   (    (    s/   /tmp/pip-build-zHWFj_/Jinja2/jinja2/compiler.pyt   visit_ExprStmt  s    c            s    j  r | j r d  St }   j j r   j j } t | d t  sX t | d t  ra t } q t | d t  r   f d   } q   f d   } n t } t } | j r   j d    j	   t } n  g  } x| j
 D]} y+ | s t
 j    n  | j | j  }	 Wn$ t
 j k
 r3| j |  q n XyI | j j rpt |	 d  ra|	 j   }	 qpt |	  }	 n  | |	  }	 Wn! t k
 r| j |  q n X| rt | d t  r| d j |	  q | j |	 g  q Wt |  d	 k  s| j d  k	 r| j d  k	 r\t |  d
 k r;  j d | j  n   j d | j    j	   n  xt| D]l}
 t |
 t  rt t |
   } | j d  k r  j d |  q  j | d  qc| j d  k r  j d |
  n   j |
  d
 } | j j r  j d  n) | j j r.  j d  n   j d    j j d  k	 r  j d  t   j j d t  r  j d  n  | d
 7} n    j |
 |    j d |  | j d  k	 rc  j d  qcqcW| j d  k	 r  j     j t |  d
 k r
d pd  qng  } g  } xY | D]Q }
 t |
 t  ra| j t |
  j  d d   q*| j d  | j |
  q*W  j d    j t t |   d    j	   x6| D].}   j |  d } | j j r  j d  | d
 7} n& | j j r  j d  | d
 7} n    j j d  k	 r  j d  t   j j d t  rf  j d  nP t   j j d t  r  j d  n( t   j j d t  r  j d  n  | d
 7} n    j | |    j d | d  qW  j     j d  | r  j   n  d  S(   Nt   contextfunctiont   evalcontextfunctiont   environmentfunctionc            s   t    j j   j |    S(   N(   R   R(   t   finalize(   R   (   RJ   (    s/   /tmp/pip-build-zHWFj_/Jinja2/jinja2/compiler.pyt   <lambda>  s   c            s   t    j j |    S(   N(   R   R(   R+  (   R   (   RJ   (    s/   /tmp/pip-build-zHWFj_/Jinja2/jinja2/compiler.pyR,    s    s   if parent_template is None:t   __html__ii   i   s
   %s.append(s   %s.extend((s   yield s   , s6   (context.eval_ctx.autoescape and escape or to_string)(s   escape(s
   to_string(s   environment.finalize(s	   context, R   s   ))t   %s   %%s   %ss    % (i    s   context.eval_ctx, s   environment, (!   R   RY   R0   R(   R+  R   R:   R   R   R   R   t
   Impossiblet   as_constRU   R   R   t   hasattrR-  R	   t	   ExceptionR   R6   R   RZ   R$   R   R   R   R   R   R#   R   t   replace(   RJ   R'   R   t   allow_constant_finalizet   funcR+  t   outdent_laterR~   t   childt   constR=   t   valt   closet   formatR   t   argument(    (   RJ   s/   /tmp/pip-build-zHWFj_/Jinja2/jinja2/compiler.pyt   visit_Output  s    		
	!
+"

c         C   s)   | j  s | S| j   } t   | _ | S(   N(   RW   RP   R7   t   toplevel_assignments(   RJ   R   t   assignment_frame(    (    s/   /tmp/pip-build-zHWFj_/Jinja2/jinja2/compiler.pyt   make_assignment_frameQ  s
    	c         C   s=  | j  s d  Sg  | j D] } | j d  s | ^ q } t | j  d k r| t t | j   } |  j d | | f  ng |  j d  xJ t | j  D]9 \ } } | r |  j d  n  |  j d | | f  q W|  j d  | r9t |  d k r|  j d | d	  q9|  j d
 d j	 t
 t |    n  d  S(   NR  i   s   context.vars[%r] = l_%ss   context.vars.update({s   , s   %r: l_%ss   })s   context.exported_vars.add(%r)i    s"   context.exported_vars.update((%s))(   RW   R>  R  R   t   nextR   R   t	   enumerateR   R   R   R   (   RJ   R   R?  R   t   public_namesR)   t   idx(    (    s/   /tmp/pip-build-zHWFj_/Jinja2/jinja2/compiler.pyt   export_assigned_vars\  s&    			c         C   sc   |  j  |  |  j |  } |  j | j |  |  j d  |  j | j |  |  j | |  d  S(   Ns    = (   R   R@  R#   R   R   R'   RE  (   RJ   R'   R   R?  (    (    s/   /tmp/pip-build-zHWFj_/Jinja2/jinja2/compiler.pyR   s  s    c         C   s   | j    } | j | j  |  j |  } |  j |  |  j |  |  j | j |  |  j | |  |  j |  } |  j	 |  |  j
 | j |  |  j d | j  |  j | |  d  S(   Ns    = concat(%s)(   Rj   Re   R~   R   R   RZ   R   R   R@  R   R#   R   R   RE  (   RJ   R'   R   R   R   R?  (    (    s/   /tmp/pip-build-zHWFj_/Jinja2/jinja2/compiler.pyR   {  s    c         C   sY   | j  d k r. | j r. | j j | j  n  |  j d | j  | j j | j  d  S(   NRw   R   (   Ru   RW   R>  RM   R)   R   R\   (   RJ   R'   R   (    (    s/   /tmp/pip-build-zHWFj_/Jinja2/jinja2/compiler.pyRv     s    c         C   sE   | j  } t | t  r. |  j t |   n |  j t |   d  S(   N(   R<   R   R3   R   t   strR   (   RJ   R'   R   R9  (    (    s/   /tmp/pip-build-zHWFj_/Jinja2/jinja2/compiler.pyt   visit_Const  s    	c         C   sR   y# |  j  t | j | j    Wn( t j k
 rM |  j  d | j  n Xd  S(   Ns8   (context.eval_ctx.autoescape and Markup or identity)(%r)(   R   R   R0  RU   R   R/  t   data(   RJ   R'   R   (    (    s/   /tmp/pip-build-zHWFj_/Jinja2/jinja2/compiler.pyt   visit_TemplateData  s
    #	c         C   s|   |  j  d  d } xC t | j  D]2 \ } } | rE |  j  d  n  |  j | |  q# W|  j  | d k rq d pt d  d  S(   NR  is   , i    s   ,)R   (   R   RB  R   R#   (   RJ   R'   R   RD  R=   (    (    s/   /tmp/pip-build-zHWFj_/Jinja2/jinja2/compiler.pyt   visit_Tuple  s    c         C   sd   |  j  d  xC t | j  D]2 \ } } | r? |  j  d  n  |  j | |  q W|  j  d  d  S(   Nt   [s   , t   ](   R   RB  R   R#   (   RJ   R'   R   RD  R=   (    (    s/   /tmp/pip-build-zHWFj_/Jinja2/jinja2/compiler.pyt
   visit_List  s    c         C   s   |  j  d  xf t | j  D]U \ } } | r? |  j  d  n  |  j | j |  |  j  d  |  j | j |  q W|  j  d  d  S(   Nt   {s   , s   : R   (   R   RB  R   R#   R>   R<   (   RJ   R'   R   RD  R=   (    (    s/   /tmp/pip-build-zHWFj_/Jinja2/jinja2/compiler.pyt
   visit_Dict  s    c            s     f d   } | S(   Nc            s   |  j  j re   |  j  j k re |  j d    |  j | j |  |  j d  |  j | j |  nD |  j d  |  j | j |  |  j d    |  j | j |  |  j d  d  S(   Ns$   environment.call_binop(context, %r, s   , R  s    %s R   (   R(   t	   sandboxedt   intercepted_binopsR   R#   t   leftt   right(   RJ   R'   R   (   t   operator(    s/   /tmp/pip-build-zHWFj_/Jinja2/jinja2/compiler.pyRC     s    (    (   RT  t   interceptableRC   (    (   RT  s/   /tmp/pip-build-zHWFj_/Jinja2/jinja2/compiler.pyt   binop  s    c            s     f d   } | S(   Nc            sz   |  j  j rE   |  j  j k rE |  j d    |  j | j |  n$ |  j d    |  j | j |  |  j d  d  S(   Ns#   environment.call_unop(context, %r, R  R   (   R(   RP  t   intercepted_unopsR   R#   R'   (   RJ   R'   R   (   RT  (    s/   /tmp/pip-build-zHWFj_/Jinja2/jinja2/compiler.pyRC     s    (    (   RT  RU  RC   (    (   RT  s/   /tmp/pip-build-zHWFj_/Jinja2/jinja2/compiler.pyt   uaop  s    	t   +t   -t   *t   /s   //s   **R.  t   andRU  t   ors   not c         C   s   | j  j r d } n | j  j r* d } n d } |  j d |  x. | j D]# } |  j | |  |  j d  qK W|  j d  d  S(   Ns;   (context.eval_ctx.volatile and markup_join or unicode_join)t   markup_joint   unicode_joins   %s((s   , s   ))(   RU   R   R   R   R   R#   (   RJ   R'   R   R  R   (    (    s/   /tmp/pip-build-zHWFj_/Jinja2/jinja2/compiler.pyt   visit_Concat  s    		c         C   s;   |  j  | j |  x! | j D] } |  j  | |  q Wd  S(   N(   R#   t   exprt   ops(   RJ   R'   R   t   op(    (    s/   /tmp/pip-build-zHWFj_/Jinja2/jinja2/compiler.pyt   visit_Compare  s    c         C   s/   |  j  d t | j  |  j | j |  d  S(   Ns    %s (   R   t	   operatorsRd  R#   Rb  (   RJ   R'   R   (    (    s/   /tmp/pip-build-zHWFj_/Jinja2/jinja2/compiler.pyt   visit_Operand  s    c         C   s8   |  j  d  |  j | j |  |  j  d | j  d  S(   Ns   environment.getattr(s   , %r)(   R   R#   R'   t   attr(   RJ   R'   R   (    (    s/   /tmp/pip-build-zHWFj_/Jinja2/jinja2/compiler.pyt   visit_Getattr  s    c         C   s   t  | j t j  rX |  j | j |  |  j d  |  j | j |  |  j d  nM |  j d  |  j | j |  |  j d  |  j | j |  |  j d  d  S(   NRK  RL  s   environment.getitem(s   , R   (   R   R   R   t   SliceR#   R'   R   (   RJ   R'   R   (    (    s/   /tmp/pip-build-zHWFj_/Jinja2/jinja2/compiler.pyt   visit_Getitem  s    c         C   s   | j  d  k	 r% |  j | j  |  n  |  j d  | j d  k	 rW |  j | j |  n  | j d  k	 r |  j d  |  j | j |  n  d  S(   NR  (   t   startR$   R#   R   t   stopR   (   RJ   R'   R   (    (    s/   /tmp/pip-build-zHWFj_/Jinja2/jinja2/compiler.pyt   visit_Slice  s    c         C   sk  |  j  |  j | j d  |  j j j | j  } | d  k r\ |  j d | j | j  n  t | d t	  r~ |  j  d  nD t | d t	  r |  j  d  n" t | d t	  r |  j  d  n  | j
 d  k	 r |  j | j
 |  nc | j j r|  j  d	 | j | j f  n7 | j j r6|  j  d
 | j  n |  j  d | j  |  j | |  |  j  d  d  S(   NR  s   no filter named %rt   contextfilters	   context, t   evalcontextfilters   context.eval_ctx, t   environmentfilters   environment, sB   (context.eval_ctx.autoescape and Markup(concat(%s)) or concat(%s))s   Markup(concat(%s))s
   concat(%s)R   (   R   Rn   R)   R(   t   getR$   R   R   R   R:   R'   R#   RU   R   RZ   R   R   (   RJ   R'   R   R5  (    (    s/   /tmp/pip-build-zHWFj_/Jinja2/jinja2/compiler.pyRq     s(    	c         C   s   |  j  |  j | j d  | j |  j j k rM |  j d | j | j  n  |  j | j |  |  j | |  |  j  d  d  S(   NR  s   no test named %rR   (	   R   Ro   R)   R(   R   R   R#   R'   R   (   RJ   R'   R   (    (    s/   /tmp/pip-build-zHWFj_/Jinja2/jinja2/compiler.pyRr   4  s    c            sz       f d   }  j  d   j  j     j  d   j  j     j  d  |    j  d  d  S(   Nc              sD    j  d  k	 r"  j  j     S j d d  j    d  S(   Ns   environment.undefined(%r)sR   the inline if-expression on %s evaluated to false and no else section was defined.(   t   expr2R$   R#   R   R   (    (   R   R'   RJ   (    s/   /tmp/pip-build-zHWFj_/Jinja2/jinja2/compiler.pyt   write_expr2=  s    R  s    if s    else R   (   R   R#   t   expr1R}   (   RJ   R'   R   Rt  (    (   R   R'   RJ   s/   /tmp/pip-build-zHWFj_/Jinja2/jinja2/compiler.pyt   visit_CondExpr<  s    c         C   sy   |  j  j r |  j d  n |  j d  |  j | j |  | rO i d d 6pR d  } |  j | | |  |  j d  d  S(   Ns   environment.call(context, s   context.call(R   R   (   R(   RP  R   R#   R'   R$   R   (   RJ   R'   R   R#  R   (    (    s/   /tmp/pip-build-zHWFj_/Jinja2/jinja2/compiler.pyR$  L  s    c         C   s+   |  j  | j d  |  j | j |  d  S(   Nt   =(   R   R>   R#   R<   (   RJ   R'   R   (    (    s/   /tmp/pip-build-zHWFj_/Jinja2/jinja2/compiler.pyt   visit_KeywordV  s    c         C   s1   |  j  d  |  j | j |  |  j  d  d  S(   Ns   Markup(R   (   R   R#   Rb  (   RJ   R'   R   (    (    s/   /tmp/pip-build-zHWFj_/Jinja2/jinja2/compiler.pyt   visit_MarkSafe\  s    c         C   s1   |  j  d  |  j | j |  |  j  d  d  S(   Ns5   (context.eval_ctx.autoescape and Markup or identity)(R   (   R   R#   Rb  (   RJ   R'   R   (    (    s/   /tmp/pip-build-zHWFj_/Jinja2/jinja2/compiler.pyt   visit_MarkSafeIfAutoescapea  s    c         C   s   |  j  d | j  d  S(   Ns   environment.(   R   R)   (   RJ   R'   R   (    (    s/   /tmp/pip-build-zHWFj_/Jinja2/jinja2/compiler.pyt   visit_EnvironmentAttributef  s    c         C   s!   |  j  d | j | j f  d  S(   Ns   environment.extensions[%r].%s(   R   t
   identifierR)   (   RJ   R'   R   (    (    s/   /tmp/pip-build-zHWFj_/Jinja2/jinja2/compiler.pyt   visit_ExtensionAttributei  s    c         C   s   |  j  |  j | j  d  S(   N(   R   R   R   (   RJ   R'   R   (    (    s/   /tmp/pip-build-zHWFj_/Jinja2/jinja2/compiler.pyt   visit_ImportedNamel  s    c         C   s   |  j  | j  d  S(   N(   R   R)   (   RJ   R'   R   (    (    s/   /tmp/pip-build-zHWFj_/Jinja2/jinja2/compiler.pyt   visit_InternalNameo  s    c         C   s   |  j  d  d  S(   NR   (   R   (   RJ   R'   R   (    (    s/   /tmp/pip-build-zHWFj_/Jinja2/jinja2/compiler.pyt   visit_ContextReferencer  s    c         C   s   |  j  d |  d  S(   NR  (   R   (   RJ   R'   R   (    (    s/   /tmp/pip-build-zHWFj_/Jinja2/jinja2/compiler.pyt   visit_Continueu  s    c         C   s   |  j  d |  d  S(   Nt   break(   R   (   RJ   R'   R   (    (    s/   /tmp/pip-build-zHWFj_/Jinja2/jinja2/compiler.pyt   visit_Breakx  s    c         C   sb   | j    } | j | j    |  j |  } |  j |  |  j | j |  |  j | |  d  S(   N(   Rj   Re   R   R   R   R   R~   R   (   RJ   R'   R   t   scope_frameR   (    (    s/   /tmp/pip-build-zHWFj_/Jinja2/jinja2/compiler.pyR   {  s    c         C   s   x | j  D] } |  j d | j  |  j | j |  y | j j | j  } Wn  t j k
 rr t	 | j _
 q
 Xt | j | j |  q
 Wd  S(   Ns   context.eval_ctx.%s = (   t   optionsR   R>   R#   R<   R0  RU   R   R/  R0   R   t   setattr(   RJ   R'   R   t   keywordR9  (    (    s/   /tmp/pip-build-zHWFj_/Jinja2/jinja2/compiler.pyt   visit_EvalContextModifier  s    c         C   s   |  j    } | j j   } |  j d |  |  j | |  x! | j D] } |  j | |  qF W| j j |  |  j d |  d  S(   Ns   %s = context.eval_ctx.save()s   context.eval_ctx.revert(%s)(   R   RU   t   saveR   R  R~   R#   t   revert(   RJ   R'   R   t   old_ctx_namet	   safed_ctxR7  (    (    s/   /tmp/pip-build-zHWFj_/Jinja2/jinja2/compiler.pyt   visit_ScopedEvalContextModifier  s    N(    (Y   RQ   RR   R$   R:   RK   R   R   RZ   R   R   R   R   R   R   R   R   R   R   R   R   R   R   R   R   R0   R   R   R   R   R   Rs   R  R  R   R   R   R   R   R   R   R'  R=  R@  RE  R   R   Rv   RG  RI  RJ  RM  RO  RV  RX  t	   visit_Addt	   visit_Subt	   visit_Mult	   visit_Divt   visit_FloorDivt	   visit_Powt	   visit_Modt	   visit_Andt   visit_Ort	   visit_Post	   visit_Negt	   visit_NotRa  Re  Rg  Ri  Rk  Rn  Rq   Rr   Rv  R$  Rx  Ry  Rz  R{  R}  R~  R  R  R  R  R   R  R  (    (    (    s/   /tmp/pip-build-zHWFj_/Jinja2/jinja2/compiler.pyR   p  s   6								5				D			c		/	+		5	~																		
						
			
												N(2   RS   t	   itertoolsR    RP   R   R  R   R   t   jinja2R   t   jinja2.nodesR   t   jinja2.visitorR   t   jinja2.exceptionsR   t   jinja2.utilsR   R   R	   t   jinja2._compatR
   R   R   R   R   R   Rf  R1  R;   R  R   R1   R   R$   R:   R-   R9   RD   R_   RE   RT   t   RuntimeErrorR@   Rm   R?   Rd   R2  R   R   (    (    (    s/   /tmp/pip-build-zHWFj_/Jinja2/jinja2/compiler.pyt   <module>
   sH   .
				%XY