
    hO                    p   S SK Jr  S SKrS SKJr  S SKJr  S SKJr  S SKJ	r	  SSK
Jr  SS	K
Jr  SS
K
Jr  SSK
Jr  SSKJr  SSKJr  SSKJr  \R(                  (       a  SSKJr  SSKJr  SS jr " S S\5      r " S S\5      rSS jr      SS jrSS jr        S S jr      S!S jrS"S jr g)#    )annotationsN)
BaseLoader)Environment)Template)TemplateNotFound   )_cv_app)_cv_request)current_app)request)stream_with_context)before_render_template)template_rendered)Flask)Scaffoldc                     [         R                  " S5      n [        R                  " S5      n0 nU b  U R                  US'   Ub  UR                  US'   UR
                  US'   U$ )zKDefault template context processor.  Injects `request`,
`session` and `g`.
Ngr   session)r	   getr
   r   r   r   )appctxreqctxrvs      eC:\Users\ROHAN GUPTA\OneDrive\Desktop\mathbuddy-assessment\venv\Lib\site-packages\flask/templating.py_default_template_ctx_processorr      s]     [[F__T"FB((399I    c                  "    \ rS rSrSrSS jrSrg)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.
c                p    SU;  a  UR                  5       US'   [        R                  " U 40 UD6  Xl        g )Nloader)create_global_jinja_loaderBaseEnvironment__init__app)selfr#   optionss      r   r"   Environment.__init__,   s5    7" # > > @GH  11r   r#   N)r#   r   r%   t.AnyreturnNone)__name__
__module____qualname____firstlineno____doc__r"   __static_attributes__ r   r   r   r   &   s    
r   r   c                      \ rS rSrSrSS jr      SS jr      SS jr      SS jr    SS jr	SS jr
S	rg
)DispatchingJinjaLoader3   zTA loader that looks for templates in the application and all
the blueprint folders.
c                    Xl         g Nr'   )r$   r#   s     r   r"   DispatchingJinjaLoader.__init__8   s    r   c                    U R                   R                  S   (       a  U R                  X5      $ U R                  X5      $ )NEXPLAIN_TEMPLATE_LOADING)r#   config_get_source_explained_get_source_fast)r$   environmenttemplates      r   
get_source!DispatchingJinjaLoader.get_source;   s7     88??56--kDD$$[;;r   c                   / nS nU R                  U5       H/  u  pV UR                  X5      nUc  UnUR                  XeU45        M1     SSKJn  U" U R                  X#5        Ub  U$ [        U5      e! [         a    S n NNf = f)Nr   )!explain_template_loading_attempts)_iter_loadersr?   r   appenddebughelpersrB   r#   )	r$   r=   r>   attemptstrvsrcobjr   r   rB   s	            r   r;   ,DispatchingJinjaLoader._get_source_explainedB   s     LP"00:NF&&{=;C OOVR01 ; 	D)$((HG?Jx(( $ s   A22B Bc                    U R                  U5       H  u  p4 UR                  X5      s  $    [        U5      e! [         a     M3  f = fr6   )rC   r?   r   )r$   r=   r>   _srcobjr   s        r   r<   'DispatchingJinjaLoader._get_source_fastZ   sR      $11(;OG((??  <
 x(( $ s   8
AAc              #     #    U R                   R                  nUb  U R                   U4v   U R                   R                  5        H  nUR                  nUc  M  X24v   M     g 7fr6   )r#   jinja_loaderiter_blueprints)r$   r>   r   	blueprints       r   rC   $DispatchingJinjaLoader._iter_loadersd   s\      &&((F""113I++F!'' 4s   AA$
A$c                P   [        5       nU R                  R                  nUb  UR                  UR	                  5       5        U R                  R                  5        H<  nUR                  nUc  M  UR	                  5        H  nUR                  U5        M     M>     [        U5      $ r6   )setr#   rN   updatelist_templatesrO   addlist)r$   resultr   rP   r>   s        r   rU   %DispatchingJinjaLoader.list_templatesp   s    &&MM&//12113I++F! & 5 5 7HJJx( !8 4 F|r   r'   N)r#   r   r)   r*   )r=   r   r>   strr)   z)tuple[str, str | None, t.Callable | None])r>   rZ   r)   z4t.Generator[tuple[Scaffold, BaseLoader], None, None])r)   z	list[str])r+   r,   r-   r.   r/   r"   r?   r;   r<   rC   rU   r0   r1   r   r   r3   r3   3   s}    <&<25<	2<)&)25)	2)0)&)25)	2)
(
(	=
(r   r3   c                    U R                  U5        [        R                  " X R                  XS9  UR	                  U5      n[
        R                  " X R                  XS9  U$ N_async_wrapperr>   context)update_template_contextr   sendensure_syncrenderr   )r#   r>   r_   r   s       r   _renderrd      sU    (OOh 
	!BOOh Ir   c                z    [         R                  " 5       nUR                  R                  U 5      n[	        X#U5      $ )zRender 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_templaterd   template_name_or_listr_   r#   r>   s       r   render_templaterk      s4     
)
)
+C}}334IJH3'**r   c                z    [         R                  " 5       nUR                  R                  U 5      n[	        X#U5      $ )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   rf   rg   from_stringrd   sourcer_   r#   r>   s       r   render_template_stringrp      s3     
)
)
+C}}((0H3'**r   c                   ^ ^^ T R                  T5        [        R                  " T T R                  TTS9  SU UU4S jjnU" 5       n[        (       a  [        U5      nU$ )Nr]   c               3     >#    TR                  T5       S h  vN   [        R                  " T T R                  TTS9  g  N&7fr\   )generater   ra   rb   )r#   r_   r>   s   r   rs   _stream.<locals>.generate   s:     $$W---(G	
 	.s   A?'A)r)   t.Iterator[str])r`   r   ra   rb   r   r   )r#   r>   r_   rs   r   s   ```  r   _streamrv      sW     (COOh
 
 
B w $Ir   c                z    [         R                  " 5       nUR                  R                  U 5      n[	        X#U5      $ )aw  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   rf   rg   rh   rv   ri   s       r   stream_templaterx      s4     
)
)
+C}}334IJH3'**r   c                z    [         R                  " 5       nUR                  R                  U 5      n[	        X#U5      $ )aB  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   rf   rg   rm   rv   rn   s       r   stream_template_stringrz      s3     
)
)
+C}}((0H3'**r   )r)   dict[str, t.Any])r#   r   r>   r   r_   r{   r)   rZ   )rj   %str | Template | list[str | Template]r_   r(   r)   rZ   )ro   rZ   r_   r(   r)   rZ   )r#   r   r>   r   r_   r{   r)   ru   )rj   r|   r_   r(   r)   ru   )ro   rZ   r_   r(   r)   ru   )!
__future__r   typingtjinja2r   r   r!   r   r   globalsr	   r
   r   r   helpersr   signalsr   r   TYPE_CHECKINGr#   r   scaffoldr   r   r3   rd   rk   rp   rv   rx   rz   r1   r   r   <module>r      s    "   1  #       ( + &??"
/ 
IZ IX	+@++ 	+	+	"-=.+@++ +&+r   