y UdZddlZddlZddlZddlZddlmZddlm Z ddlm Z ddl m Z ddl mZdd l mZdd lmZdd lmZdd lmZdd lmZddlmZejrFddlZddlmZddlmZddlmZGddejZ Gdde Z!ej"e e!fZ#dZ$ej%e&dfe'd<ej(dZ)GddZ*ededej+dej+dej"ej+effd Z,d!ej-e&ge&fdej-de&ffd"Z.d!ej-e&e&e/ge&fdej-de&ffd#Z0d!ej-e&e&ge&fdej-de&ffd$Z1d!ej-e&e&e&e/ge&fdej-de&ffd%Z2Gd&d'e*Z3Gd(d)e*Z4Gd*d+e*Z5Gd,d-e*Z6Gd.d/e*Z7Gd0d1e*Z8e$d2fd3e j9d4ej:e&d5e;dej<ej%e/e&ej"ej=e&ej%ej=e&dffffd6Z>Gd7d8Z?d9ej@d:ej:e&d;ej:e&dz2Extension API for adding custom tags and behavior.N)Markup)defaults)nodes) Environment)TemplateAssertionError)TemplateSyntaxError)concat)Context) Undefined) import_string) pass_context)Token) TokenStream)Parserc6eZdZdedefdZdedededefdZdS) _TranslationsBasicmessagereturncdSN)selfrs /srv/buildsys-work-dir/castor/build_node/builder-2/WGSG1/unpkd_srcs/cloudlinux-venv-1.0.6/venv/lib/python3.11/site-packages/jinja2/ext.pygettextz_TranslationsBasic.gettext CsingularpluralncdSrr)rrrr s rngettextz_TranslationsBasic.ngettexts DrN)__name__ __module__ __qualname__strrintr"rrrrrsf 3 3     S # # #      rrc >eZdZdededefdZdededededef dZd S) _TranslationsContextcontextrrcdSrr)rr*rs rpgettextz_TranslationsContext.pgettext"rrrrr cdSrr)rr*rrr s r npgettextz_TranslationsContext.npgettext%rrN)r#r$r%r&r,r'r.rrrr)r)!su C # #     S C   QT      rr))_rr"r,r..GETTEXT_FUNCTIONSz\s*\n\s*ceZdZUdZejeed<ddZe Z ej eed<dZ de ddfd Zde ddfd Z dd ed ejed ejedefdZdddejdejdffdZdddejejejejffdZ dd edejedejfdZ dd edejejejdejejejdejejdejejdejedejfdZdS) ExtensionagExtensions can be used to add extra functionality to the Jinja template system at the parser level. Custom extensions are bound to an environment but may not store environment specific data on `self`. The reason for this is that an extension can be bound to another environment (for overlays) by creating a copy and reassigning the `environment` attribute. As extensions are created by the environment they cannot accept any arguments for configuration. One may want to work around that by using a factory function, but that is not possible as extensions are identified by their import name. The correct way to configure the extension is storing the configuration values on the environment. Because this way the environment ends up acting as central configuration storage the attributes may clash which is why extensions have to ensure that the names they choose for configuration are not too generic. ``prefix`` for example is a terrible name, ``fragment_cache_prefix`` on the other hand is a good name as includes the name of the extension (fragment cache). identifierrNc2|jd|j|_dS)N.)r$r#r3)clss r__init_subclass__zExtension.__init_subclass__LsN;;S\;;rtagsd environmentc||_dSr)r:)rr:s r__init__zExtension.__init__Ys&rctjtt|j}|j|j||_|S)z=Create a copy of this extension bound to another environment.) tcastr2object__new__ __class____dict__updater:)rr:rvs rbindzExtension.bind\sE VIv~~dn== > > 4=)))$ rsourcenamefilenamec|S)zThis method is called before the actual lexing and can be used to preprocess the source. The `filename` is optional. The return value must be the preprocessed source. r)rrGrHrIs r preprocesszExtension.preprocesscs  rstreamrrc|S)a It's passed a :class:`~jinja2.lexer.TokenStream` that can be used to filter tokens returned. This method has to return an iterable of :class:`~jinja2.lexer.Token`\s, but it doesn't have to return a :class:`~jinja2.lexer.TokenStream`. r)rrLs r filter_streamzExtension.filter_streamls  rparserrct)aIf any of the :attr:`tags` matched this method is called with the parser as first argument. The token the parser stream is pointing at is the name token that matched. This method has to return one or a list of multiple nodes. )NotImplementedError)rrOs rparsezExtension.parsevs "###rlinenoc:tj|j||S)zReturn an attribute node for the current extension. This is useful to pass constants on extensions to generated template code. :: self.attr('_my_attribute', lineno=lineno) rS)rExtensionAttributer3)rrHrSs rattrzExtension.attr~s'fMMMMrargskwargsdyn_args dyn_kwargscp|g}|g}tj||||||||S)zsCall a method of the extension. This is a shortcut for :meth:`attr` + :class:`jinja2.nodes.Call`. NrU)rCallrW)rrHrXrYrZr[rSs r call_methodzExtension.call_methodsS <D >Fz IId6I * *         r)rNr)NNNNN) r#r$r%__doc__r>ClassVarr&__annotations__r7setr8Setpriorityrr<rFOptionalrKUnionIterablerNrNodeListrRr'rVrWExprKeywordr]r^rrrr2r27s\$ 3<<<<suuD!%*H'K'D''''  OS!"C<=JsO #  7 33 4$H$QVEJ=O1O)P$$$$48 N N N!"C N  ! N N N N0448+/-1"&   j +,  16%-01  *UZ(  Juz*   3        rr2 __contextrXrYrcJ|j|dg|Ri|S)Nr)callresolve)rlrXrYs r_gettext_aliasrps4 9>)++I66 H H H H H HHrfuncc ptdtdtdtjdtffd }|S)Nrl__string variablesrcp||}|jjrt|}||zSr)rneval_ctx autoescaper)rlrsrtrErqs rrz"_make_new_gettext..gettexts; ^^D( + +   ( BI~rrr r&r>Any)rqrs` r_make_new_gettextrzsP7c#\ Nrc tdtdtdtdtdtjdtf fd }|S)Nrl __singular__plural__numrtrc|d|||||}|jjrt |}||zS)Nnum setdefaultrnrvrwr)rlr|r}r~rtrErqs rr"z$_make_new_ngettext..ngettextsU UE*** ^^D*h > >   ( BI~rrr r&r'r>ry)rqr"s` r_make_new_ngettextrsl      U      \  Orc ~tdtdtdtdtjdtf fd }|S)Nrl __string_ctxrsrtrc|d||||}|jjrt |}||zS)Nr*r)rlrrsrtrErqs rr,z$_make_new_pgettext..pgettextsU Y 555 ^^D, 9 9   ( BI~rrx)rqr,s` r_make_new_pgettextrs\  *- 9< KL5       \  Orctdtdtdtdtdtdtjdtffd }|S) Nrlrr|r}r~rtrc|d||d||||||}|jjrt |}||zS)Nr*rr)rlrr|r}r~rtrErqs rr.z&_make_new_npgettext..npgettextso Y 555UE*** ^^D, He L L   ( BI~rr)rqr.s` r_make_new_npgettextrsy    U  \$ rceZdZdZdhZdeddffd Z d%ddd eje ddfd Z d%d eje ddfd Z d&d ej e ge fd ej e e ege fd eje dejej e e ge fdejej e e e ege fddf dZd'dZefdeje ejfdeje dejejee ejeje ejeje dffffdZdddejejejejffdZefde deje de fdZddde dejeje e ffdZde deje d ej e ej!fd!ejej!d"e d#e dej"fd$Z#xZ$S)(InternationalizationExtensionz-This extension adds gettext support to Jinja.transr:rNct|t|jd<||j|j|j|j|j ddS)Nr/F)install_gettext_translationsinstall_null_translationsinstall_gettext_callablesuninstall_gettext_translationsextract_translationsnewstyle_gettext) superr<rpglobalsextend_install _install_null_install_callables _uninstall_extractrr:rBs rr<z&InternationalizationExtension.__init__sm %%%#1 C )-&*&8&*&=+/?!%"      r translations_SupportedTranslationsnewstylect|dd}||j}t|dd}||j}t|dd}t|dd}||||||dS)Nugettext ungettextr,r.)rr,r.)getattrrr"r)rrrrr"r,r.s rrz&InternationalizationExtension._installs , D99 ?"*G<d;;  #,H<T::L+t<<   X8y      rc ^ddl}|}t|dr|j}ndtdtdtfd}t|dr|j}n'dtdtdtd t dtf d }||j|j||| dS) Nrr,csrc|Srr)rrs rr,z=InternationalizationExtension._install_null..pgettext*srr.pr c|dkr|n|S)Nrr)rrrr s rr.z>InternationalizationExtension._install_null..npgettext1sFFqq)r)rr"rr,r.) rNullTranslationshasattrr,r&r.r'rr")rrrrr,r.s rrz+InternationalizationExtension._install_null s//11 < , , #,HH C C C     < - - *$.II *S *S *S *S *S * * * *  (!*      rrr"r,r.c| ||j_|jjr@t|}t|}|t |}|t |}|jj||||dSN)rr"r,r.)r:rrzrrrrrD)rrr"rr,r.s rrz0InternationalizationExtension._install_callables<s  08D  -   , ;'00G)(33H#-h77$/ ::   ''hY (     rcPdD]"}|jj|d#dSr)r:rpop)rrkeys rrz(InternationalizationExtension._uninstallTs:C 4 4C   $ ( (d 3 3 3 3 4 4rrGgettext_functions.ct|tr|j|}t ||Sr) isinstancer&r:rRextract_from_ast)rrGrs rrz&InternationalizationExtension._extractXs= fc " " 4%++F33F(9:::rrOrc lt|jj}d}d}d}i}d}|jjjdkr|r|jd|jdrnX|jd}|j|vr+|d|jd|jt |jjjd kr3t|j| x||j<} n;||jd vr |jd k}tj |jd x||j<} |ot| tjrHtj dd }|||j<tjtj dd| }n| }|jdk}|jjjdk|jdd} d} t!} ||d\} }| r>| | |'tj | dd }| ddk}|jjdrd} t|j|jjjdkrf|jd}|j|vr+|d|jd|jt ||j}|jdk}|jd||d\}} t|j| |nt|j| D]}||vrtj |d ||<| sd}n||d|||jjd}|r,||}| r|| } ||| ||t1| |o| }|||||gS|S)zParse a translatable tag.FN block_endcommacolonrHztranslatable variable z defined twice.)excassign)trimmed notrimmedrload_transstorerTrname:pluralizezunknown variable z for pluralizationzpluralize without variablesext.i18n.trimmed)nextrLrScurrenttypeexpectskip_ifvaluefailrparse_expressionrNamerr]Assignrb _parse_blockrDtestr:policies_trim_whitespace _make_nodebool set_lineno)rrOrSnum_called_num plural_exprplural_expr_assignmentrtrtokenvarr have_plural referencedsingular_namesr plural_namesrHnodes rrRz#InternationalizationExtension.parsecsfm$$+ /3 ;?-/ m#(K77 . $$W---}$$W-- M((00E{i'' KU[KKKL.}$)X55V]###/5/F/F/H/HH %+&U[4L%L%L+2/4z%+v/N/NN %+&"c5:..&"'*Xv">">K-8Iek*-2\ 8W55s..**#&K!&!5Gm#(K77J  [))) UU $(#4#4VT#B#B   <   n - - -"#j):FCC !/!2e!; = % %&6 7 7 K    }$)[88 ,,V44;i//KKMEKMMM 2  ( 4 !&!5 M  - - -#'#4#4VU#C#C L&       l + + + +     ; ;D9$$"'*T6":": $ ?KK  KK5v > > > ?&/0BCG  7,,X66H 7..v66         *{     ! -*D1 1Krstring_ws_recR|d|S)N )substrip)rrrs rrz.InternationalizationExtension._trim_whitespaceszz#v||~~...rallow_pluralizecg}g} |jjjdkrN||jjjddt |jnX|jjjdkr|t |j|jdj}|||d|d|jd n|jjjd krt |j|jjd rn|jjd r|rn^| d | dn1|jj r| dntd|t|fS)z1Parse until the next block tag with a given name.Tdata%%%variable_beginrHz%(z)s variable_end block_beginz name:endtransrz:a translatable section can have only one pluralize sectionz;control structures in translatable sections are not allowedzunclosed translation blockzinternal parser error) rLrrappendrreplacerrrreos RuntimeErrorr )rrOrrbufrHs rrz*InternationalizationExtension._parse_blocks  <}$)V33 6=06>>sDIIJJJV]####&+/???V]###}++F339!!$''' ====))) $$^4444&+}<<V]###=(--o>>]*//0@AA&KKT Q" < 89999"#:;;;5 <86#;;&&rrrrtrvars_referencedrc.|jj}|s0|s.|dd}|r|dd}|Atjdd}tj|tj|ggdd} nTtjdd} tj| tj|tj||ggdd} |rQ|D];\} } |r| dkr| j tj | | z.6sB *U"Ju{3'7'7??r)r:rrrrr]ritemsrYrrkMarkSafeIfAutoescapeModDictOutput) rrrrtrrrrrrr"rrs rrz(InternationalizationExtension._make_nodes#4  3x 3''c22H 3c22  jF33G:g H(=(='>D$OODDz*f55H:X&& F(;(;[I D  'oo// > > U"cUll ""5=e#<#<====  >-d33D yJ.7oo.?.?|TF###rr)NNN)rrrN)%r#r$r%r_r8rr<r>rerrrCallabler&r'rrr0rfrTemplateSequenceIteratorTuplerrhrirRrPatternrrrrjrr __classcell__rBs@rrrsK77 9D  K  D       TX  4 @A 4@P     $  aj&6 $    @&*<@GK   SE3J' *c3_c12 *T"  *QZc C89  :aj#sC)=s)BCD       04444.? ; ;U^+, ;:c? ;  S!'!*S/171:c?C;O3P"PQQR  ; ; ; ;qHqQVEJ=O1O)PqqqqfFL//s/AIcN/PS////#'#'15#' c! "#'#'#'#'J>$>$ 3>$6#uz/* >$ Z + >$  >$>$ >$>$>$>$>$>$>$>$rrc2eZdZdZdhZdddejfdZdS)ExprStmtExtensionzrAdds a `do` tag to Jinja that works like the print statement just that it doesn't print the return value. dorOrrctjt|jj}||_|S)NrU)rExprStmtrrLrS parse_tupler)rrOrs rrRzExprStmtExtension.parseFs9~T&-%8%8%?@@@&&((  rN)r#r$r%r_r8rr rRrrrrr?sK 6DHrrcXeZdZdZddhZdddejejej ffdZ dS) LoopControlExtensionz/Adds break and continue to the template engine.breakcontinuerOrrct|j}|jdkrtj|jStj|jS)NrrU)rrLrrBreakrSContinue)rrOrs rrRzLoopControlExtension.parseQsHV]## ;' ! !;el333 3~U\2222rN) r#r$r%r_r8r>rfrrrrRrrrr r LsV99 Z D3H3en1L)M333333rr c(eZdZdeddffd ZxZS) WithExtensionr:rNct|tjdtddS)NzZThe 'with' extension is deprecated and will be removed in Jinja 3.1. This is built in now. stacklevelrr<warningswarnDeprecationWarningrs rr<zWithExtension.__init__YsI %%%  0        rr#r$r%rr<rrs@rrrXK K D          rrc(eZdZdeddffd ZxZS)AutoEscapeExtensionr:rNct|tjdtddS)Nz`The 'autoescape' extension is deprecated and will be removed in Jinja 3.1. This is built in now.rrrrs rr<zAutoEscapeExtension.__init__dsI %%%  ;        rrrs@rr r crrr cBeZdZdZdhZdddejfdZdede fdZ d S) DebugExtensionaA ``{% debug %}`` tag that dumps the available variables, filters, and tests. .. code-block:: html+jinja
{% debug %}
.. code-block:: text {'context': {'cycler': , ..., 'namespace': }, 'filters': ['abs', 'attr', 'batch', 'capitalize', 'center', 'count', 'd', ..., 'urlencode', 'urlize', 'wordcount', 'wordwrap', 'xmlattr'], 'tests': ['!=', '<', '<=', '==', '>', '>=', 'callable', 'defined', ..., 'odd', 'sameas', 'sequence', 'string', 'undefined', 'upper']} .. versionadded:: 2.11.0 debugrOrrc|jdj}tj}|d|g|}tj|g|S)Nz name:debug_renderrU)rLrrSrContextReferencer^r)rrOrSr*results rrRzDebugExtension.parses[%%l33:(**!!)gYv!FF|VHV4444rr*c|t|jjt|jjd}t j|ddS)N)r*filterstestsrT)depthcompact)get_allsortedr:r*keysr+pprintpformat)rr*r(s rr&zDebugExtension._rendersn((d.6;;==>>D,27799::  ~fAt<<<>> from jinja2 import Environment >>> env = Environment() >>> node = env.parse('{{ (_("foo"), _(), ngettext("foo", "bar", 42)) }}') >>> list(extract_from_ast(node)) [(1, '_', 'foo'), (1, '_', ()), (1, 'ngettext', ('foo', 'bar', None))] >>> list(extract_from_ast(node, babel_style=False)) [(1, '_', ('foo',)), (1, 'ngettext', ('foo', 'bar'))] For every string found this function yields a ``(lineno, function, message)`` tuple, where: * ``lineno`` is the number of the line on which the string was found, * ``function`` is the name of the ``gettext`` function used (if the string was extracted from embedded Python code), and * ``message`` is the string, or a tuple of strings for functions with multiple string arguments. This extraction function operates on the AST and is because of that unable to extract any comments. For comment support you have to use the babel extraction interface or extract comments yourself. Nc3K|]}||V dSrr)rxs r z#extract_from_ast..s"<3.....C!/!/rceZdZdZdejejeeefdejeddfdZ dedej efdZ d edej efd Z dS) _CommentFinderzHelper class to find comments in a token stream. Can only find comments for gettext calls forwards. Once the comment from line 4 is found, a comment for line 1 will not return a usable value. tokens comment_tagsrNc>||_||_d|_d|_dS)Nr)rArBoffset last_lineno)rrArBs rr<z_CommentFinder.__init__s( ( rrDc* t|j|j|D]\\}}}|dvrR |dd\}}n#t$rY1wxYw||jvr|gc||_S]g||_S#||_wxYw)N)comment linecommentr)reversedrArDsplit ValueErrorrBrstrip)rrDr/ token_type token_valueprefixrGs rfind_backwardsz_CommentFinder.find_backwardss !.6 DK&01// 2 2*:{!;;;!*5*;*;D!*D*D%!!! !!222 ' 0 0111!DKK DKK&DK s4+B AB  AB A"B ?B BrSc|jr |j|krgSt|j|jdD].\}\}}}||kr||j|zcS/|t |jSr)rBrE enumeraterArDrPr;)rrSidx token_linenor/s r find_commentsz_CommentFinder.find_commentss  D$4v$=$=I)24;t{}}3M)N)N > > %C%,1f$$**4;+<=====%""3t{#3#3444r) r#r$r%r_r>rrr'r&r<rirPrUrrrr@r@s jc3!78HI SV !S!QVC[!!!! 5C5AF3K555555rr@fileobjkeywordsrBoptionsc#@Ki}|dddD]+}|}|sd|t|<,t|vr d|t<ddt jttfdtdtd tfd }||d d }t|d tj |dtj |dtj |dtj|dtj|dtj|dp tj|dp tj||dtj||dtjtj||dtjt/|dd}||dr d |jd<||drd |_||dd} || } t;||| } n#t@$r|sYdSwxYwtC| |} tE| |D]!\} }}| ||| #| fV"dS) aBabel extraction method for Jinja templates. .. versionchanged:: 2.3 Basic support for translation comments was added. If `comment_tags` is now set to a list of keywords for extraction, the extractor will try to find the best preceding comment that begins with one of the keywords. For best results, make sure to not have more than one gettext call in one line of code and the matching comment in the same line or the line before. .. versionchanged:: 2.5.1 The `newstyle_gettext` flag can be set to `True` to enable newstyle gettext calls. .. versionchanged:: 2.7 A `silent` option can now be provided. If set to `False` template syntax errors are propagated instead of being ignored. :param fileobj: the file-like object the messages should be extracted from :param keywords: a list of keywords (i.e. function names) that should be recognized as translation functions :param comment_tags: a list of translator tags to search for and include in the results. :param options: a dictionary of additional options (optional) :return: an iterator over ``(lineno, funcname, message, comments)`` tuples. (comments will be empty currently) extensions,NFrXrdefaultrcp||t|dvS)N>1onyestrue)getr&lower)rXrr]s rgetboolzbabel_extract..getbool?s.{{3G --33559SSSrsilentTblock_start_stringblock_end_stringvariable_start_stringvariable_end_stringcomment_start_stringcomment_end_stringline_statement_prefixline_comment_prefix trim_blocks lstrip_blockskeep_trailing_newliner) cache_size auto_reloadrrrencodingzutf-8)F)$rcrJrr rr>Mappingr&rrrBLOCK_START_STRINGBLOCK_END_STRINGVARIABLE_START_STRINGVARIABLE_END_STRINGCOMMENT_START_STRINGCOMMENT_END_STRINGLINE_STATEMENT_PREFIXLINE_COMMENT_PREFIX TRIM_BLOCKS LSTRIP_BLOCKSNEWLINE_SEQUENCEKEEP_TRAILING_NEWLINEr:rrreaddecoderRlistlexrKr r@rrU)rVrWrBrXrZextension_namererfr:rGrrAfinderrSrqrs r babel_extractr s2J35J!++lB77==cBB99'--//  48 =0011$J6648 01TT38,T3TTRVTTTTWWh - -F ((*EFF &(ABB +X-KLL )8+GHH *H,IJJ ((*EFF +,,N0N )**Jh.J(<==(*@AA!0(2PQQ jK$ww ""837 /0ww*++,'+ $ \\^^ " "7;;z7#C#C D DF  ((kook&<&r markupsaferr[rrr:r exceptionsrr runtimer r r utilsr r TYPE_CHECKINGtyping_extensionstelexerrrrOrProtocolrr)rfrr0rr&racompilerr2ryrprrzr'rrrrrr rr r#rrrrrerr@BinaryIOrriri18nr loopcontrolswith_rwr$rrrrs888 $$$$$$......++++++ ?O""""""""""R[1W%79M%MN (1738$ K j j j j j j j j ZII uI01IWQUI IIII AJucz2 qz#s(7K    QZc3(<=!*SRUXBV&QZc C8QZS=Q" *c3S)3. /ZS2F$F$F$F$F$IF$F$F$R         3 3 3 3 39 3 3 3     I        )   %=%=%=%=%=Y%=%=%=T*;L/L/ L/z#L/L/ZGCagajoqwqz#7K/LLM MN L/L/L/L/^%5%5%5%5%5%5%5%5PYB ZYBjoYB*S/YBVCJ  YB ZG S!'!*S/171:c?C3G+HHI16RU;V YBYBYBYBz%#  r