f] LUddlZddlZddlZddlZddlZddlmZddlmZddl m Z ddl m Z ddl m Z ddlmZddlmZddlZej&rddlZej,d ej.d ej0f Zed d ddiZej0ed<eZej>eed<dj@Z!dedefdZ"dedefdZ#dedefdZ$GddejJZ&dedefdZ'dej0de(fdZ)dejTej0ddfdZ+dHdZ,dId e-d!e(dej0fd"Z.dJd#e-d$e-dej^ej`ej0fd%Z1dej0de-fd&Z2dej0de-fd'Z3ejhd(ejjejlzZ7ejhd)Z8 dKd*e-d+ej^e9d,ej^e-d-ej^e-d.ej^ejTe-de-f d/Z: dLd0e9d1e(d2e9d3e9de-f d4Z;dMdej0d5e-d6e(de-fd7ZZA dOdej0d?ej^ej.d e-fd@ej0dejfdAZCGdBdCZDGdDdEZEGdFdGZFy)PN)abc)deque)choice) randrange)Lock)CodeType)quote_from_bytesF.)bound MissingType__repr__cy)Nmissingr xs U/var/lib/jenkins/workspace/mettalog/venv/lib/python3.12/site-packages/jinja2/utils.pyrs r internal_codefreturnc0tj|_|S)aPass the :class:`~jinja2.runtime.Context` as the first argument to the decorated function when called while rendering a template. Can be used on functions, filters, and tests. If only ``Context.eval_context`` is needed, use :func:`pass_eval_context`. If only ``Context.environment`` is needed, use :func:`pass_environment`. .. versionadded:: 3.0.0 Replaces ``contextfunction`` and ``contextfilter``. )_PassArgcontextjinja_pass_argrs r pass_contextrs ''A Hrc0tj|_|S)aPass the :class:`~jinja2.nodes.EvalContext` as the first argument to the decorated function when called while rendering a template. See :ref:`eval-context`. Can be used on functions, filters, and tests. If only ``EvalContext.environment`` is needed, use :func:`pass_environment`. .. versionadded:: 3.0.0 Replaces ``evalcontextfunction`` and ``evalcontextfilter``. )r eval_contextrrs rpass_eval_contextr".s ,,A Hrc0tj|_|S)aPass the :class:`~jinja2.Environment` as the first argument to the decorated function when called while rendering a template. Can be used on functions, filters, and tests. .. versionadded:: 3.0.0 Replaces ``environmentfunction`` and ``environmentfilter``. )r environmentrrs rpass_environmentr%?s ++A HrceZdZejZejZejZede de jdfdZ y)robjrc4t|dr |jSy)Nr)hasattrr)clsr's rfrom_objz_PassArg.from_objQs 3( )%% %rN) __name__ __module__ __qualname__enumautorr!r$ classmethodr tOptionalr+r rrrrLsRdiikG499;L$))+K1J!7rrcDtj|j|S)z%Marks the function as internally used)radd__code__rs r internalcoder7Ysajj! Hrr'c&ddlm}t||S)aCheck if the object passed is undefined. This does nothing more than performing an instance check against :class:`Undefined` but looks nicer. This can be used for custom filters or tests that want to react to undefined variables. For example a custom default filter can look like this:: def default(var, default=''): if is_undefined(var): return default return var ) Undefined)runtimer: isinstance)r'r:s r is_undefinedr=_s# c9 %%riterablec|D]}y)z4Consumes an iterable without doing anything with it.Nr )r>_s rconsumerAps  rc\ddlm}ddlm}|j |j y)a Jinja keeps internal caches for environments and lexers. These are used so that Jinja doesn't have to recreate environments and lexers all the time. Normally you don't have to care about that but if you are measuring memory consumption you may want to clean the caches. r9)get_spontaneous_environment) _lexer_cacheN)r$rClexerrD cache_clearclear)rCrDs r clear_cachesrHvs" 9#++-r import_namesilentc d|vr|jdd\}}n%d|vr|jd\}}}n t|Stt|dd|g|S#tt f$r|sYywxYw)aImports an object based on a string. This is useful if you want to use import paths as endpoints or something similar. An import path can be specified either in dotted notation (``xml.sax.saxutils.escape``) or with a colon as object delimiter (``xml.sax.saxutils:escape``). If the `silent` is True the return value will be `None` if the import fails. :return: imported object :r9.N)split rpartition __import__getattr ImportErrorAttributeError)rIrJmoduler'r@s r import_stringrUs  + %++C3KFC K (33C8NFAsk* *z&$seAAA/.A/filenamemodecZtjj|syt||S)z\Returns a file descriptor for the filename if that file exists, otherwise ``None``. N)ospathisfileopen)rVrWs ropen_if_existsr]s$ 77>>( # $ rc|y|turyt|}|jdk(r|jdS|jd|jdS)zReturns the name of the object's type. For some recognized singletons the name of the object is returned instead. (For example for `None` and `Ellipsis`). NoneEllipsisbuiltinsz objectrM)r`typer-r,)r'r*s robject_type_reprrcsX  {  s)C ~~#,,w''nn Qs||nG 44rcddlm}||S)z.Format an object using :func:`pprint.pformat`.r)pformat)pprintre)r'res rreres 3<ra@ ^ ( (https?://|www\.) # scheme or www (([\w%-]+\.)+)? # subdomain ( [a-z]{2,63} # basic tld | xn--[\w%]{2,59} # idna tld ) | ([\w%-]{2,63}\.)+ # basic domain (com|net|int|edu|gov|org|info|mil) # basic tld | (https?://) # scheme ( (([\d]{1,3})(\.[\d]{1,3}){3}) # IPv4 | (\[([\da-f]{0,4}:){2}([\da-f]{0,4}:?){1,6}]) # IPv6 ) ) (?::[\d]{1,5})? # port (?:[/?#]\S*)? # path, query, and fragment $ z^\S+@\w[\w.-]*\.\w+$texttrim_url_limitreltarget extra_schemesc dtdtffd }ndtdtfd}tjdttj|}|rdtj|dnd }|rd tj|dnd }t |D]\} } d | d } } } tj d | }|r#|j} | |jd} | jd r;tjd | }|r#|j} | d|j} dD]~\}}| j|}|| j|kr,tt|| j|D],}| j|t!|z}| | d|z } | |d} .t"j | rL| j%ds| j%drd| d||d|| d} nd| d||d|| d} n| j%dr%t&j | ddr d| d| ddd} ngd| vr4| j%ds#d| vrt&j | r d| d| d} n/|-|D](}| |k7s | j%|sd| d||d| d} *| | | || <"d j)|S)a;Convert URLs in text into clickable links. This may not recognize links in some situations. Usually, a more comprehensive formatter, such as a Markdown library, is a better choice. Works on ``http://``, ``https://``, ``www.``, ``mailto:``, and email addresses. Links with trailing punctuation (periods, commas, closing parentheses) and leading punctuation (opening parentheses) are recognized excluding the punctuation. Email addresses that include header fields are not recognized (for example, ``mailto:address@example.com?cc=copy@example.com``). :param text: Original text containing URLs to link. :param trim_url_limit: Shorten displayed URL values to this length. :param target: Add the ``target`` attribute to links. :param rel: Add the ``rel`` attribute to links. :param extra_schemes: Recognize URLs that start with these schemes in addition to the default behavior. .. versionchanged:: 3.0 The ``extra_schemes`` parameter was added. .. versionchanged:: 3.0 Generate ``https://`` links for URLs without a scheme. .. versionchanged:: 3.0 The parsing rules were updated. Recognize email addresses with or without the ``mailto:`` scheme. Validate IP addresses. Ignore parentheses and brackets in more cases. Nrrc4t|kDr|ddS|S)Nz...)len)rrhs rtrim_urlzurlize..trim_urls)1v&O^,-S11Hrc|SNr rs rrozurlize..trim_url sHrz(\s+)z rel=""rz target="z ^([(<]|<)+))>rM, >z([)>.,\n]|>)+$))(rs)@zwww.rLzII2F;E{{}%++-0%M J ,,z2Kfll8443{DJJx,@AB JJx03x=@ $z **IJ' C%M >>& !  ,0A0A)0Lxq ;-q&AQ@RRVW (xq ;-q'(.   y )ioofQRj.I 6!":,d;F 6M%%f-6!''xr&>F  &'V#(9(9&(A((K=&QUVF(VF8D6*a{$~ 775>rnhtmlrmaxc ddlm}|j}g}t|D]}d}dx} } d} d} g} t tt ||D]z\}} t |} | | k7r| } n|r| j} d}|t ddz | kDr |} | d z } | d z } |t d d z | kDr |x} } | d z } d}| j| |dj| }|jd r |ddd z}n|jd s|d z }|j||sdj|Stjdjd|DS)z+Generate some lorem ipsum for the template.r9)LOREM_IPSUM_WORDSTrNFru rM z rvc3NK|]}dtj|dyw)z

