
    EthO                    4   d dl mZ 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)dZ G d de          Z G d de          Zd*dZd+d"Zd,d$Zd-d&Zd.d'Zd/d(Z dS )0    )annotationsN)
BaseLoader)Environment)Template)TemplateNotFound   )_cv_app)_cv_request)current_app)request)stream_with_context)before_render_template)template_rendered)Flask)Scaffoldreturndict[str, t.Any]c                     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      d/var/www/html/mycamper/aliexpress-site/backend/venv/lib/python3.11/site-packages/flask/templating.py_default_template_ctx_processorr      sY     [F_T""FB(399I    c                      e Zd ZdZd
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   optionst.Anyr   Nonec                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   N)r   r   r    r!   r   r"   )__name__
__module____qualname____doc__r'    r   r   r   r   &   s2         
     r   r   c                  B    e Zd ZdZddZddZddZddZddZddZ	dS )DispatchingJinjaLoaderz\A loader that looks for templates in the application and all
    the blueprint folders.
    r   r   r   r"   c                    || _         d S N)r   )r(   r   s     r   r'   zDispatchingJinjaLoader.__init__8   s    r   environmentr   templatestr)tuple[str, str | None, t.Callable | None]c                ~    | j         j        d         r|                     ||          S |                     ||          S )NEXPLAIN_TEMPLATE_LOADING)r   config_get_source_explained_get_source_fast)r(   r2   r3   s      r   
get_sourcez!DispatchingJinjaLoader.get_source;   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_loadersr;   r   appenddebughelpersr=   r   )	r(   r2   r3   attemptstrvsrcobjr$   r   r=   s	            r   r9   z,DispatchingJinjaLoader._get_source_explainedB   s     LP"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          |          r1   )r>   r;   r   )r(   r2   r3   _srcobjr$   s        r   r:   z'DispatchingJinjaLoader._get_source_fastZ   st      $11(;; 	 	OGV((h?????#   x(((s   4
A A4t.Generator[tuple[Scaffold, BaseLoader], None, None]c              #     K   | j         j        }|| j         |fV  | j                                         D ]}|j        }|||fV  d S r1   )r   jinja_loaderiter_blueprints)r(   r3   r$   	blueprints       r   r>   z$DispatchingJinjaLoader._iter_loadersd   sr       &(F""""1133 	( 	(I+F!''''	( 	(r   	list[str]c                H   t                      }| j        j        }|'|                    |                                           | j                                        D ]7}|j        }|,|                                D ]}|                    |           8t          |          S r1   )setr   rH   updatelist_templatesrI   addlist)r(   resultr$   rJ   r3   s        r   rO   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   N)r   r   r   r"   )r2   r   r3   r4   r   r5   )r3   r4   r   rF   )r   rK   )
r)   r*   r+   r,   r'   r;   r9   r:   r>   rO   r-   r   r   r/   r/   3   s            < < < <) ) ) )0) ) ) )
( 
( 
( 
(     r   r/   r   r   r3   r   contextr4   c                    |                      |           t          j        | | j        ||           |                    |          }t          j        | | j        ||           |S N_async_wrapperr3   rS   )update_template_contextr   sendensure_syncrenderr   )r   r3   rS   r   s       r   _renderr\      sz    (((COh    
	!	!BCOh    Ir   template_name_or_list%str | Template | list[str | Template]r!   c                ~    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_templater\   r]   rS   r   r3   s       r   render_templaterd      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`   ra   from_stringr\   re   rS   r   r3   s       r   render_template_stringri      s9     
)
+
+C}((00H3'***r   t.Iterator[str]c                                                      t          j          j                   d fd} |            }t          rt          |          }|S )NrV   r   rj   c               3  |   K                                  E d {V  t          j          j                   d S rU   )generater   rY   rZ   )r   rS   r3   s   r   rm   z_stream.<locals>.generate   s\      $$W---------(G	
 	
 	
 	
 	
 	
r   )r   rj   )rX   r   rY   rZ   r   r   )r   r3   rS   rm   r   s   ```  r   _streamrn      s     (((COh   
 
 
 
 
 
 
 
 
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`   ra   rb   rn   rc   s       r   stream_templaterp      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`   ra   rg   rn   rh   s       r   stream_template_stringrr      s9     
)
+
+C}((00H3'***r   )r   r   )r   r   r3   r   rS   r   r   r4   )r]   r^   rS   r!   r   r4   )re   r4   rS   r!   r   r4   )r   r   r3   r   rS   r   r   rj   )r]   r^   rS   r!   r   rj   )re   r4   rS   r!   r   rj   )!
__future__r   typingtjinja2r   r   r&   r   r   globalsr	   r
   r   r   helpersr   signalsr   r   TYPE_CHECKINGr   r   scaffoldr   r   r/   r\   rd   ri   rn   rp   rr   r-   r   r   <module>r|      s
   " " " " " "           1 1 1 1 1 1       # # # # # #                                     ( ( ( ( ( ( + + + + + + & & & & & &? #""""""   
 
 
 
 
/ 
 
 
I I I I IZ I I IX	 	 	 	+ + + +	+ 	+ 	+ 	+   .+ + + +&+ + + + + +r   