o |nhA^ @sHUddlZddlZddlZddlZddlZddlmZddlmZddl m Z ddl m Z ddl m Z ddlmZddlmZddlZejrJddlZejd ejd ejfd ZGd d d ZeZejed< eZejeed<dj Z!dedefddZ"dedefddZ#dedefddZ$Gdddej%Z&dedefddZ'dejde(fddZ)d ej*ejddfd!d"Z+d_d#d$Z,d`d&e-d'e(dejfd(d)Z.dad+e-d,e-dej/ej0ejfd-d.Z1dejde-fd/d0Z2dejde-fd1d2Z3e4d3ej5ej6BZ7e4d4Z8    dbd5e-d6ej/e9d7ej/e-d8ej/e-d9ej/ej*e-de-f d:d;Z: ?dcd@e9dAe(dBe9dCe9de-f dDdEZ;dddejdGe-dHe(de-fdIdJZGdKdLdLZ? M N = %dedOej@e-dPej@e-dQe(dRe(dejej/e-ge(ff dSdTZA dfdejdUej/ejd e-fdVejdejBfdWdXZCGdYdZdZZDGd[d\d\ZEGd]d^d^ZFdS)gN)abc)deque)choice) randrange)Lock)CodeType)quote_from_bytesF.)boundc@s(eZdZdefddZdefddZdS) _MissingTypereturncCdSNmissingselfrrD/usr/local/bin/dhwp/env/lib/python3.10/site-packages/jinja2/utils.py__repr__z_MissingType.__repr__cCr rrrrrr __reduce__rz_MissingType.__reduce__N)__name__ __module__ __qualname__strrrrrrrr sr r internal_codefr cC 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_argrrrr pass_context& r#cCr)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_contextr!r"rrrpass_eval_context7r$r&cCr)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 environmentr!r"rrrpass_environmentHs r(c@s@eZdZeZeZeZede de j dfddZ dS)robjr cCst|dr|jSdS)Nr!)hasattrr!)clsr)rrrfrom_objZs z_PassArg.from_objN) rrrenumautor r%r' classmethodr tOptionalr,rrrrrUs rcCst|j|S)z%Marks the function as internally used)radd__code__r"rrr internalcodebs r4r)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)runtimer6 isinstance)r)r6rrr is_undefinedhs r9iterablecCs|D]}qdS)z4Consumes an iterable without doing anything with it.Nr)r:_rrrconsumeysr<cCs,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. r5)get_spontaneous_environment) _lexer_cacheN)r'r=lexerr> cache_clearclear)r=r>rrr clear_cachess   rBF import_namesilentc Csvz+d|vr|dd\}}nd|vr|d\}}}nt|WStt|dd|g|WSttfy:|s7YdSw)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 :r5.N)split rpartition __import__getattr ImportErrorAttributeError)rCrDmoduler)r;rrr import_strings  rNrbfilenamemodecCstj|sdSt||S)z\Returns a file descriptor for the filename if that file exists, otherwise ``None``. N)ospathisfileopen)rPrQrrropen_if_existss  rVcCsJ|durdS|tur dSt|}|jdkr|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 objectrF)rXtyperr)r)r+rrrobject_type_reprs  r[cCsddlm}||S)z.Format an object using :func:`pprint.pformat`.r)pformat)pprintr\)r)r\rrrr\s r\a@ ^ ( (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 sdurdtdtffdd }n dtdtfdd}tdtt|}|r/dt|d nd }|r.trim_urlcSs|SNrrerrrrgrz(\s+)z rel=""rz target="z ^([(<]|<)+))>rF, >z([)>.,\n]|>)+$))(rj)@zwww.rEzz

