
    F 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 ej        rddlmZ ddlmZ dej        eej        f         fdZ G d de          Z G d de          Zdddedej        eej        f         defdZdej        eeej        ej        eef                  f         dej        defdZdedej        defdZ dddedej        eej        f         dej!        e         fdZ"dej        eeej        ej        eef                  f         dej        dej!        e         fd Z#dedej        dej!        e         fd!Z$dS )"    N)
BaseLoader)Environment)Template)TemplateNotFound   )_cv_app)_cv_request)current_app)request)stream_with_context)before_render_template)template_rendered)Flask)Scaffoldreturnc                      t          j        d          } t          j        d          }i }| 
| j        |d<   ||j        |d<   |j        |d<   |S )zSDefault template context processor.  Injects `request`,
    `session` and `g`.
    Ngr   session)r   getr	   r   r   r   )appctxreqctxrvs      YC:\Users\ChattiNader\Documents\MyHotelMatch\api\dev\Lib\site-packages\flask/templating.py_default_template_ctx_processorr      sY     [F_T""FB(399I    c                   0    e Zd ZdZdddej        ddfdZdS )r   zWorks like a regular Jinja2 environment but has some additional
    knowledge of how Flask's blueprint works so that it can prepend the
    name of the blueprint to referenced templates if necessary.
    appr   optionsr   Nc                 n    d|vr|                                 |d<   t          j        | fi | || _        d S )Nloader)create_global_jinja_loaderBaseEnvironment__init__r   )selfr   r   s      r   r#   zEnvironment.__init__*   sG    7"" # > > @ @GH 11111r   )__name__
__module____qualname____doc__tAnyr#    r   r   r   r   $   sI         
G  $      r   r   c            
          e Zd ZdZddZdededej        eej	        e         ej	        ej
                 f         fd	Zdededej        eej	        e         ej	        ej
                 f         fd
Zdededej        eej	        e         ej	        ej
                 f         fdZdedej        ej        def         ddf         fdZdej        e         fdZdS )DispatchingJinjaLoaderz\A loader that looks for templates in the application and all
    the blueprint folders.
    r   r   r   Nc                     || _         d S N)r   )r$   r   s     r   r#   zDispatchingJinjaLoader.__init__6   s    r   environmenttemplatec                 ~    | j         j        d         r|                     ||          S |                     ||          S )NEXPLAIN_TEMPLATE_LOADING)r   config_get_source_explained_get_source_fast)r$   r0   r1   s      r   
