Ë
    ¹Å:jþ  ã                  ód  — 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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"y)$é    )ÚannotationsN)Ú
BaseLoader)ÚEnvironment)ÚTemplate)ÚTemplateNotFoundé   )Ú_cv_app)Ú_cv_request)Úcurrent_app)Úrequest)Ústream_with_context)Úbefore_render_template)Útemplate_rendered)ÚFlask)ÚApp)ÚScaffoldc                 ó¢   — t        j                  d«      } t        j                  d«      }i }| �| j                  |d<   |�|j                  |d<   |S )z‡Default template context processor.  Replaces the ``request`` and ``g``
    proxies with their concrete objects for faster access.
    NÚgr   )r	   Úgetr
   r   r   )ÚappctxÚreqctxÚrvs      úe/home/mcse/projects/srt_converter/srt-converter-venv/lib/python3.12/site-packages/flask/templating.pyÚ_default_template_ctx_processorr      sR   € ô �[‰[˜Ó€FÜ�_‰_˜TÓ"€FØ€BØÐØ—(‘(ˆˆ3‰ØÐØŸ™ˆˆ9‰ð €Ió    c                  ó   — e Zd ZdZdd„Zy)r   zËWorks like a regular Jinja 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                ól   — d|vr|j                  «       |d<   t        j                  | fi |¤Ž || _        y )NÚloader)Úcreate_global_jinja_loaderÚBaseEnvironmentÚ__init__Úapp)Úselfr"   Úoptionss      r   r!   zEnvironment.__init__.   s7   € Ø˜7Ñ"Ø #× >Ñ >Ó @ˆG�HÑÜ× Ñ  Ñ1¨Ò1Øˆ�r   N)r"   r   r$   út.AnyÚreturnÚNone)Ú__name__Ú
__module__Ú__qualname__Ú__doc__r!   © r   r   r   r   (   s   „ ñô
r   r   c                  ód   — e Zd ZdZd	d„Z	 	 	 	 	 	 d
d„Z	 	 	 	 	 	 d
d„Z	 	 	 	 	 	 d
d„Zdd„Zdd„Z	y)ÚDispatchingJinjaLoaderz\A loader that looks for templates in the application and all
    the blueprint folders.
    c                ó   — || _         y ©N)r"   )r#   r"   s     r   r!   zDispatchingJinjaLoader.__init__:   s	   € Øˆ�r   c                ó|   — | j                   j                  d   r| j                  ||«      S | j                  ||«      S )NÚEXPLAIN_TEMPLATE_LOADING)r"   ÚconfigÚ_get_source_explainedÚ_get_source_fast)r#   ÚenvironmentÚtemplates      r   Ú
