
    0hq                    |   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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)App)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      H/var/www/auris/envauris/lib/python3.13/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                  x    \ 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
)DispatchingJinjaLoader4   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__9   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debughelpersrC   r$   )	r%   r>   r?   attemptstrvsrcobjr    r   rC   s	            r   r<   ,DispatchingJinjaLoader._get_source_explainedC   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r7   )rD   r@   r   )r%   r>   r?   _srcobjr    s        r   r=   'DispatchingJinjaLoader._get_source_fast[   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r7   )r$   jinja_loaderiter_blueprints)r%   r?   r    	blueprints       r   rD   $DispatchingJinjaLoader._iter_loaderse   sZ     &&((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      $ r7   )setr$   rO   updatelist_templatesrP   addlist)r%   resultr    rQ   r?   s        r   rV   %DispatchingJinjaLoader.list_templateso   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*   z3tuple[str, str | None, t.Callable[[], bool] | None])r?   r[   r*   z't.Iterator[tuple[Scaffold, BaseLoader]])r*   z	list[str])r,   r-   r.   r/   r0   r#   r@   r<   r=   rD   rV   r1   r2   r   r   r4   r4   4   sm    <*<69<	<<)*)69)	<)0)*)69)	<)(r   r4   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   _renderre   ~   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_templatere   template_name_or_listr`   r$   r?   s       r   render_templaterl      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   rg   rh   from_stringre   sourcer`   r$   r?   s       r   render_template_stringrq      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   rb   rc   )r$   r`   r?   s   r   rt   _stream.<locals>.generate   s:     $$W---(G	
 	.s   A?'A)r*   t.Iterator[str])ra   r   rb   rc   r   r   )r$   r?   r`   rt   r   s   ```  r   _streamrw      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   rg   rh   ri   rw   rj   s       r   stream_templatery      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   rg   rh   rn   rw   ro   s       r   stream_template_stringr{      s3     
)
)
+C}}((0H3'**r   )r*   dict[str, t.Any])r$   r   r?   r   r`   r|   r*   r[   )rk   %str | Template | list[str | Template]r`   r)   r*   r[   )rp   r[   r`   r)   r*   r[   )r$   r   r?   r   r`   r|   r*   rv   )rk   r}   r`   r)   r*   rv   )rp   r[   r`   r)   r*   rv   )#
__future__r   typingtjinja2r   r   r"   r   r   globalsr	   r
   r   r   helpersr   signalsr   r   TYPE_CHECKINGr$   r   
sansio.appr   sansio.scaffoldr   r   r4   re   rl   rq   rw   ry   r{   r2   r   r   <module>r      s    "   1  #       ( + &??)
/ 
GZ GT	+@++ 	+	+	"-=.+@++ +&+r   