lfW ddlZddlZddlZddlZddlmZddlmZddlmZddl m Z ddl m Z ddl m Z dd lmZdd lmZdd lmZdd lmZejd Zejddeej dddeej ddZejdZejdZejdZdZdZeddddiZeZ djZ!dej"dvZ#d Z$d!Z%d"Z&d#Z'd$Z(d%Z)d&Z*dBd(Z+dCd*Z,d+Z-dBd,Z.dDd-Z/dEd2Z0dFd4Z1Gd5d6e2Z3ej45e3 dGd8Z6dHd9Z7Gd:d;e2Z8Gd<d=e2Z9Gd>d?e2Z: e;d@d/ZdS)IN)deque)choice) randrange)Lockescape)Markup)abc) string_types) text_type) url_quotez(\s+)z ^(?P(?:|)(.*?)(?P(?:).,)> z>z)*)$z&^\S+@[a-zA-Z0-9._-]+\.[a-zA-Z0-9._-]+$z(|<[^>]*>)z &([^;]+);4abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ 0123456789 MissingType__repr__cdS)Nmissingr)xs l/builddir/build/BUILD/imunify360-venv-2.3.5/opt/imunify360/venv/lib/python3.11/site-packages/jinja2/utils.pyr "sz\//cd|_|S)a+This decorator can be used to mark a function or method context callable. A context callable is passed the active :class:`Context` as first argument when called from the template. This is useful if a function wants to get access to the context or functions provided on the context object. For example a function that returns a sorted list of template variables the current template exports could look like this:: @contextfunction def get_exported_names(context): return sorted(context.exported_vars) T)contextfunctionfs rr%r%,sA Hr!cd|_|S)aGThis decorator can be used to mark a function or method as an eval context callable. This is similar to the :func:`contextfunction` but instead of passing the context, an evaluation context object is passed. For more information about the eval context, see :ref:`eval-context`. .. versionadded:: 2.4 T)evalcontextfunctionr&s rr)r)<s!A Hr!cd|_|S)zThis decorator can be used to mark a function or method as environment callable. This decorator works exactly like the :func:`contextfunction` decorator just that the first argument is the active :class:`Environment` and not context. T)environmentfunctionr&s rr+r+Is !A Hr!cDt|j|S)z%Marks the function as internally used) internal_codeadd__code__r&s r internalcoder0Ssaj!!! Hr!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 r ) Undefined)runtimer2 isinstance)objr2s r is_undefinedr6Ys&#""""" c9 % %%r!c|D]}dS)z4Consumes an iterable without doing anything with it.Nr)iterable_s rconsumer:js      r!cnddlm}ddlm}||dS)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. r )_spontaneous_environments) _lexer_cacheN) environmentr<lexerr=clear)r<r=s r clear_cachesrApsR 766666########%%%r!Fc d|vr|dd\}}n-d|vr|d\}}}nt|Stt|dd|g|S#tt f$r|sYdSwxYw)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 :r rN)split rpartition __import__getattr ImportErrorAttributeError) import_namesilentmoduler5r9s r import_stringrM}s  +  %++C33KFCC K  (33C88NFAssk** *z&$se<>( # #t $  r!c|dS|turdSt|}|jdvr|j}n|jdz|jz}d|zS)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`). NNoneEllipsis) __builtin__builtinsrz %s object)rYtype __module____name__)r5clsnames robject_type_reprras^  {v z s))C ~444|~#cl2  r!cl ddlm}|||S#t$rddlm}||cYSwxYw)zYPrettyprint an object. Either use the `pretty` library or the builtin `pprint`. r)pretty)verbose)pformat)rcrHpprintre)r5rdrcres rrereso!!!!!!vc7++++ """"""ws||s 33c ^|fd}ttt|}|rdtt|zpd}|rdt|zpd}t |D]\}} t | } | rs| \} } } | dsd| vr| ds| dst| d krm| d ttzvrV| d s*| d s| d rd | d||d|| d} | ds| drd| d||d|| d} d| vr<| ds'd| vr#t| r d| d| d} | | z| z| kr | | z| z||<d|S)a Converts any URLs in text into clickable links. Works on http://, https:// and www. links. Links can have trailing punctuation (periods, commas, close-parens) and leading punctuation (opening parens) and it'll still do the right thing. If trim_url_limit is not None, the URLs in link text will be limited to trim_url_limit characters. If nofollow is True, the URLs in link text will get a rel="nofollow" attribute. If target is not None, a target attribute will be added to the link. cR|dur"|d|t||krdpdzp|S)Nz...r")len)rlimits rr zurlize..s?T(9)< vvY#a&&E/3e9r :) r!z rel="%s"r"z target="%s"zwww.@zhttp://zhttps://rz.orgz.netz.comzz )_word_split_rerDr r enumerate_punctuation_rematchgroups startswithri_letters_digitsendswith_simple_email_rejoin)texttrim_url_limitreltargettrim_urlwordsrel_attr target_attriwordrpleadmiddletrails rurlizers'     6$<%s