get_sourcez!DispatchingJinjaLoader.get_source=   s;   € ð �8‰8�?‰?Ð5Ò6Ø×-Ñ-¨k¸8Ó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_loadersr8   r   ÚappendÚdebughelpersr:   r"   )	r#   r6   r7   ÚattemptsÚtrvÚsrcobjr   r   r:   s	            r   r4   z,DispatchingJinjaLoader._get_source_explainedD   s£   € ð ˆàLPˆà"×0Ñ0°Ó:ò 	2‰NˆF�FðØ×&Ñ& {°HÓ=�Ø�;Ø�Cð �O‰O˜V V¨RÐ0Õ1ð	2õ 	Dá)¨$¯(©(°H¸hÔGàˆ?ØˆJÜ˜xÓ(Ð(øô $ò Ø’ðús   �A2Á2B Á?B c                ó�   — | j                  |«      D ]  \  }}	 |j                  ||«      c S  t        |«      ‚# t        $ r Y Œ2w xY wr0   )r;   r8   r   )r#   r6   r7   Ú_srcobjr   s        r   r5   z'DispatchingJinjaLoader._get_source_fast\   s[   € ð  $×1Ñ1°(Ó;ò 	‰OˆG�VðØ×(Ñ(¨°hÓ?Ò?ð	ô
 ˜xÓ(Ð(øô $ò Ùðús   ™9¹	AÁAc              #  óÄ   K  — | j                   j                  }|�| j                   |f–— | j                   j                  «       D ]  }|j                  }|€Œ||f–— Œ y ­wr0   )r"   Újinja_loaderÚiter_blueprints)r#   r7   r   Ú	blueprints       r   r;   z$DispatchingJinjaLoader._iter_loadersf   sb   è ø€ Ø—‘×&Ñ&ˆØÐØ—(‘(˜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 r0   )Úsetr"   rD   ÚupdateÚlist_templatesrE   ÚaddÚlist)r#   Úresultr   rF   r7   s        r   rJ   z%DispatchingJinjaLoader.list_templatesp   s�   € Ü“ˆØ—‘×&Ñ&ˆØÐØ�M‰M˜&×/Ñ/Ó1Ô2àŸ™×1Ñ1Ó3ò 	)ˆIØ×+Ñ+ˆFØÑ!Ø &× 5Ñ 5Ó 7ò )�HØ—J‘J˜xÕ(ñ)ð	)ô �F‹|Ðr   N)r"   r   r&   r'   )r6   r    r7   Ústrr&   z3tuple[str, str | None, t.Callable[[], bool] | None])r7   rN   r&   z't.Iterator[tuple[Scaffold, BaseLoader]])r&   z	list[str])
r(   r)   r*   r+   r!   r8   r4   r5   r;   rJ   r,   r   r   r.   r.   5   sm   „ ñóð<Ø*ð<Ø69ð<à	<ó<ð)Ø*ð)Ø69ð)à	<ó)ð0)Ø*ð)Ø69ð)à	<ó)ó(ôr   r.   c                óÖ   — | j                  |«       t        j                  | | j                  ||¬«       |j	                  |«      }t        j                  | | j                  ||¬«       |S ©N©Ú_async_wrapperr7   Úcontext)Úupdate_template_contextr   ÚsendÚensure_syncÚrenderr   )r"   r7   rS   r   s       r   Ú_renderrX      s]   € Ø×Ñ Ô(Ü×ÑØ˜CŸO™O°hÈõð 
�‰˜Ó	!€BÜ×ÑØ˜CŸO™O°hÈõð €Ir   c                óz   — t        j                  «       }|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_templaterX   ©Útemplate_name_or_listrS   r"   r7   s       r   Úrender_templater_   ‹   s6   € ô ×
)Ñ
)Ó
+€CØ�}‰}×3Ñ3Ð4IÓJ€HÜ�3˜ 'Ó*Ð*r   c                óz   — t        j                  «       }|j                  j                  | «      }t	        |||«      S )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   rZ   r[   Úfrom_stringrX   ©ÚsourcerS   r"   r7   s       r   Úrender_template_stringrd   š   s5   € ô ×
)Ñ
)Ó
+€CØ�}‰}×(Ñ(¨Ó0€HÜ�3˜ 'Ó*Ð*r   c                ó´   ‡ ‡‡— ‰ j                  ‰«       t        j                  ‰ ‰ j                  ‰‰¬«       dˆ ˆˆfd„} |«       }t        rt        |«      }|S )NrQ   c               3  óŠ   •K  — ‰j                  ‰«      E d {  –—†  t        j                  ‰ ‰ j                  ‰‰¬«       y 7 Œ(­wrP   )Úgenerater   rU   rV   )r"   rS   r7   s   €€€r   rg   z_stream.<locals>.generate®   s;   øè ø€ Ø×$Ñ$ WÓ-×-Ð-Ü×ÑØ §¡¸(ÈGö	
ð 	.ús   ƒA˜A™)A)r&   út.Iterator[str])rT   r   rU   rV   r   r   )r"   r7   rS   rg   r   s   ```  r   Ú_streamri   ¦   sP   ú€ ð ×Ñ Ô(Ü×ÑØ˜CŸO™O°hÈõ÷
ñ 
‹€Bõ Ü  Ó$ˆà€Ir   c                óz   — t        j                  «       }|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   rZ   r[   r\   ri   r]   s       r   Ústream_templaterk   ½   s6   € ô ×
)Ñ
)Ó
+€CØ�}‰}×3Ñ3Ð4IÓJ€HÜ�3˜ 'Ó*Ð*r   c                óz   — t        j                  «       }|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   rZ   r[   ra   ri   rb   s       r   Ústream_template_stringrm   Ð   s5   € ô ×
)Ñ
)Ó
+€CØ�}‰}×(Ñ(¨Ó0€HÜ�3˜ 'Ó*Ð*r   )r&   údict[str, t.Any])r"   r   r7   r   rS   rn   r&   rN   )r^   ú%str | Template | list[str | Template]rS   r%   r&   rN   )rc   rN   rS   r%   r&   rN   )r"   r   r7   r   rS   rn   r&   rh   )r^   ro   rS   r%   r&   rh   )rc   rN   rS   r%   r&   rh   )#Ú
__future__r   ÚtypingÚtÚjinja2r   r   r    r   r   Úglobalsr	   r
   r   r   Úhelpersr   Úsignalsr   r   ÚTYPE_CHECKINGr"   r   Ú
sansio.appr   Úsansio.scaffoldr   r   r.   rX   r_   rd   ri   rk   rm   r,   r   r   ú<module>rz      sÎ   ðÝ "ã å Ý 1Ý Ý #å Ý  Ý  Ý Ý (Ý +Ý &à‡?‚?ÝÝÝ)óô 
�/ô 
ôG˜Zô GóT	ð+Ø@ð+àð+ð 	ó+ó	+ðØ	ðØ"ðØ-=ðàóð.+Ø@ð+àð+ð ó+ô&+r   