1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
U
ß=®dOã@sXddlmZddlZddlmZddlmZddlmZddlm    Z    ddl
m Z dd    l
m Z dd
l
m Z dd l
mZdd lmZdd lmZddlmZejr¶ddlmZddlmZddœdd„ZGdd„deƒZGdd„deƒZdddddœdd„Zdd dd!œd"d#„Zdd dd$œd%d&„Zdddd'dœd(d)„Zdd d'd!œd*d+„Zdd d'd$œd,d-„Z dS).é)Ú annotationsN)Ú
BaseLoader)Ú Environment)ÚTemplate)ÚTemplateNotFoundé)Ú_cv_app)Ú _cv_request)Ú current_app)Úrequest)Ústream_with_context)Úbefore_render_template)Útemplate_rendered)ÚFlask)ÚScaffoldzdict[str, t.Any]©ÚreturncCsJt d¡}t d¡}i}|dk    r*|j|d<|dk    rF|j|d<|j|d<|S)zSDefault template context processor.  Injects `request`,
    `session` and `g`.
    NÚgr Úsession)rÚgetr    rr r)ZappctxZreqctxÚrv©rúGd:\z\workplace\vscode\pyvenv\venv\Lib\site-packages\flask/templating.pyÚ_default_template_ctx_processors
 
 
 
 
rc@s"eZdZdZddddœdd„ZdS)    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.
    rút.AnyÚNone)ÚappÚoptionsrcKs,d|kr| ¡|d<tj|f|Ž||_dS)NÚloader)Zcreate_global_jinja_loaderÚBaseEnvironmentÚ__init__r)Úselfrrrrrr ,s zEnvironment.__init__N)Ú__name__Ú
__module__Ú __qualname__Ú__doc__r rrrrr&src@steZdZdZdddœdd„Zddd    d
œd d „Zddd    d
œd d„Zddd    d
œdd„Zdddœdd„Zddœdd„Z    dS)ÚDispatchingJinjaLoaderz\A loader that looks for templates in the application and all
    the blueprint folders.
    rr)rrcCs
||_dS©N)r)r!rrrrr 8szDispatchingJinjaLoader.__init__rÚstrz)tuple[str, str | None, t.Callable | None])Ú environmentÚtemplatercCs$|jjdr| ||¡S| ||¡S)NZEXPLAIN_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]N\}}z| ||¡}|dkr4|}Wntk
rNd}YnX| |||f¡qddlm}||j||ƒ|dk    rˆ|St|ƒ‚dS)Nr)Ú!explain_template_loading_attempts)Ú _iter_loadersr.rÚappendZ debughelpersr/r)    r!r)r*ÚattemptsZtrvÚsrcobjrrr/rrrr,Bs 
 z,DispatchingJinjaLoader._get_source_explainedc    CsL| |¡D]4\}}z| ||¡WStk
r<Yq
Yq
Xq
t|ƒ‚dSr')r0r.r)r!r)r*Z_srcobjrrrrr-Zs  z'DispatchingJinjaLoader._get_source_fastz4t.Generator[tuple[Scaffold, BaseLoader], None, None])r*rccsH|jj}|dk    r|j|fV|j ¡D]}|j}|dk    r&||fVq&dSr')rÚ jinja_loaderÚiter_blueprints)r!r*rÚ    blueprintrrrr0ds z$DispatchingJinjaLoader._iter_loadersz    list[str]rcCsbtƒ}|jj}|dk    r$| | ¡¡|j ¡D]*}|j}|dk    r.| ¡D]}| |¡qHq.t|ƒSr')Úsetrr4ÚupdateÚlist_templatesr5ÚaddÚlist)r!Úresultrr6r*rrrr9ps z%DispatchingJinjaLoader.list_templatesN)
r"r#r$r%r r.r,r-r0r9rrrrr&3s
 r&rrr()rr*ÚcontextrcCs@| |¡tj||j||d| |¡}tj||j||d|S©N©Z_async_wrapperr*r=)Úupdate_template_contextr ÚsendÚ ensure_syncÚrenderr)rr*r=rrrrÚ_renders
ÿ
ÿrDz%str | Template | list[str | Template]r)Útemplate_name_or_listr=rcKs 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_templaterD©rEr=rr*rrrÚrender_template‹s
 rJ)Úsourcer=rcKs t ¡}|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
rFrGÚ from_stringrD©rKr=rr*rrrÚrender_template_stringšs rNút.Iterator[str]csJˆ ˆ¡tjˆˆjˆˆdddœ‡‡‡fdd„ }|ƒ}trFt|ƒ}|S)Nr?rOrc3s(ˆ ˆ¡EdHtjˆˆjˆˆddSr>)ÚgeneraterrArBr©rr=r*rrrP®sÿz_stream.<locals>.generate)r@r rArBr r )rr*r=rPrrrQrÚ_stream¦s
ÿrRcKs t ¡}|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
rFrGrHrRrIrrrÚstream_template½s rScKs t ¡}|j |¡}t|||ƒS)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
rFrGrLrRrMrrrÚstream_template_stringÐs
 rT)!Ú
__future__rÚtypingÚtZjinja2rrrrrÚglobalsrr    r
r Zhelpersr Zsignalsr rÚ TYPE_CHECKINGrrZscaffoldrrr&rDrJrNrRrSrTrrrrÚ<module>s0               L