
    F d                     D   d dl 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 ddlmZ ddlmZ ddlmZ dej        ej                 dej        ej                 fdZ G d de          Z G d de          Z G d de          Zee_        dS )    N)literal_eval)parse)chain)islice)GeneratorType   )nodes)CodeGenerator)Frame)has_safe_repr)Environment)Templatevaluesreturnc                    t          t          | d                    }|sdS t          |          dk    r |d         }t          |t                    s|S nDt          | t
                    rt          ||           } d                    d | D                       }	 t          t          |d                    S # t          t          t          f$ r |cY S w xY w)	an  Return a native Python type from the list of compiled nodes. If
    the result is a single node, its value is returned. Otherwise, the
    nodes are concatenated as strings. If the result can be parsed with
    :func:`ast.literal_eval`, the parsed value is returned. Otherwise,
    the string is returned.

    :param values: Iterable of outputs to concatenate.
       Nr   r    c                 ,    g | ]}t          |          S  str.0vs     [C:\Users\ChattiNader\Documents\MyHotelMatch\api\dev\Lib\site-packages\jinja2/nativetypes.py
<listcomp>z!native_concat.<locals>.<listcomp>%   s    ...!s1vv...    eval)mode)listr   len
isinstancer   r   r   joinr   r   
ValueErrorSyntaxErrorMemoryError)r   headraws      r   native_concatr)      s     vq!!""D t
4yyA~~1g#s## 	J	 fm,, 	)4((Fgg..v...// #F###	
 
 	
 [1   


s   B8 8CCc                      e Zd ZdZedej        dej        fd            Zdej        ej                 de	fdZ
dej        ded	ej        dej        fd
Zdej        ded	ej        ddfdZdej        ded	ej        ddfdZdS )NativeCodeGeneratorzaA code generator which renders Python types by not adding
    ``str()`` around output nodes.
    valuer   c                     | S Nr   )r,   s    r   _default_finalizez%NativeCodeGenerator._default_finalize7   s    r   groupc                 Z    t          d                    d |D                                 S )Nr   c                 ,    g | ]}t          |          S r   r   r   s     r   r   z:NativeCodeGenerator._output_const_repr.<locals>.<listcomp><   s    333SVV333r   )reprr#   )selfr0   s     r   _output_const_reprz&NativeCodeGenerator._output_const_repr;   s+    BGG33U33344555r   nodeframefinalizec                     |                     |j                  }t          |          st          j                    t          |t          j                  r|S |                    |          S r.   )as_consteval_ctxr   r	   
Impossibler"   TemplateDataconst)r4   r6   r7   r8   r>   s        r   _output_child_to_constz*NativeCodeGenerator._output_child_to_const>   sb     en--U## 	%"$$$dE.// 	L~~e$$$r   Nc                 L    |j         |                     |j                    d S d S r.   srcwriter4   r6   r7   r8   s       r   _output_child_prez%NativeCodeGenerator._output_child_preK   s.     <#JJx|$$$$$ $#r   c                 B    |j         |                     d           d S d S )N)rA   rD   s       r   _output_child_postz&NativeCodeGenerator._output_child_postQ   s'     <#JJsOOOOO $#r   )__name__
__module____qualname____doc__staticmethodtAnyr/   Iterabler   r5   r	   Exprr   r
   _FinalizeInfor?   rE   rH   r   r   r   r+   r+   2   s(          15    \6
15(9 6c 6 6 6 6%J%',%8E8S%	
% % % %%J%',%8E8S%	% % % %J',8E8S	     r   r+   c                   ,    e Zd ZdZeZ ee          ZdS )NativeEnvironmentz=An environment that renders templates to native Python types.N)	rI   rJ   rK   rL   r+   code_generator_classrM   r)   concatr   r   r   rT   rT   X   s)        GG.\-((FFFr   rT   c                   v    e Zd ZeZdej        dej        dej        fdZdej        dej        dej        fdZdS )NativeTemplateargskwargsr   c                     |                      t          |i |          }	 | j                            |                     |                    S # t
          $ r | j                                        cY S w xY w)aB  Render the template to produce a native Python type. If the
        result is a single node, its value is returned. Otherwise, the
        nodes are concatenated as strings. If the result can be parsed
        with :func:`ast.literal_eval`, the parsed value is returned.
        Otherwise, the string is returned.
        )new_contextdictenvironment_classrV   root_render_func	Exceptionenvironmenthandle_exceptionr4   rY   rZ   ctxs       r   renderzNativeTemplate.renderb   s     tT4V4455	7)00%%c**    	7 	7 	7#4466666	7s   ,A #A43A4c                 H  K   | j         j        st          d          |                     t	          |i |          }	 | j                            d |                     |          2              d {V           S # t          $ r | j         	                                cY S w xY w)Nz8The environment was not created with async mode enabled.c                 "   K   g | 3 d {V }|
6 S r.   r   )r   ns     r   r   z/NativeTemplate.render_async.<locals>.<listcomp>|   s.      ========Q====s   )
ra   is_asyncRuntimeErrorr\   r]   r^   rV   r_   r`   rb   rc   s       r   render_asynczNativeTemplate.render_asyncr   s      ( 	J   tT4V4455	7)00==$"7"7"<"<=========    	7 	7 	7#4466666	7s   <A; ;#B! B!N)	rI   rJ   rK   rT   r^   rN   rO   re   rk   r   r   r   rX   rX   _   sx        )7AE 7QU 7qu 7 7 7 7 7 7 715 7 7 7 7 7 7r   rX   )typingrN   astr   r   	itertoolsr   r   typesr   r   r	   compilerr
   r   r   ra   r   r   rP   rO   Optionalr)   r+   rT   rX   template_classr   r   r   <module>rs      s                                           # # # # # #       # # # # # # $ $ $ $ $ $ ! ! ! ! ! !!*QU+ 
150A    D# # # # #- # # #L) ) ) ) ) ) ) ) 7  7  7  7  7X  7  7  7F $2       r   