Format: application/x-python-code
⬇ Download File (6.9 KB)
   1  o
   2  
   3  D'hq�@s,ddlmZddlZddlmZddlmZddlmZddlm	Z	ddl
   4  mZdd	l
   5  mZdd
   6  l
   7  m
   8  Z
   9  ddl
  10  mZddlmZdd
  11  lmZddlmZejraddlmZddlmZddlmZd1dd�ZGdd�de�ZGdd�de�Zd2d d!�Zd3d%d&�Zd4d(d)�Zd5d+d,�Z d6d-d.�Z!d7d/d0�Z"dS)8�)�annotationsN)�
  12  BaseLoader)�Environment)�Template)�TemplateNotFound�)�_cv_app)�_cv_request)�current_app)�request)�stream_with_context)�before_render_template)�template_rendered)�Flask)�App)�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`,
  13      `session` and `g`.
  14      N�gr�session)r�getr	rrr)ZappctxZreqctx�rv�r�FC:\Users\shubh\Videos\agent\nova\Lib\site-packages\flask/templating.py�_default_template_ctx_processors
  15  
  16  
  17  
  18  
  19  rc@seZdZdZddd	�Zd
  20  S)rz�Works like a regular Jinja2 environment but has some additional
  21      knowledge of how Flask's blueprint works so that it can prepend the
  22      name of the blueprint to referenced templates if necessary.
  23      �appr�options�t.Anyr�NonecKs0d|vr
  24  |��|d<tj|fi|��||_dS)N�loader)Zcreate_global_jinja_loader�BaseEnvironment�__init__r)�selfrrrrrr!-s
  25  zEnvironment.__init__N)rrrrrr)�__name__�
  26  __module__�__qualname__�__doc__r!rrrrr'src@sLeZdZdZddd�Zdd
  27  d�Zddd�Zddd�Zddd�Zddd�Z	dS)�DispatchingJinjaLoaderz\A loader that looks for templates in the application and all
  28      the blueprint folders.
  29      rrrrcCs
  30  ||_dS�N)r)r"rrrrr!9s
  31  zDispatchingJinjaLoader.__init__�environmentr �template�str�3tuple[str, str | None, t.Callable[[], bool] | None]cCs$|jjdr|�||�S|�||�S)NZEXPLAIN_TEMPLATE_LOADING)r�config�_get_source_explained�_get_source_fast)r"r)r*rrr�
  32  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)�
  33  _iter_loadersr0r�appendZdebughelpersr1r)	r"r)r*ZattemptsZtrv�srcobjrrr1rrrr.Cs"��z,DispatchingJinjaLoader._get_source_explainedc	Cs@|�|�D]\}}z	|�||�WStyYqwt|��r()r2r0r)r"r)r*Z_srcobjrrrrr/[s�z'DispatchingJinjaLoader._get_source_fast�'t.Iterator[tuple[Scaffold, BaseLoader]]ccsJ�|jj}|dur|j|fV|j��D]}|j}|dur"||fVqdSr()r�jinja_loader�iter_blueprints)r"r*r�	blueprintrrrr2es�
  34  ��z$DispatchingJinjaLoader._iter_loaders�	list[str]cCsbt�}|jj}|dur|�|���|j��D]}|j}|dur,|��D]}|�|�q$qt|�Sr()�setrr6�update�list_templatesr7�add�list)r"�resultrr8r*rrrr<os�z%DispatchingJinjaLoader.list_templatesN)rrrr)r)r r*r+rr,)r*r+rr5)rr9)
  35  r#r$r%r&r!r0r.r/r2r<rrrrr'4s
  36  
  37  
  38  
  39  
  40  
  41  
  42  r'rrr*r�contextr+cCs@|�|�tj||j||d�|�|�}tj||j||d�|S�N�Z_async_wrapperr*r@)�update_template_contextr
  43  �send�ensure_sync�renderr)rr*r@rrrr�_render~s
  44  
  45  �
  46  
  47  �rG�template_name_or_list�%str | Template | list[str | Template]rcK� t��}|j�|�}t|||�S)aRender a template by name with the given context.
  48  
  49      :param template_name_or_list: The name of the template to render. If
  50          a list is given, the first name to exist will be rendered.
  51      :param context: The variables to make available in the template.
  52      )r
  53  �_get_current_object�	jinja_env�get_or_select_templaterG�rHr@rr*rrr�render_template��
  54  rO�sourcecKrJ)z�Render a template from the given source string with the given
  55      context.
  56  
  57      :param source: The source code of the template to render.
  58      :param context: The variables to make available in the template.
  59      )r
  60  rKrL�from_stringrG�rQr@rr*rrr�render_template_string�srT�t.Iterator[str]csF����tj��j��d�d���fdd�}|�}tr!t|�}|S)NrBrrUc3s*�����EdHtj��j��d�dSrA)�generaterrDrEr�rr@r*rrrV�s
  61  �
  62  
  63  �z_stream.<locals>.generate)rrU)rCr
  64  rDrErr)rr*r@rVrrrWr�_stream�s
  65  
  66  �rXcKrJ)a�Render a template by name with the given context as a stream.
  67      This returns an iterator of strings, which can be used as a
  68      streaming response from a view.
  69  
  70      :param template_name_or_list: The name of the template to render. If
  71          a list is given, the first name to exist will be rendered.
  72      :param context: The variables to make available in the template.
  73  
  74      .. versionadded:: 2.2
  75      )r
  76  rKrLrMrXrNrrr�stream_template�srYcKrJ)aZRender a template from the given source string with the given
  77      context as a stream. This returns an iterator of strings, which can
  78      be used as a streaming response from a view.
  79  
  80      :param source: The source code of the template to render.
  81      :param context: The variables to make available in the template.
  82  
  83      .. versionadded:: 2.2
  84      )r
  85  rKrLrRrXrSrrr�stream_template_string�rPrZ)rr)rrr*rr@rrr+)rHrIr@rrr+)rQr+r@rrr+)rrr*rr@rrrU)rHrIr@rrrU)rQr+r@rrrU)#�
  86  __future__r�typing�tZjinja2rrr rr�globalsrr	r
  87  r�helpersrZsignalsr
  88  r�
  89  TYPE_CHECKINGrrZ
  90  sansio.apprZsansio.scaffoldrrr'rGrOrTrXrYrZrrrr�<module>s4
  91  
  92  J
  93  
  94  
  95  
  96