Files
intellecton/venv/lib/python3.12/site-packages/jinja2/__pycache__/utils.cpython-312.pyc
T

325 lines
34 KiB
Plaintext
Raw Normal View History

Ë
jA^ã
óLUddlZddlZddlZddlZddlZddlmZddlmZddl m
Z
ddl m Z ddl m
Z
ddlmZddlmZddlZej&rddlZej,d ej.d
ej0f¬ «ZGd d
«Ze«Zej0ed< e«Zej>eed<dj@Z!dedefdZ"dedefdZ#dedefdZ$GddejJ«Z&dedefdZ'dej0de(fdZ)dejTej0ddfdZ+dFdZ,dGde-de(dej0fd „Z.dHd!e-d"e-dej^ej`ej0fd#„Z1dej0de-fd$„Z2dej0de-fd%„Z3ejhd&ejjejlz«Z7ejhd'«Z8 dId(e-d)ej^e9d*ej^e-d+ej^e-d,ej^ejTe-de-f d-„Z: dJd.e9d/e(d0e9d1e9de-f
d2„Z;dKdej0d3e-d4e(de-fd5„Z<ejzj|Gd6„d7««Z? dLd8ej€e-d9ej€e-d:e(d;e(dej.ej^e-ge(ff
d<„ZA dMdej0d=ej^ej.d
e-fd>ej0dej„fd?„ZCGd@„dA«ZDGdB„dC«ZEGdD„dE«ZFy)NéN)Úabc)Údeque)Úchoice)Ú randrange)ÚLock)ÚCodeType)Úquote_from_bytesÚF.)Úboundcó$eZdZdefdZdefdZy)Ú _MissingTypeÚreturncóy©missing©©Úselfs úO/home/antigravity/intellecton/venv/lib/python3.12/site-packages/jinja2/utils.pyÚ__repr__z_MissingType.__repr__óØócóyrrrs rÚ
__reduce__z_MissingType.__reduce__rrN)Ú__name__Ú
__module__Ú __qualname__Ústrrrrrrr
r
sð˜#óð˜Côrr
rÚ
internal_codeÚÚfrcó0tj|_|S)Pass 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``.
)Ú_PassArgÚcontextÚjinja_pass_arg©r!s rÚ pass_contextr'&sô ×'€AÔØ €Hrcó0tj|_|S)a“Pass 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&s rÚpass_eval_contextr*7sô ×,€AÔØ €Hrcó0tj|_|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#Ú environmentr%r&s rÚpass_environmentr-Hsô ×+€AÔØ €Hrcó¦eZdZej«Zej«Zej«Zede de
jdfd«Z y)r#Úobjrcó4t|d«r |jSy)Nr%)Úhasattrr%)Úclsr/s rÚfrom_objz_PassArg.from_objZsä  × rN)
rrrÚenumÚautor$r)r,Ú classmethodr
ÚOptionalr3rrrr#r#UsR؈di‰ik€GØ4—9‘9“;€LØ$—)‘)“+€Kàð˜1ð §¡¨JÑ!7òóñrr#cóDtj|j«|S)z%Marks the function as internally used)rÚaddÚ__code__r&s rÚ internalcoder<bsä×Ña—j‘jÔ €Hrr/có&ddlm}t||«S)a´Check 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_undefinedrBhsõ c˜ %rÚiterablecó|D]}Œy)z4Consumes an iterable without doing anything with it.Nr)rCÚ_s rÚconsumerFysà
ò
ˆØ ñ
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.
r>)Úget_spontaneous_environment)Ú _lexer_cacheN)r,rHÚlexerrIÚ cache_clearÚclear)rHrIs rÚ clear_cachesrMs"õ ××ÑÕrÚ import_nameÚsilentcóä d|vr|jdd«\}}n%d|vr|jd«\}}}n t|«Stt|dd|g«|«S#tt
f$r|sYywxYw)a˜Imports 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>ú.N)ÚsplitÚ
rpartitionÚ
__import__ÚgetattrÚ ImportErrorÚAttributeError)rNrOÚmoduler/rEs rÚ
import_stringrZŒs‡ð
Ø  Ø+¨C°Ó3‰KˆF‘CØ

Ø3°CÓ8‰NˆFA‘sä˜ ”z &¨$°°s°eÓ<¸BøÜ œÐ ÙØ ñðús>AÁAÁA/Á.A/ÚfilenameÚmodecóZtjj|«syt||«S)z\Returns a file descriptor for the filename if that file exists,
otherwise ``None``.
N)ÚosÚpathÚisfileÚopen)r[r\s rÚopen_if_existsrb¤s$ô 7‰7>‰>˜ ä ˜ Ðrcó¤|y|turyt|«}|jdk(r|jdS|jd|jdS)z¨Returns 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`).
ÚNoneÚEllipsisÚbuiltinsz objectrR)reÚtyperr)r/r2s rÚobject_type_reprrh®sXð
 €{ØØ Øä
ˆs)€Cà
‡~Ò—,,˜n‰nÐ
˜Q˜sŸ|™|˜n¨GÐ 4rcóddlm}||«S)z.Format an object using :func:`pprint.pformat`.r)Úpformat)Úpprintrj)r/rjs rrjrjÀsåá 3ra@
^
(
(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+$ÚtextÚtrim_url_limitÚrelÚtargetÚ
extra_schemesc
óÆdtdtfˆfd }ndtdtfd}tjdttj|«««}|rdtj|«dnd }|rd
tj|«dnd }t |«D]0\} }
d |
d }
} } tj d | «}|r#|j«} | |j«d} | jd «r;tjd
| «}|r#|j«}
| d|j«} dD]~\}}| j|«}|| j|«krŒ,tt||
j|«««D],}|
j|«t!|«z}| |
d|z
} |
|d}
Œ.Œ€t"j
| «rL| j%d«s| j%d«rd| d||d|| «d} nÃd| d||d|| «d} n®| j%d«r%t&j
| dd«r
d| d| ddd} nxd| vrE| j%d«s4| j%d«s#d| vrt&j
| «r
d| d| d} n/|-|D](}| |k7sŒ | j%|«sŒd| d||d| d} Œ*| | |
|| <Œ3d 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.
xrcó4t|«kDr|ddS|S)Nz...)Úlen)rrrms €rÚtrim_urlzurlize.<locals>.trim_urls)ø€Ü1v˜Ò˜O˜-¨SЈHrcó|S©Nr)rrs rruzurlize.<locals>.trim_urls؈Hrz(\s+)z rel="ú"r z target="z
^([(<]|&lt;)+)ú>rRú
ú&gt;z([)>.,\n]|&gt;)+$))ú(ry)ú<rz)z&lt;r}zhttps://zhttp://z <a href="rzz</a>z<a href="https://zmailto:éz">ú@zwww.rQz<a href="mailto:)rÚrerSÚ
markupsafeÚescapeÚ enumerateÚmatchÚgroupÚendÚendswithÚsearchÚstartÚcountÚrangeÚminÚindexrtÚ_http_reÚ
startswithÚ _email_reÚjoin)rlrmrnrorpruÚwordsÚrel_attrÚ target_attrÚwordÚheadÚmiddleÚtailr†Ú
start_charÚend_charÚ start_countrEÚ end_indexÚschemes ` rÚurlizer¡æs3ø€ðLÐ œð ¤ö ð œð ¤ó ô
H‰HXœs¤:×#4Ñ#4°TÓ#:Ó <€EÙ58œ
×)¨#Ó/¨qÑ1¸b€HÙ>DIœj×Ó8¸Ñ:È"€Kä˜?+‰ˆˆ4Ø  rdˆfˆÜÐ)¨6Óá Ø—;‘;“=ˆDؘEŸI™I›K˜MÐ*ˆFð
?‰?Ð —I2°FÓ;ˆEáØ—{‘{“}Ø  %§+¡+£-Ð0ð%Mò ˆJ˜Ø Ÿ,™, zÓ2ˆKà˜fŸl™l¨8Óôœ3˜{¨D¯J©J°xÓ,@Ó
(Ø ŸJ™J xÓ0´3°x³=Ñ@ à˜$˜z  Ð*ؘI˜'ñ 
  >‰>˜ × Ñ  Ô×0AÑ0AÀ)Ô0Là ˜x ¨
°;°-¸È&ÓAQÐ@RÐRVÐð
 x¨q°°
¸;¸-ÀqÙ Óðð
×
Ñ
˜
)¬i¯o©o¸fÀQÀR¸jÔ.IØ   ¨¨6°!°"¨:¨,°dÐ;‰Fð
6‰MØ×% fÔ×% cÔ˜6Ñ Ô x¨r°&°¸Ð>‰Fà
Ð

Wؘ×(9Ñ(9¸&Õ(Aب°°(°¸K¸È&ÈÐQUÐV
WðV˜F˜8 D *ˆˆað?+ðB 7‰75rÚhtmlrŽÚmaxc óÀddlm}|j«}g}t|«D}d}dx} }
d} d} g}
t tt ||«««D]z\}} t
|«} | | k7r| } nŒ|r| j«} d}|t dd«z
| 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|D«««S)z+Generate some lorem ipsum for the template.r>)ÚLOREM_IPSUM_WORDSTrNFééér{é
érRú éÿÿÿÿz
r|c3óNK|]}dtj|«dŒy­w)z<p>z</p>N)r„©Ú.0rrs rú <genexpr>z'generate_lorem_ipsum.<locals>.<genexpr>”s%èø€ÒC°q
×)¨!Ó-¨TÔCùs#%)
Ú constantsr¦rSrr…rrÚ
capitalizeÚappendr“r‰ÚMarkup)r”ÚresultrEÚnext_capitalizedÚ
last_commaÚ
last_fullstopr˜ÚlastÚidxÚp_strs rÚgenerate_lorem_ipsumr¾as“õ × %€EØ
€Fä
1%ˆØÐØ%&Ð&ˆ
ˆØˆØ ˆô ¤¤i°°SÓ&9Ó :Ó ‰FˆCØÜ˜e“}ؘ4’<Øð ñ
 ØÓ(Ø#(Ð à”Y˜q !“_Ñ$ 
Ø Ñ"
ؘ à”Y˜r Ò6Ø-0Ð0
˜˜ Ø#'Ð Ø
H‰HTNð' ð,˜ ˆà >‰>˜ ؘ#˜2Ñ$‰EØ Ô S‰LˆEà
ðK%ñN Ø{‰{˜ × Ñ Ø ‰ ÑC¸FÔ ðrÚcharsetÚfor_qscóÊt|t«s,t|t«s 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ú+)rAÚbytesrÚencoder Úreplace)r/r¿ÚsafeÚrvs rÚ url_quoterɘs\ô cœ5Ô ˜#œsÔc“(ˆCàj‰j˜Óá‰3˜d€DÜ ˜#˜tÓ $€Bá
Ø
Z‰Z˜˜
#ˆà
€IrcóÆeZdZdZdeddfdZddZdeje 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 «yrw)Ú_mappingrÚ_queueÚ _postinit)rs rÚ__init__zLRUCache.__init__·s#Ø ˆŒ
Ø.0ˆŒ
Ü',£wˆŒ Ø Õrcóú|jj|_|jj|_|jj
|_t«|_|jj|_
yrw) ÚpopleftÚ_popleftÚpopÚ_popÚremoveÚ_removerÚ_wlockr´Ú_appendrs rzLRUCache._postinit½sMàŸ ×Œ
Ø—K‘K—O‘OˆŒ Ø—{‘{׌ Ü“fˆŒ Ø—{‘{× rcóJ|j|j|jdœS)rs rÚ __getstate__zLRUCache.__getstate__Ås!àŸ
ØŸ
Ø—k
ð
rÚdcóZ|jj|«|j«yrw)Ú__dict__ÚupdaterÐ)rs rÚ __setstate__zLRUCache.__setstate__ÌsØ
×јQÔØ Õr.có|jfSrw)rs rÚ__getnewargs__zLRUCache.__getnewargs__ÐsØ
ÐÐrcóÐ|j|j«}|jj|j«|jj |j«|S)z&Return a shallow copy of the instance.)Ú __class__rÌÚextend©rs rÚcopyz
LRUCache.copyÓsEà
^‰^˜DŸM™MÓ
*ˆØ
×ј4Ÿ=™=Ô
‰ ×јŸÔˆ rÚkeyÚdefaultcó0 ||S#t$r|cYSwxYw)z/Return an item from the cache dict or `default`©ÚKeyError©rs rÚgetz LRUCache.getÚs%ð Ø˜‘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.
s rÚ
setdefaultzLRUCache.setdefaultás.ð Ø˜‘9Ð øÜò ؈D‰IØŠNð ús có®|j5|jj«|jj«ddd«y#1swYyxYw)zClear the cache.N)rLrs rrLzLRUCache.clearës>à
[‰[ñ Ø M‰M× Ñ Ô K‰K× Ñ Ô ÷ ÷ ñ ús 5A Á Acó||jvS)z$Check if a key exists in this cache.)©rs rÚ __contains__zLRUCache.__contains__ñsàd—m#rcó,t|j«S)z%Return the current size of the cache.)rtrs rÚ__len__zLRUCache.__len__õsä4—=!rcóNdt|«jd|jdS)Nrrz)rgrrs rrzLRUCache.__repr__ùs'Ø”4˜“:×' ¯©Ð(9¸Ð;rcóð|j5|j|}|jd|k7r# |j|«|j |«|cddd«S#t$rYŒ'wxYw#1swYyxYw)zšGet 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­N)Ú
ValueErrorrÚ)rs rÚ __getitem__zLRUCache.__getitem__üs{ð [‰[ñ ؘsÑ#ˆBà{‰{˜2‰ #ÒØ—L‘L Ô ˜SÔ÷ ñ øô ñð ú÷
 ð ús."A,°AÁA,Á A)Á&A,Á(A)Á)A,Á,A5Úvaluecó@|j5||jvr|j|«n=t|j«|jk(r|j|j «=|j
|«||j|<ddd«y#1swYyxYw)zhSets the value for an item. Moves the item up so that it
has the highest priority then.
N)rt)rs rÚ __setitem__zLRUCache.__setitem__syð[‰[ñd—m ˜SÕT—]‘]Ó# t§}¡}Ò—MM $§-¡-£/Ð L‰L˜Ô Ø!&ˆDM‰M˜ ÷ 'ús A>BÂBcó¢|j5|j|= |j|«ddd«y#t$rYŒwxYw#1swYyxYw)z]Remove an item from the cache dict.
Raise a `KeyError` if it does not exist.
N)s rÚ __delitem__zLRUCache.__delitem__sVð[‰[ñ Ø
˜
Ø ˜SÔ ð øô
ò
Ùð
ú÷  ð ús%Aœ6¶ A¿AÁAÁAÁAcó’t|j«Dcgc]}||j|fŒ}}|j«|Scc}w)zReturn a list of items.)ÚlistrÏÚreverse)rs rÚitemszLRUCache.items+sAä7;¸D¿K¹KÓ7HÖ3˜Ÿ
 cÑÐÔØˆ
ùòJs˜AcóN|j«Dcgc]}|dŒ c}Scc}w)zReturn a list of all values.r>)r)rrrs rÚvalueszLRUCache.values1s à"Ÿj™j+˜!“Ò+ùÒ+s "cót|«S)z7Return a list of all keys ordered by most recent usage.)rrs rÚkeysz
LRUCache.keys5s äDrcó>tt|j««Srw)ÚreversedÚtuplerÏrs rÚ__iter__zLRUCache.__iter__9sÜœ˜dŸk™kÓ+rcó>tt|j««S)zTIterate over the keys in the cache dict, oldest items
coming first.
)Úiterr rs rÚ __reversed__zLRUCache.__reversed__<sô”E˜$Ÿ+™+Ó'r©rN)rzte.Selfrw)"rrrÚ__doc__ÚintrÑr7ÚMappingrÚAnyrÝÚTuplerärLÚboolrörrÿrÚIterablerrr ÚIteratorr
rÚ__copy__rrr¯á  ð¨óó 
˜aŸi™i¨¨Q¯U©U¨
Ñ
ð˜aŸi™i¨¨Q¯U©U¨
Ѹóð  §¡¨¯©¨s¨
Ñ 3ó óñq—u‘uð q§u¡u𸿹óñ˜aŸe™eð¨a¯e©eð¸q¿u¹uóó ð §¡ð$¨$ó"˜ó<˜˜qŸu™u𨯩óð, '˜qŸu™uð '¨Q¯U©Uð '°tó 
˜qŸu™uð
¨ó
ðq—zz !§'¡'¨!¯%©%°·±¨,Ñ"7Ñð ,˜Ÿ
 1§5¡5Ña—jj §¡Ñð,˜!Ÿ*™* Q§U¡UÑ(˜aŸj™j¨¯©Ñ HrÚenabled_extensionsÚdisabled_extensionsÚdefault_for_stringrëcó¢td|D««Štd|D««Šdtjtdtfˆˆˆˆfd }|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,
))