N)rtru.0rcrrr s z'generate_lorem_ipsum..) constantsrrGr~rvrr capitalizeappendrrzrtMarkup)rrrrrrresultr;next_capitalized last_comma last_fullstoprlastpidxp_strrrrgenerate_lorem_ipsumasN        rutf-8charsetfor_qscCsPt|tst|tst|}||}|rdnd}t||}|r&|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. /z%20+)r8bytesrencoderreplace)r)rrsafervrrr url_quotes      rc@seZdZdZdeddfddZd3ddZdeje ej ffd d Z d eje ej fddfd d Z dej ej dffddZd4ddZd5dej dej dej fddZd5dej dej dej fddZd3ddZdej defddZdefddZde fd d!Zdej dej fd"d#Zdej d$ej ddfd%d&Zdej ddfd'd(Zdejej ej ej ffd)d*Zdejej fd+d,Zdejej fd-d.Zdejej fd/d0Zdejej fd1d2Z eZ!dS)6LRUCachez"A simple LRU Cache implementation.capacityr NcCs ||_i|_t|_|dSrh)r_mappingr_queue _postinit)rrrrr__init__s zLRUCache.__init__cCs4|jj|_|jj|_|jj|_t|_|jj |_ dSrh) rpopleft_popleftpop_popremove_remover_wlockr_appendrrrrrs   zLRUCache._postinitcCs|j|j|jdS)Nrrrrrrrr __getstate__szLRUCache.__getstate__dcCs|j||dSrh)__dict__updater)rrrrr __setstate__s  zLRUCache.__setstate__.cCs|jfSrh)rrrrr__getnewargs__szLRUCache.__getnewargs__te.SelfcCs,||j}|j|j|j|j|S)z&Return a shallow copy of the instance.) __class__rrrrextendrrrrrcopys z LRUCache.copykeydefaultcCs"z||WSty|YSw)z/Return an item from the cache dict or `default`KeyErrorrrrrrrgets   z LRUCache.getcCs*z||WSty|||<|YSw)zvSet `default` if the key is not in the cache otherwise leave unchanged. Return the value of this key. rrrrr setdefaults   zLRUCache.setdefaultcCs@|j|j|jWddS1swYdS)zClear the cache.N)rrrArrrrrrAs  "zLRUCache.clearcCs ||jvS)z$Check if a key exists in this cache.rrrrrr __contains__ zLRUCache.__contains__cCs t|jS)z%Return the current size of the cache.)rdrrrrr__len__rzLRUCache.__len__cCsdt|jd|jdS)Nrprrk)rZrrrrrrrszLRUCache.__repr__c Csr|j,|j|}|jd|kr&z||Wn ty Ynw|||WdS1s2wYdS)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)rrrrrr __getitem__s   $zLRUCache.__getitem__valuecCsr|j,||jvr||nt|j|jkr|j|=||||j|<WddS1s2wYdS)zhSets the value for an item. Moves the item up so that it has the highest priority then. N)rrrrdrrr)rrrrrr __setitem__s     "zLRUCache.__setitem__c Csf|j&|j|=z||Wn tyYn wWddSWddS1s,wYdS)z]Remove an item from the cache dict. Raise a `KeyError` if it does not exist. N)rrrrrrrr __delitem__s "zLRUCache.__delitem__cs$fddtjD}||S)zReturn a list of items.csg|] }|j|fqSrr)rrrrr -sz"LRUCache.items..)listrreverse)rrrrritems+szLRUCache.itemscCsdd|DS)zReturn a list of all values.cSsg|]}|dqS)r5rrrrrr3sz#LRUCache.values..)rrrrrvalues1szLRUCache.valuescCst|S)z7Return a list of all keys ordered by most recent usage.)rrrrrkeys5sz LRUCache.keyscCtt|jSrh)reversedtuplerrrrr__iter__9zLRUCache.__iter__cCr)zTIterate over the keys in the cache dict, oldest items coming first. )iterrrrrrr __reversed__<szLRUCache.__reversed__r N)r rrh)"rrr__doc__intrrr0MappingrAnyrrTuplerrrrrAboolrrrrrrIterablerrrIteratorrr__copy__rrrrrs.    " rrhtmxmlrenabled_extensionsdisabled_extensionsdefault_for_stringrcsJtdd|Dtdd|Ddtjtdtffdd }|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 cs$|] }d|dVqdSrFNlstriplowerrrrrrm"z$select_autoescape..csrrrrrrrrnr  template_namer cs4|durS|}|rdS|rdSS)NTF)rrz)r rrdisabled_patternsenabled_patternsrr autoescapeps  z%select_autoescape..autoescape)rr0r1rr)rrrrrrr rselect_autoescapeEs(" rdumpskwargscKsD|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 ``