a P}d?Z;dWeje-e(e-dAdBdCZGdDdEdEZ?dXej@e-ej@e-e(e(ejej/e-ge(fdGdHdIZAdYejej/ejd e-fejejBdJdKdLZCGdMdNdNZDGdOdPdPZEGdQdRdRZFdS)ZN)abc)deque)choice) randrange)Lock)CodeType)quote_from_bytesF.)boundZ MissingType__repr__cCsdS)Nmissingr xr r @/usr/lib/python3.9/site-packages/ansible/_vendor/jinja2/utils.pyrr internal_code)freturncCs tj|_|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_argrr r r pass_contexts rcCs tj|_|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_contextrrr r rpass_eval_context.s rcCs tj|_|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 environmentrrr r rpass_environment?s rc@s>eZdZeZeZeZee e j ddddZ dS)robjrcCst|dr|jSdS)Nr)hasattrr)clsr!r r rfrom_objQs z_PassArg.from_objN) __name__ __module__ __qualname__enumautorrr classmethodr tOptionalr$r r r rrLs rcCst|j|S)z%Marks the function as internally used)radd__code__rr r r internalcodeYs r/r cCsddlm}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)Zruntimer1 isinstance)r!r1r r r is_undefined_s r3)iterablercCs|D]}qdS)z4Consumes an iterable without doing anything with it.Nr )r4_r r rconsumepsr6rcCs,ddlm}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. r0)get_spontaneous_environment) _lexer_cacheN)rr8Zlexerr9 cache_clearclear)r8r9r r r clear_cachesvs  r<F) import_namesilentrc CsxzVd|vr|dd\}}n$d|vr6|d\}}}n t|WStt|dd|g|WSttfyr|snYn0dS)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 :r0.N)split rpartition __import__getattr ImportErrorAttributeError)r=r>moduler!r5r r r import_strings  rHrb)filenamemodercCstj|sdSt||S)z\Returns a file descriptor for the filename if that file exists, otherwise ``None``. N)ospathisfileopen)rJrKr r ropen_if_existss rPcCsJ|dur dS|turdSt|}|jdkr6|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`). NNoneEllipsisbuiltinsz objectr@)rRtyper&r%)r!r#r r robject_type_reprs  rUcCsddlm}||S)z.Format an object using :func:`pprint.pformat`.r)pformat)ZpprintrV)r!rVr r rrVs rVa@ ^ ( (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_schemesrc sdurttdfdd }nttddd}tdtt|}|rZdt|dnd }|rtd t|dnd }t|D]&\} } d | d } } } td | }|r|} | |d} | d rt d | }|r|} | d| } dD]n\}}| |}|| |krqt t|| |D]4}| |t|}| | d|7} | |d} q0qt| r| ds| drd| d||d|| d} n d| d||d|| d} n| dr t| ddr d| d| ddd} nd| vrL| dsLd| vrLt| rLd| d| d} nH|dur|D]8}| |krZ| |rZd| d||d| d} qZ| | | || <qd |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. N)rrcs"t|kr|ddS|S)Nz...)lenrrXr rtrim_urls zurlize..trim_urlcSs|SNr rr r rr^ sz(\s+)z rel=""rz target="z ^([(<]|<)+))>r@, >z([)>.,\n]|>)+$))(ra)@zwww.r?z|j$|j|jWdn1s00YdS)zClear the cache.N)rrr;rrr r rr;s zLRUCache.clear)rrcCs ||jvS)z$Check if a key exists in this cache.rrrr r r __contains__szLRUCache.__contains__cCs t|jS)z%Return the current size of the cache.)r\rrr r r__len__szLRUCache.__len__cCsdt|jd|jdS)Nrgrrb)rTr%rrr r rr szLRUCache.__repr__c Csr|jX|j|}|jd|krLz||Wnty@Yn0|||WdS1sd0YdS)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)rrrr r r __getitem__s   zLRUCache.__getitem__)rvaluercCsp|jV||jvr||nt|j|jkr:|j|=||||j|<Wdn1sb0YdS)zhSets the value for an item. Moves the item up so that it has the highest priority then. N)rrrr\rrr)rrrr r r __setitem__s    zLRUCache.__setitem__c CsT|j:|j|=z||Wnty0Yn0Wdn1sF0YdS)z]Remove an item from the cache dict. Raise a `KeyError` if it does not exist. N)rrrrrr r r __delitem__s  zLRUCache.__delitem__cs$fddtjD}||S)zReturn a list of items.csg|]}|j|fqSr r)rrrr r "rz"LRUCache.items..)listrreverse)rrr rritems szLRUCache.itemscCsdd|DS)zReturn a list of all values.cSsg|] }|dqS)r0r rr r rr(rz#LRUCache.values..)rrr r rvalues&szLRUCache.valuescCst|S)z7Return a list of all keys ordered by most recent usage.)rrr r rkeys*sz LRUCache.keyscCstt|jSr_)reversedtuplerrr r r__iter__.szLRUCache.__iter__cCstt|jS)zTIterate over the keys in the cache dict, oldest items coming first. )iterrrrr r r __reversed__1szLRUCache.__reversed__)N)N)"r%r&r'__doc__intrrr+MappingrjAnyrrTuplerrrrr;boolrrr rrrIterablerrrIteratorrr__copy__r r r rrs,   "rrZhtmZxml)enabled_extensionsdisabled_extensionsdefault_for_stringrrcsHtdd|Dtdd|Dtjttdfdd }|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 css"|]}d|dVqdSr@Nlstriplowerrr r rrbrz$select_autoescape..css"|]}d|dVqdSrrrr r rrcr) template_namercs4|dur S|}|r"dS|r0dSS)NTF)rrr)rrrZdisabled_patternsZenabled_patternsr r autoescapees  z%select_autoescape..autoescape)rr+r,rjr)rrrrrr rrselect_autoescape:s( r)r!dumpskwargsrcKsD|durtj}t||fi|dddddddd S) 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 ``