HEX
Server: Apache/2.4.52 (Ubuntu)
System: Linux spn-python 5.15.0-89-generic #99-Ubuntu SMP Mon Oct 30 20:42:41 UTC 2023 x86_64
User: arjun (1000)
PHP: 8.1.2-1ubuntu2.20
Disabled: NONE
Upload Files
File: //home/arjun/projects/env/lib/python3.10/site-packages/flask/__pycache__/templating.cpython-310.pyc
o

'weO�@s ddlmZddlZddlmZddlmZddlmZddlm	Z	ddl
mZdd	l
mZdd
l
m
Z
ddl
mZddlmZdd
lmZddlmZejr[ddlmZddlmZd0dd�ZGdd�de�ZGdd�de�Zd1dd �Zd2d$d%�Zd3d'd(�Zd4d*d+�Zd5d,d-�Zd6d.d/�Z dS)7�)�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]cCsJt�d�}t�d�}i}|dur|j|d<|dur#|j|d<|j|d<|S)zSDefault template context processor.  Injects `request`,
    `session` and `g`.
    N�gr�session)r�getr	rrr)�appctx�reqctx�rv�r�I/home/arjun/projects/env/lib/python3.10/site-packages/flask/templating.py�_default_template_ctx_processors




rc@seZdZdZddd	�Zd
S)rz�Works 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�NonecKs0d|vr
|��|d<tj|fi|��||_dS)N�loader)�create_global_jinja_loader�BaseEnvironment�__init__r)�selfrrrrrr#,s
zEnvironment.__init__N)rrrrrr)�__name__�
__module__�__qualname__�__doc__r#rrrrr&src@sLeZdZdZddd�Zdd
d�Zddd�Zddd�Zddd�Zddd�Z	dS)�DispatchingJinjaLoaderz\A loader that looks for templates in the application and all
    the blueprint folders.
    rrrrcCs
||_dS�N)r)r$rrrrr#8s
zDispatchingJinjaLoader.__init__�environmentr�template�str�)tuple[str, str | None, t.Callable | None]cCs$|jjdr|�||�S|�||�S)N�EXPLAIN_TEMPLATE_LOADING)r�config�_get_source_explained�_get_source_fast)r$r+r,rrr�
get_source;sz!DispatchingJinjaLoader.get_sourcec		Cs�g}d}|�|�D]&\}}z|�||�}|dur|}Wnty&d}Ynw|�|||f�q	ddlm}||j||�|durC|St|��)Nr)�!explain_template_loading_attempts)�
_iter_loadersr3r�append�debughelpersr4r)	r$r+r,�attempts�trv�srcobjr rr4rrrr1Bs"��z,DispatchingJinjaLoader._get_source_explainedc	Cs@|�|�D]\}}z	|�||�WStyYqwt|��r*)r5r3r)r$r+r,�_srcobjr rrrr2Zs�z'DispatchingJinjaLoader._get_source_fast�4t.Generator[tuple[Scaffold, BaseLoader], None, None]ccsJ�|jj}|dur|j|fV|j��D]}|j}|dur"||fVqdSr*)r�jinja_loader�iter_blueprints)r$r,r �	blueprintrrrr5ds�
��z$DispatchingJinjaLoader._iter_loaders�	list[str]cCsbt�}|jj}|dur|�|���|j��D]}|j}|dur,|��D]}|�|�q$qt|�Sr*)�setrr=�update�list_templatesr>�add�list)r$�resultr r?r,rrrrCps�z%DispatchingJinjaLoader.list_templatesN)rrrr)r+rr,r-rr.)r,r-rr<)rr@)
r%r&r'r(r#r3r1r2r5rCrrrrr)3s





r)rrr,r�contextr-cCs@|�|�tj||j||d�|�|�}tj||j||d�|S�N��_async_wrapperr,rG)�update_template_contextr
�send�ensure_sync�renderr)rr,rGrrrr�_renders

�

�rO�template_name_or_list�%str | Template | list[str | Template]rcK� t��}|j�|�}t|||�S)aRender 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_templaterO�rPrGrr,rrr�render_template��
rW�sourcecKrR)z�Render 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
rSrT�from_stringrO�rYrGrr,rrr�render_template_string�sr\�t.Iterator[str]csF����tj��j��d�d���fdd�}|�}tr!t|�}|S)NrIrr]c3s*�����EdHtj��j��d�dSrH)�generaterrLrMr�rrGr,rrr^�s
�

�z_stream.<locals>.generate)rr])rKr
rLrMrr)rr,rGr^rrr_r�_stream�s

�r`cKrR)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
rSrTrUr`rVrrr�stream_template�sracKrR)aZRender 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
rSrTrZr`r[rrr�stream_template_string�rXrb)rr)rrr,rrGrrr-)rPrQrGrrr-)rYr-rGrrr-)rrr,rrGrrr])rPrQrGrrr])rYr-rGrrr])!�
__future__r�typing�t�jinja2rrr"rr�globalsrr	r
r�helpersr�signalsr
r�
TYPE_CHECKINGrr�scaffoldrrr)rOrWr\r`rarbrrrr�<module>s2

L