z

N)r~r.0rs r z'generate_lorem_ipsum..s%CqC ))!,-T2Cs#%) constantsrrNrrrr capitalizeappendrrr~Markup)rrrrrrresultr@next_capitalized last_comma last_fullstoprlastpidxp_strs rgenerate_lorem_ipsumrVs-  # # %E F 1X%&& ]  iS&9 :;FCe}4<D   (#( Yq!_$z1 "  Yr2&&6-00 ] #' HHTN'<,  >># #2J$E$ SLE eKN {{6""    CFCC rcharsetfor_qsct|ts,t|ts t|}|j|}|rdnd}t ||}|r|j dd}|S)a5Quote a string for use in a URL using the given charset. :param obj: String or bytes to quote. Other types are converted to string then encoded to bytes using the given charset. :param charset: Encode text to bytes using this charset. :param for_qs: Quote "/" and use "+" for spaces. r/z%20+)r<bytesr|encoder replace)r'rrsafervs r url_quoters\ c5 !#s#c(Cjj!3dD #t $B ZZs # IrceZdZdZdeddfdZddZdeje ejffdZ deje ejfddfd Z dejejd ffd Zdd Zd d ejdejdejfdZd d ejdejdejfdZddZd ejdefdZdefdZde fdZd ejdejfdZd ejdejddfdZd ejddfdZdej4ejejejffdZdej4ejfdZdej4ejfdZdej<ejfdZdej<ejfdZ eZ!y)!LRUCachez"A simple LRU Cache implementation.capacityrNc^||_i|_t|_|j yrq)r_mappingr_queue _postinit)selfrs r__init__zLRUCache.__init__s#  .0 ).  rc|jj|_|jj|_|jj |_t|_|jj|_ yrq) rpopleft_popleftpop_popremove_remover_wlockr_appendrs rrzLRUCache._postinitsM ++ KKOO {{)) f {{)) rcJ|j|j|jdS)Nrrrrrs r __getstate__zLRUCache.__getstate__s!  kk  rdcZ|jj||jyrq)__dict__updater)rrs r __setstate__zLRUCache.__setstate__s Q r.c|jfSrq)rrs r__getnewargs__zLRUCache.__getnewargs__s rc|j|j}|jj|j|jj |j|S)z&Return a shallow copy of the instance.) __class__rrrrextendrrs rcopyz LRUCache.copysE ^^DMM * 4==) % rkeydefaultc0 ||S#t$r|cYSwxYw)z/Return an item from the cache dict or `default`KeyErrorrrrs rgetz LRUCache.gets% 9  N s  c: ||S#t$r |||<|cYSwxYw)zvSet `default` if the key is not in the cache otherwise leave unchanged. Return the value of this key. rrs r setdefaultzLRUCache.setdefaults. 9  DIN s c|j5|jj|jjdddy#1swYyxYw)zClear the cache.N)rrrGrrs rrGzLRUCache.clears> [[ MM   ! KK      s 5A  Ac||jvS)z$Check if a key exists in this cache.)rrrs r __contains__zLRUCache.__contains__sdmm##rc,t|jS)z%Return the current size of the cache.)rnrrs r__len__zLRUCache.__len__s4==!!rcNdt|jd|jdS)Nryrrt)rbr,rrs rrzLRUCache.__repr__s'4:&&'q(9;;rc|j5|j|}|jd|k7r# |j||j ||cdddS#t$rY'wxYw#1swYyxYw)zGet an item from the cache. Moves the item up so that it has the highest priority then. Raise a `KeyError` if it does not exist. rN)rrrr ValueErrorr)rrrs r __getitem__zLRUCache.__getitem__s{ [[ s#B{{2#%LL% S!   "    s."A,AA, A)&A,(A))A,,A5valuec@|j5||jvr|j|n=t|j|jk(r|j|j =|j |||j|<dddy#1swYyxYw)zhSets the value for an item. Moves the item up so that it has the highest priority then. N)rrrrnrrr)rrrs r __setitem__zLRUCache.__setitem__sy[[ 'dmm# S!T]]#t}}4MM$--/2 LL !&DMM#  ' ' 's A>BBc|j5|j|= |j|dddy#t$rYwxYw#1swYyxYw)z]Remove an item from the cache dict. Raise a `KeyError` if it does not exist. N)rrrrrs r __delitem__zLRUCache.__delitem__sV[[  c"  S!         s%A6 AAAAAct|jDcgc]}||j|f}}|j|Scc}w)zReturn a list of items.)listrrreverse)rrrs ritemszLRUCache.items sA7;DKK7HI3 c*+II JsAcN|jDcgc]}|d c}Scc}w)zReturn a list of all values.r9)r)rrs rvalueszLRUCache.values&s "jjl+!+++s "ct|S)z7Return a list of all keys ordered by most recent usage.)rrs rkeysz LRUCache.keys*s Dzrc>tt|jSrq)reversedtuplerrs r__iter__zLRUCache.__iter__.sdkk*++rc>tt|jS)zTIterate over the keys in the cache dict, oldest items coming first. )iterr rrs r __reversed__zLRUCache.__reversed__1sE$++&''rrN)rrrq)"r,r-r.__doc__intrrr2Mappingr|AnyrrTuplerrrrrGboolrrrrrrIterablerrrIteratorr r __copy__r rrrrs,  * aiiQUU 3 aiiQUU 3 s 3 quuquuaeeaeequu $$$$""<#<quu, 'quu 'QUU 't ' quu  qzz!''!%%,"78 , 155),ajj',!**QUU+,(ajj/( Hrrenabled_extensionsdisabled_extensionsdefault_for_stringrctd|Dtd|Ddtjtdtffd }|S)acIntelligently sets the initial value of autoescaping based on the filename of the template. This is the recommended way to configure autoescaping if you do not want to write a custom function yourself. If you want to enable it for all templates created from strings or for all templates with `.html` and `.xml` extensions:: from jinja2 import Environment, select_autoescape env = Environment(autoescape=select_autoescape( enabled_extensions=('html', 'xml'), default_for_string=True, )) Example configuration to turn it on at all times except if the template ends with `.txt`:: from jinja2 import Environment, select_autoescape env = Environment(autoescape=select_autoescape( disabled_extensions=('txt',), default_for_string=True, default=True, )) The `enabled_extensions` is an iterable of all the extensions that autoescaping should be enabled for. Likewise `disabled_extensions` is a list of all templates it should be disabled for. If a template is loaded from a string then the default from `default_for_string` is used. If nothing matches then the initial value of autoescaping is set to the value of `default`. For security reasons this function operates case insensitive. .. versionadded:: 2.9 c3`K|]&}d|jdj(ywrMNlstriplowerrs rrz$select_autoescape..bs)UQq#!4!4!6 78U,.c3`K|]&}d|jdj(ywrrrs rrz$select_autoescape..cs)Wa!((3-"5"5"7!89Wr! template_namercx|S|j}|jry|jryS)NTF)r r)r#rrdisabled_patternsenabled_patternss r autoescapez%select_autoescape..autoescapeesF  % %%++-  ! !"2 3  ! !"3 4r)r r2r3r|r)rrrrr'r%r&s `` @@rselect_autoescaper(:sRPUBTUUWCVWW!**S/d rdumpskwargsc |tj}tj||fi|j ddj ddj ddj ddS) aSerialize an object to a string of JSON with :func:`json.dumps`, then replace HTML-unsafe characters with Unicode escapes and mark the result safe with :class:`~markupsafe.Markup`. This is available in templates as the ``|tojson`` filter. The following characters are escaped: ``<``, ``>``, ``&``, ``'``. The returned string is safe to render in HTML documents and ``