Nr.0rs r z'generate_lorem_ipsum..0s-FF!\F1II5FFFFFFr!) constantsrrDrangernrr capitalizeappendrwrur )nhtmlminmaxrr}resultr9next_capitalized last_comma last_fullstoprlastpidxs rgenerate_lorem_ipsumrs,,,,,,  # # % %E F 1XX##%&& ]  iS&9&9 : :;;  FC e}}4<<D     )((#( Yq!__$z11 "  Yr2&&&66-00 ] #' HHTNNNN IIaLL ::c?? #2# AAC  HA a $||F### %**FFvFFFFF G GGr!utf-8cRt|tst|}t|tr||}|rdnd}t ||}t|ts|d}|r|dd}|S)aQuote a string for use in a URL using the given charset. This function is misnamed, it is a wrapper around :func:`urllib.parse.quote`. :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!/rz%20+)r4r r encoderdecodereplace)r5charsetfor_qssafervs runicode_urlencoder3s c< ( (nn#y!!"jj!! "33dD 3  B b) $ $ YYw   $ ZZs # # Ir!ceZdZdZdZdZdZdZdZdZ dd Z dd Z d Z d Z d ZdZdZdZdZdZdZdZdZdZdZdZdZdZe ZdS)LRUCachez"A simple LRU Cache implementation.cp||_i|_t|_|dSN)capacity_mappingr_queue _postinit)selfrs r__init__zLRUCache.__init__Ws1   gg  r!c|jj|_|jj|_|jj|_t|_|jj |_ dSr) rpopleft_popleftpop_popremove_remover_wlockr_appendrs rrzLRUCache._postinit]s@ + KO {) ff {) r!c,|j|j|jdS)Nrrrrrs r __getstate__zLRUCache.__getstate__es   k   r!cb|j||dSr)__dict__updater)rds r __setstate__zLRUCache.__setstate__ls. Q r!c|jfSr)rrs r__getnewargs__zLRUCache.__getnewargs__ps  r!c||j}|j|j|j|j|S)z&Return a shallow copy of the instance.) __class__rrrrextendrrs rcopyz LRUCache.copyssJ ^^DM * * 4=))) %%% r!Nc8 ||S#t$r|cYSwxYw)z/Return an item from the cache dict or `default`KeyErrorrkeydefaults rgetz LRUCache.getzs5 9    NNN s  cB ||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    DINNN s  c |j |j|j|jdS#|jwxYw)zClear the cache.N)racquirerr@rreleasers rr@zLRUCache.clearsw  " M   ! ! ! K      K   ! ! ! ! !DK   ! ! ! !s 2A((Bc||jvS)z$Check if a key exists in this cache.rrrs r __contains__zLRUCache.__contains__sdm##r!c*t|jS)z%Return the current size of the cache.)rirrs r__len__zLRUCache.__len__s4=!!!r!c2d|jjd|jdS)Nrrr)rr^rrs rrzLRUCache.__repr__s  N333T]]]CCr!c\|j |j|}|jd|kr< ||n#t $rYnwxYw||||jS#|jwxYw)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. r)rrrrr ValueErrorrr)rrrs r __getitem__zLRUCache.__getitem__s  "s#B{2#%%LL%%%%!D   S!!! K   ! ! ! !DK   ! ! ! !s.BAB ABABB+c|j ||jvr||n7t |j|jkr|j|=||||j|<|jdS#|jwxYw)zhSets the value for an item. Moves the item up so that it has the highest priority then. N) rrrrrirrrr)rrvalues r __setitem__zLRUCache.__setitem__s  "dm## S!!!!T]##t}44M$--//2 LL   !&DM#  K   ! ! ! ! !DK   ! ! ! !s A5B++Cc|j |j|= ||n#t$rYnwxYw|jdS#|jwxYw)z]Remove an item from the cache dict. Raise a `KeyError` if it does not exist. N)rrrrrrrs r __delitem__zLRUCache.__delitem__s  " c"  S!!!!     K   ! ! ! ! !DK   ! ! ! !s+A%:A% AA%AA%%BcpfdtjD}||S)zReturn a list of items.c.g|]}|j|fSrr)rrrs r z"LRUCache.items..s%III3 c*+IIIr!)listrreverse)rrs` ritemszLRUCache.itemss;IIIItDK7H7HIII r!c|tjdtdt|S)zIterate over all items.zP'iteritems()' will be removed in version 3.0. Use 'iter(cache.items())' instead.r stacklevel)warningswarnDeprecationWarningiterrrs r iteritemszLRUCache.iteritemss>  .      DJJLL!!!r!c>d|DS)zReturn a list of all values.cg|] }|d S)r rrs rrz#LRUCache.values..s+++!+++r!)rrs rvalueszLRUCache.valuess++djjll++++r!c|tjdtdt|S)Iterate over all values.zQ'itervalue()' will be removed in version 3.0. Use 'iter(cache.values())' instead.rrrrrrrrs r itervaluezLRUCache.itervalue>  /      DKKMM"""r!c|tjdtdt|S)rzR'itervalues()' will be removed in version 3.0. Use 'iter(cache.values())' instead.rrrrs r itervalueszLRUCache.itervaluesrr!c t|S)z7Return a list of all keys ordered by most recent usage.)rrs rkeysz LRUCache.keyssDzzr!cXtjdtdt|S)z[Iterate over all keys in the cache dict, ordered by the most recent usage. zN'iterkeys()' will be removed in version 3.0. Use 'iter(cache.keys())' instead.rr)rrrrrs riterkeyszLRUCache.iterkeyss6   -      Dzzr!cDtt|jSr)reversedtuplerrs r__iter__zLRUCache.__iter__ sdk**+++r!cDtt|jS)zTIterate over the keys in the cache dict, oldest items coming first. )rr rrs r __reversed__zLRUCache.__reversed__ sE$+&&'''r!r)r^r] __qualname____doc__rrrrrrrrr@rrrrrrrrrrrrr rr__copy__rr!rrrPs,,  ***      """$$$"""DDD""", " " " " " " """,,,######   ,,,((( HHHr!rrhtmxmlctd|Dtd|Dfd}|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 c3jK|].}d|dzV/dSrNlstriplowerrs rrz$select_autoescape..As=UUQS188C==#6#6#8#88UUUUUUr!c3jK|].}d|dzV/dSrrrs rrz$select_autoescape..Bs=WWacAHHSMM$7$7$9$99WWWWWWr!c|S|}|rdS|rdSS)NTF)rru) template_namerdefault_for_stringdisabled_patternsenabled_patternss r autoescapez%select_autoescape..autoescapeDs]  % %%++--  ! !"2 3 3 4  ! !"3 4 4 5r!)r )enabled_extensionsdisabled_extensionsr rr#r!r"s `` @@rselect_autoescaper&suPUUBTUUUUUWWCVWWWWW r!c | tj}||fi|dddddddd }t|S) aWorks exactly like :func:`dumps` but is safe for use in ``