;ip@ddlmZddlZddlmZddlmZddlmZddlm Z ddl m Z dd l m Z dd l m Z dd l mZdd lmZdd lmZddlmZejrddlmZddlmZddlmZd*dZGddeZGddeZd+dZd,d#Zd-d%Zd.d'Z d/d(Z!d0d)Z"dS)1) annotationsN) BaseLoader) Environment)Template)TemplateNotFound)_cv_app) _cv_request) current_app)request)stream_with_context)before_render_template)template_rendered)Flask)App)Scaffoldreturndict[str, t.Any]ctjd}tjd}i}| |j|d<||j|d<|j|d<|S)zSDefault template context processor. Injects `request`, `session` and `g`. Ngr session)r getr rr r)appctxreqctxrvs DC:\PYTHON\MyICR_Workspace\venv\Lib\site-packages\flask/templating.py_default_template_ctx_processorrsY[  F _T " "FB (3 9 9 IceZdZdZd dZd S) rzWorks 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. approptionst.AnyrNonec nd|vr||d<tj|fi|||_dS)Nloader)create_global_jinja_loaderBaseEnvironment__init__r )selfr r!s rr(zEnvironment.__init__-sG 7 " " # > > @ @GH  11111rN)r rr!r"rr#)__name__ __module__ __qualname____doc__r(rrrr's2 rrcBeZdZdZddZdd Zdd ZddZddZddZ dS)DispatchingJinjaLoaderz\A loader that looks for templates in the application and all the blueprint folders. r rrr#c||_dSN)r )r)r s rr(zDispatchingJinjaLoader.__init__9s r environmentr'templatestr3tuple[str, str | None, t.Callable[[], bool] | None]c~|jjdr|||S|||S)NEXPLAIN_TEMPLATE_LOADING)r config_get_source_explained_get_source_fast)r)r3r4s r get_sourcez!DispatchingJinjaLoader.get_source<sC 8?5 6 E--k8DD D$$[(;;;rc"g}d}||D]K\}} |||}||}n#t$rd}YnwxYw||||fLddlm}||j||||St|)Nr)!explain_template_loading_attempts) _iter_loadersr<rappend debughelpersr>r ) r)r3r4attemptstrvsrcobjr%rr>s rr:z,DispatchingJinjaLoader._get_source_explainedCsLP"00:: 2 2NFF &&{H==;C#     OOVVR0 1 1 1 1CCCCCC))$(HhGGG ?Jx(((s; A  A c||D]-\}} |||cS#t$rY*wxYwt|r2)r?r<r)r)r3r4_srcobjr%s rr;z'DispatchingJinjaLoader._get_source_fast[st $11(;;  OGV ((h?????#    x(((s4 AA't.Iterator[tuple[Scaffold, BaseLoader]]c#K|jj}| |j|fV|jD]}|j}|||fVdSr2)r jinja_loaderiter_blueprints)r)r4r% blueprints rr?z$DispatchingJinjaLoader._iter_loadersesp&  (F" " " "1133 ( (I+F!'''' ( (r list[str]cHt}|jj}|'|||jD]7}|j}|,|D]}||8t|Sr2)setr rIupdatelist_templatesrJaddlist)r)resultr%rKr4s rrPz%DispatchingJinjaLoader.list_templatesos&   MM&//11 2 2 21133 ) )I+F! & 5 5 7 7))HJJx((((F||rN)r rrr#)r3r'r4r5rr6)r4r5rrG)rrL) r*r+r,r-r(r<r:r;r?rPr.rrr0r04s<<<<))))0))))((((      rr0r rr4rcontextr5c||tj||j||||}t j||j|||SN_async_wrapperr4rT)update_template_contextrsend ensure_syncrenderr)r r4rTrs r_renderr]~sz((( COh  ! !B COh Irtemplate_name_or_list%str | Template | list[str | Template]r"c ~tj}|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_envget_or_select_templater]r^rTr r4s rrender_templateres:  ) + +C}334IJJH 3' * **rsourcec ~tj}|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 rarb from_stringr]rfrTr r4s rrender_template_stringrjs9  ) + +C}((00H 3' * **rt.Iterator[str]ctjjdfd }|}trt |}|S)NrWrrkc3|KEd{VtjjdSrV)generaterrZr[)r rTr4srrnz_stream..generates\$$W--------- (G      r)rrk)rYrrZr[r r )r r4rTrnrs``` r_streamros((( COh        B%  $ $ Irc ~tj}|j|}t |||S)aRender 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 rarbrcrords rstream_templaterqs:  ) + +C}334IJJH 3' * **rc ~tj}|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 rarbrhroris rstream_template_stringrss9  ) + +C}((00H 3' * **r)rr)r rr4rrTrrr5)r^r_rTr"rr5)rfr5rTr"rr5)r rr4rrTrrrk)r^r_rTr"rrk)rfr5rTr"rrk)# __future__rtypingtjinja2rrr'rrglobalsr r r r helpersr signalsrr TYPE_CHECKINGr r sansio.apprsansio.scaffoldrrr0r]rerjrorqrsr.rrr~s""""""111111###### ((((((++++++&&&&&&?*))))))         /   GGGGGZGGGT     + + + + + + + +.++++& + + + + + +r