
    2Bf                        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 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ededddefdZdej4                  eej6                  e   f   dej*                  defdZdedej*                  defdZy)    N)
BaseLoader)Environment)Template)TemplateNotFound   )_app_ctx_stack)_request_ctx_stack)before_render_template)template_rendered)Flask)Scaffoldreturnc                      t         j                  } t        j                  }i }||j                  |d<   | | j                  |d<   | j
                  |d<   |S )zSDefault template context processor.  Injects `request`,
    `session` and `g`.
    grequestsession)r	   topr   r   r   r   )reqctxappctxrvs      P/var/www/highfloat_scraper/venv/lib/python3.12/site-packages/flask/templating.py_default_template_ctx_processorr      sW      ##FF	B((399I    c                   8    e Zd ZdZdddej
                  ddfdZy)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                 l    d|vr|j                         |d<   t        j                  | fi | || _        y )Nloader)create_global_jinja_loaderBaseEnvironment__init__r   )selfr   r   s      r   r!   zEnvironment.__init__'   s7    7" # > > @GH  11r   )__name__
__module____qualname____doc__tAnyr!    r   r   r   r   !   s%    
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y)DispatchingJinjaLoaderz\A loader that looks for templates in the application and all
    the blueprint folders.
    r   Nc                     || _         y N)r   )r"   r   s     r   r!   zDispatchingJinjaLoader.__init__3   s	    r   environmenttemplatec                 |    | j                   j                  d   r| j                  ||      S | j                  ||      S )NEXPLAIN_TEMPLATE_LOADING)r   config_get_source_explained_get_source_fast)r"   r.   r/   s      r   
get_sourcez!DispatchingJinjaLoader.get_source6   s;     88??56--k8DD$$[(;;r   c                    g }d }| j                  |      D ]0  \  }}	 |j                  ||      }||}|j                  |||f       2 ddlm}  || j                  ||       ||S t        |      # t        $ r d }Y Lw xY w)Nr   )!explain_template_loading_attempts)_iter_loadersr5   r   appenddebughelpersr7   r   )	r"   r.   r/   attemptstrvsrcobjr   r   r7   s	            r   r3   z,DispatchingJinjaLoader._get_source_explained=   s       	 #00: 	2NFF&&{H=;C OOVVR01	2 	D)$((HhG?Jx(( $ s   A22B ?B c                     | j                  |      D ]  \  }}	 |j                  ||      c S  t        |      # t        $ r Y 2w xY wr-   )r8   r5   r   )r"   r.   r/   _srcobjr   s        r   r4   z'DispatchingJinjaLoader._get_source_fastW   s[      $11(; 	OGV((h??	
 x(( $ s   9	AAr   c              #      K   | j                   j                  }|| j                   |f | j                   j                         D ]  }|j                  }|||f  y wr-   )r   jinja_loaderiter_blueprints)r"   r/   r   	blueprints       r   r8   z$DispatchingJinjaLoader._iter_loadersa   sd      &&((F""113 	(I++F!''	(s   AA 	A c                 B   t               }| j                  j                  }||j                  |j	                                | j                  j                         D ]7  }|j                  }||j	                         D ]  }|j                  |        9 t        |      S r-   )setr   rA   updatelist_templatesrB   addlist)r"   resultr   rC   r/   s        r   rG   z%DispatchingJinjaLoader.list_templatesm   s    &&MM&//12113 	)I++F! & 5 5 7 )HJJx()	) F|r   )r   r   r   N)r#   r$   r%   r&   r!   r   strr'   TupleOptionalCallabler5   r3   r4   	Generatorr   r8   ListrG   r)   r   r   r+   r+   .   s   <&<25<	
ajjoqzz!**'==	><)&)25)	
ajjoqzz!**'==	>)4)&)25)	
ajjoqzz!**'==	>)
(
(	
QWWZ34dD@	A
(s r   r+   r/   contextr   r   c                     t        j                  || |       | j                  |      }t        j                  || |       |S )z)Renders the template and fires the signal)r/   rQ   )r
   sendrenderr   )r/   rQ   r   r   s       r   _renderrU   |   s;     hH		!B37CIr   template_name_or_listc                     t         j                  }|j                  j                  |       t	        |j                  j
                  j                  |       ||j                        S )a  Renders a template from the template folder with the given
    context.

    :param template_name_or_list: the name of the template to be
                                  rendered, or an iterable with template names
                                  the first one existing will be rendered
    :param context: the variables that should be available in the
                    context of the template.
    )r   r   r   update_template_contextrU   	jinja_envget_or_select_template)rV   rQ   ctxs      r   render_templater\      sQ     

CGG##G,001FG r   sourcec                     t         j                  }|j                  j                  |       t	        |j                  j
                  j                  |       ||j                        S )aF  Renders a template from the given template source string
    with the given context. Template variables will be autoescaped.

    :param source: the source code of the template to be
                   rendered
    :param context: the variables that should be available in the
                    context of the template.
    )r   r   r   rX   rU   rY   from_string)r]   rQ   r[   s      r   render_template_stringr`      sI     

CGG##G,377$$008'377KKr   )typingr'   jinja2r   r   r    r   r   globalsr   r	   signalsr
   r   TYPE_CHECKINGr   r   scaffoldr   DictrK   r(   r   r+   dictrU   UnionrP   r\   r`   r)   r   r   <module>rj      s      1  # # ' + &??"QUU
); 
/ 
KZ K\h  G  773s#34AB*L3 L155 LS Lr   