get_sourcez!DispatchingJinjaLoader.get_source9   sC     8?56 	E--k8DDD$$[(;;;r   c                 "   g }d }|                      |          D ]K\  }}	 |                    ||          }||}n# t          $ r d }Y nw xY w|                    |||f           Lddlm}  || j        ||           ||S t          |          )Nr   )!explain_template_loading_attempts)_iter_loadersr7   r   appenddebughelpersr9   r   )	r$   r0   r1   attemptstrvsrcobjr    r   r9   s	            r   r5   z,DispatchingJinjaLoader._get_source_explained@   s       	 #00:: 	2 	2NFF&&{H==;C#   OOVVR01111CCCCCC))$(HhGGG?Jx(((s   ;A
	A
c                     |                      |          D ]-\  }}	 |                    ||          c S # t          $ r Y *w xY wt          |          r/   )r:   r7   r   )r$   r0   r1   _srcobjr    s        r   r6   z'DispatchingJinjaLoader._get_source_fastZ   st      $11(;; 	 	OGV((h?????#   x(((s   4
A Ar   c              #      K   | j         j        }|| j         |fV  | j                                         D ]}|j        }|||fV  d S r/   )r   jinja_loaderiter_blueprints)r$   r1   r    	blueprints       r   r:   z$DispatchingJinjaLoader._iter_loadersd   sr       &(F""""1133 	( 	(I+F!''''	( 	(r   c                 H   t                      }| j        j        }|'|                    |                                           | j                                        D ]7}|j        }|,|                                D ]}|                    |           8t          |          S r/   )setr   rC   updatelist_templatesrD   addlist)r$   resultr    rE   r1   s        r   rI   z%DispatchingJinjaLoader.list_templatesp   s    &MM&//112221133 	) 	)I+F! & 5 5 7 7 ) )HJJx((((F||r   )r   r   r   N)r%   r&   r'   r(   r#   r   strr)   TupleOptionalCallabler7   r5   r6   	Generatorr   r:   ListrI   r+   r   r   r-   r-   1   sl           <&<25<	
ajoqz!*'==	>< < < <)&)25)	
ajoqz!*'==	>) ) ) )4)&)25)	
ajoqz!*'==	>) ) ) )
(
(	
QWZ34dD@	A
( 
( 
( 
(s      r   r-   r   r   r1   contextc                     |                      |           t          j        | ||           |                    |          }t	          j        | ||           |S Nr1   rS   )update_template_contextr   sendrenderr   )r   r1   rS   r   s       r   _renderrZ      s\    (((hHHHH		!	!B37CCCCIr   template_name_or_listc                 ~    t          j                    }|j                            |           }t	          |||          S )a  Render a template by name with the given context.

    :param template_name_or_list: The name of the template to render. If
        a list is given, the first name to exist will be rendered.
    :param context: The variables to make available in the template.
    )r
   _get_current_object	jinja_envget_or_select_templaterZ   r[   rS   r   r1   s       r   render_templatera      s:     
)
+
+C}334IJJH3'***r   sourcec                 ~    t          j                    }|j                            |           }t	          |||          S )zRender a template from the given source string with the given
    context.

    :param source: The source code of the template to render.
    :param context: The variables to make available in the template.
    )r
   r]   r^   from_stringrZ   rb   rS   r   r1   s       r   render_template_stringrf      s9     
)
+
+C}((00H3'***r   c                                                       t          j                    dt          j        t
                   f fd} |            }t          rt          |          }|S )NrV   r   c               3   p   K                                  E d {V  t          j                    d S rU   )generater   rX   )r   rS   r1   s   r   ri   z_stream.<locals>.generate   sK      $$W---------sXwGGGGGGr   )rW   r   rX   r)   IteratorrM   r   r   )r   r1   rS   ri   r   s   ```  r   _streamrk      s     (((hHHHHHajo H H H H H H H H 
B  % $$Ir   c                 ~    t          j                    }|j                            |           }t	          |||          S )a  Render a template by name with the given context as a stream.
    This returns an iterator of strings, which can be used as a
    streaming response from a view.

    :param template_name_or_list: The name of the template to render. If
        a list is given, the first name to exist will be rendered.
    :param context: The variables to make available in the template.

    .. versionadded:: 2.2
    )r
   r]   r^   r_   rk   r`   s       r   stream_templaterm      s:     
)
+
+C}334IJJH3'***r   c                 ~    t          j                    }|j                            |           }t	          |||          S )aZ  Render a template from the given source string with the given
    context as a stream. This returns an iterator of strings, which can
    be used as a streaming response from a view.

    :param source: The source code of the template to render.
    :param context: The variables to make available in the template.

    .. versionadded:: 2.2
    )r
   r]   r^   rd   rk   re   s       r   stream_template_stringro      s9     
)
+
+C}((00H3'***r   )%typingr)   jinja2r   r   r"   r   r   globalsr   r	   r
   r   helpersr   signalsr   r   TYPE_CHECKINGr   r   scaffoldr   DictrM   r*   r   r-   rZ   UnionrR   ra   rf   rj   rk   rm   ro   r+   r   r   <module>ry      s             1 1 1 1 1 1       # # # # # #                                     ( ( ( ( ( ( + + + + + + & & & & & &? #""""""QU
);    
 
 
 
 
/ 
 
 
K K K K KZ K K K\ H qvc15j7I c    +73!&h9O2P#PQ+u+ 	+ + + +	+3 	+15 	+S 	+ 	+ 	+ 	+	$/0vc15j/AZ_   &+73!&h9O2P#PQ+u+ Z_+ + + +&+3 +15 +QZ_ + + + + + +r   