Files
old-parkingkoncept/parkingkonceptvenv/lib/python3.7/site-packages/jinja2/__pycache__/utils.cpython-37.pyc

265 lines
20 KiB
Plaintext
Raw Normal View History

2019-11-17 12:44:16 +01:00
B
<00>/<2F>]P<00> @sdZddlZddlZddlZddlmZddlmZddlm Z m
Z
m Z m Z m Z e<01>d<06>Ze<01>dd<08>eejd <09><02>d<08>eejd
<EFBFBD><02>f<00>Ze<01>d <0B>Ze<01>d <0C>Ze<01>d <0A>ZdZdZeddddd<14>i<01><03>Ze<1B>ZdjZde<02>d<17>kZdd<19>Z dd<1B>Z!dd<1D>Z"dd<1F>Z#d d!<21>Z$d"d#<23>Z%d$d%<25>Z&dJd'd(<28>Z'dKd*d+<2B>Z(d,d-<2D>Z)dLd.d/<2F>Z*dMd0d1<64>Z+dNd6d7<64>Z,dOd9d:<3A>Z-Gd;d<<3C>d<e.<2E>Z/e j0<6A>1e/<2F>dPd>d?<3F>Z2dQd@dA<64>Z3e GdBdC<64>dCe.<2E><03>Z4GdDdE<64>dEe.<2E>Z5GdFdG<64>dGe.<2E>Z6ye7dH<64>d3Z8Wne9k
<EFBFBD>r<>d&Z8YnXddIl:m;Z;mZm<Z<dS)Rz<52>
jinja2.utils
~~~~~~~~~~~~
Utility functions.
:copyright: (c) 2017 by the Jinja Team.
:license: BSD, see LICENSE for more details.
<EFBFBD>N)<01>deque)<01>Lock)<05> text_type<70> string_types<65>implements_iterator<6F> url_quote<74>abcz(\s+)z4^(?P<lead>(?:%s)*)(?P<middle>.*?)(?P<trail>(?:%s)*)$<24>|)<03>(<28><z&lt;)<06>.<2E>,<2C>)<29>><3E>
z&gt;z&^\S+@[a-zA-Z0-9._-]+\.[a-zA-Z0-9._-]+$z(<!--.*?-->|<[^>]*>)z &([^;]+);<3B>4abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ<59>
0123456789Z MissingType<70><00>__repr__cCsdS)N<>missingr)<01>xrr<00>0/tmp/pip-install-c3kgu56x/Jinja2/jinja2/utils.py<70><lambda>"<00>r<00>z\/<2F>/cCs
d|_|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)<01>contextfunction)<01>frrrr,s rcCs
d|_|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)<01>evalcontextfunction)rrrrr<s rcCs
d|_|S)z<>This 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)<01>environmentfunction)rrrrrIsrcCst<00>|j<02>|S)z%Marks the function as internally used)<03> internal_code<64>add<64>__code__)rrrr<00> internalcodeSs r#cCsddlm}t||<01>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
r)<01> Undefined)Zjinja2.runtimer$<00>
isinstance)<02>objr$rrr<00> is_undefinedYs r'cCsx |D]}qWdS)z4Consumes an iterable without doing anything with it.Nr)<02>iterable<6C>eventrrr<00>consumeis
r*cCs,ddlm}ddlm}|<00><04>|<01><04>dS)a"Jinja2 keeps internal caches for environments and lexers. These are
used so that Jinja2 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)<01>_spontaneous_environments)<01> _lexer_cacheN)Zjinja2.environmentr+Z jinja2.lexerr,<00>clear)r+r,rrr<00> clear_cachesos  r.Fc Cs<>yfd|kr|<00>dd<02>\}}n6d|krJ|<00>d<03>}d<03>|dd<05><00>}|d}nt|<00>Stt|dd|g<01>|<03>Sttfk
r<EFBFBD>|s<><73>YnXdS)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
<20>:<3A>r N<><4E><EFBFBD><EFBFBD><EFBFBD>)<06>split<69>join<69>
__import__<EFBFBD>getattr<74> ImportError<6F>AttributeError)<05> import_nameZsilent<6E>moduler&<00>itemsrrr<00> import_string{s 

r;<00>rbc
CsJy
t||<01>Stk
rD}z|jtjtjtjfkr4<72>Wdd}~XYnXdS)zZReturns a file descriptor for the filename if that file exists,
otherwise `None`.
N)<06>open<65>IOError<6F>errno<6E>ENOENTZEISDIR<49>EINVAL)<03>filename<6D>mode<64>errr<00>open_if_exists<74>s

rEcCsJ|dkr dS|tkrdS|jjdkr.|jj}n|jjd|jj}d|S)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`).
N<>None<6E>Ellipsis)<02> __builtin__<5F>builtinsr z %s object)rG<00> __class__<5F>
__module__<EFBFBD>__name__)r&<00>namerrr<00>object_type_repr<70>s 
rNcCsByddlm}|||d<03>Stk
r<ddlm}||<00>SXdS)zYPrettyprint an object. Either use the `pretty` library or the
builtin `pprint`.
r)<01>pretty)<01>verbose)<01>pformatN)rOr6<00>pprintrQ)r&rPrOrQrrrrQ<00>s    rQcCs<>|fdd<02>}t<00>tt|<00><01><01>}|r2dtt|<02><01>p4d}|rFdt|<03>pHd}<07>x*t|<05>D<00>]\}} t<05>| <09>}
|
rV|
<EFBFBD><07>\} } } | <0C>d<06>s<>d| kr<>| <0C>d<08>s<>| <0C>d <09>s<>t | <0C>d
kr<>| d
t
t kr<>| <0C> d <0B>s<>| <0C> d <0C>s<>| <0C> d <0A>r<>d| |||| <0C>f} | <0C>d<08><01>s| <0C>d <09><01>rd| |||| <0C>f} d| k<06>rT| <0C>d<06><01>sTd| k<07>rTt <0A>| <0C><01>rTd| | f} | | | | krV| | | ||<qVWd<04>|<05>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.
cSs,|dk r(|d|<01>t|<00>|kr"dp$dp*|S)Nz...r)<01>len)r<00>limitrrrr<00>szurlize.<locals>.<lambda>z rel="%s"rz target="%s"zwww.<2E>@zhttp://zhttps://rz.orgz.netz.comz<a href="http://%s"%s%s>%s</a>z<a href="%s"%s%s>%s</a>r/z<a href="mailto:%s">%s</a>)<0F>_word_split_rer2r<00>escape<70> enumerate<74>_punctuation_re<72>match<63>groups<70>
startswithrS<00>_letters<72>_digits<74>endswith<74>_simple_email_rer3)<0E>textZtrim_url_limit<69>rel<65>targetZtrim_url<72>wordsZrel_attrZ target_attr<74>i<>wordrZZleadZmiddle<6C>trailrrr<00>urlize<7A>s: 



 


   rh<00>T<><00>dcCsfddlm}ddlm}m}|<04><05>}g}<08>xt|<00>D<00>]} d}
d} } d} d}g}x<>tt|||<03><02><01>D]<5D>\}} x||<07>} | |krp| }PqpW|
r<EFBFBD>| <0A><08>} d}
||dd<08>| kr<>|} | d 7} | d
7} ||d d <0C>| kr<>|} } | d 7} d}
|<0F> | <0A>qfWd<0E>
|<0F>}|<0F> d
<EFBFBD><01>r|dd<0F>d }n|<0F> d <0A><01>s0|d 7}|<08> |<0F>q4W|<01>sNd<10>
|<08>St d<11>
dd<13>|D<00><01><01>S)z+Generate some lorem ipsum for the template.r)<01>LOREM_IPSUM_WORDS)<02>choice<63> randrangeTNF<4E><00><00>r <00>
rjr <00> r1z
rcss|]}dt|<01>VqdS)z <p>%s</p>N)rW)<02>.0rrrr<00> <genexpr>sz'generate_lorem_ipsum.<locals>.<genexpr>) Zjinja2.constantsrl<00>randomrmrnr2<00>rangerX<00>
capitalize<EFBFBD>appendr3r_<00>Markup)<11>n<>html<6D>min<69>maxrlrmrnrd<00>result<6C>_Znext_capitalizedZ
last_commaZ last_fullstoprf<00>last<73>p<>idxrrr<00>generate_lorem_ipsum<75>sJ 
  
r<><00>utf-8cCsVt|t<01>st|<00>}t|t<02>r&|<00>|<01>}| r0dp2d}tt||<03><02>}|rR|<04>dd<04>}|S)a&URL escapes a single bytestring or unicode string with the
given charset if applicable to URL safe quoting under all rules
that need to be considered under all supported Python versions.
If non strings are provided they are converted to their unicode
representation first.
<20>/rz%20<32>+)r%rr<00>encoder<00>replace)r&<00>charsetZfor_qs<71>safe<66>rvrrr<00>unicode_urlencodes


 r<>c@s<>eZdZdZdd<03>Zdd<05>Zdd<07>Zdd <09>Zd
d <0B>Zd d <0A>Z d/dd<10>Z
d0dd<12>Z dd<14>Z dd<16>Z dd<18>Zdd<1A>Zdd<1C>Zdd<1E>Zdd <20>Zd!d"<22>Zd#d$<24>Zd%d&<26>Zd'd(<28>Zd)d*<2A>Zd+d,<2C>ZeZd-d.<2E>Ze ZdS)1<>LRUCachez"A simple LRU Cache implementation.cCs ||_i|_t<02>|_|<00><04>dS)N)<05>capacity<74>_mappingr<00>_queue<75> _postinit)<02>selfr<66>rrr<00>__init__9szLRUCache.__init__cCs4|jj|_|jj|_|jj|_t<07>|_|jj |_
dS)N) r<><00>popleft<66>_popleft<66>popZ_pop<6F>remove<76>_remover<00>_wlockry<00>_append)r<>rrrr<>?s



zLRUCache._postinitcCs|j|j|jd<01>S)N)r<>r<>r<>)r<>r<>r<>)r<>rrr<00> __getstate__GszLRUCache.__getstate__cCs|j<00>|<01>|<00><02>dS)N)<03>__dict__<5F>updater<65>)r<><00>drrr<00> __setstate__Ns zLRUCache.__setstate__cCs|jfS)N)r<>)r<>rrr<00>__getnewargs__RszLRUCache.__getnewargs__cCs*|<00>|j<01>}|j<02>|j<02>t|j<05>|_|S)z&Return a shallow copy of the instance.)rJr<>r<>r<>rr<>)r<>r<>rrr<00>copyUs  z LRUCache.copyNcCs"y||Stk
r|SXdS)z/Return an item from the cache dict or `default`N)<01>KeyError)r<><00>key<65>defaultrrr<00>get\sz LRUCache.getcCsF|j<00><01>z*y||Stk
r0|||<|SXWd|j<00><03>XdS)zvSet `default` if the key is not in the cache otherwise
leave unchanged. Return the value of this key.
N)r<><00>acquirer<65><00>release)r<>r<>r<>rrr<00>
setdefaultcs

zLRUCache.setdefaultcCs4|j<00><01>z|j<02><03>|j<04><03>Wd|j<00><05>XdS)zClear the cache.N)r<>r<>r<>r-r<>r<>)r<>rrrr-qs


zLRUCache.clearcCs
||jkS)z$Check if a key exists in this cache.)r<>)r<>r<>rrr<00> __contains__zszLRUCache.__contains__cCs
t|j<01>S)z%Return the current size of the cache.)rSr<>)r<>rrr<00>__len__~szLRUCache.__len__cCsd|jj|jfS)Nz<%s %r>)rJrLr<>)r<>rrrr<00>szLRUCache.__repr__cCsf|j<00><01>zJ|j|}|jd|krRy|<00>|<01>Wntk
rFYnX|<00>|<01>|S|j<00><07>XdS)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.
r1N)r<>r<>r<>r<>r<><00>
ValueErrorr<EFBFBD>r<>)r<>r<>r<>rrr<00> __getitem__<5F>s


zLRUCache.__getitem__cCsf|j<00><01>zJ||jkr"|<00>|<01>nt|j<02>|jkr>|j|<00><06>=|<00>|<01>||j|<Wd|j<00><08>XdS)zhSets the value for an item. Moves the item up so that it
has the highest priority then.
N) r<>r<>r<>r<>rSr<>r<>r<>r<>)r<>r<><00>valuerrr<00> __setitem__<5F>s

  
zLRUCache.__setitem__cCsL|j<00><01>z0|j|=y|<00>|<01>Wntk
r6YnXWd|j<00><05>XdS)z]Remove an item from the cache dict.
Raise a `KeyError` if it does not exist.
N)r<>r<>r<>r<>r<>r<>)r<>r<>rrr<00> __delitem__<5F>s

zLRUCache.__delitem__cs$<00>fdd<02>t<00>j<01>D<00>}|<01><02>|S)zReturn a list of items.csg|]}|<01>j|f<02>qSr)r<>)rtr<>)r<>rr<00>
<listcomp><3E>sz"LRUCache.items.<locals>.<listcomp>)<03>listr<74><00>reverse)r<>rr)r<>rr:<00>szLRUCache.itemscCs t|<00><01><00>S)zIterate over all items.)<02>iterr:)r<>rrr<00> iteritems<6D>szLRUCache.iteritemscCsdd<02>|<00><00>D<00>S)zReturn a list of all values.cSsg|] }|d<00>qS)r0r)rtrrrrr<><00>sz#LRUCache.values.<locals>.<listcomp>)r:)r<>rrr<00>values<65>szLRUCache.valuescCs t|<00><01><00>S)zIterate over all values.)r<>r<>)r<>rrr<00> itervalue<75>szLRUCache.itervaluecCst|<00>S)z7Return a list of all keys ordered by most recent usage.)r<>)r<>rrr<00>keys<79>sz LRUCache.keyscCstt|j<02><01>S)z[Iterate over all keys in the cache dict, ordered by
the most recent usage.
)<03>reversed<65>tupler<65>)r<>rrr<00>iterkeys<79>szLRUCache.iterkeyscCstt|j<02><01>S)zVIterate over the values in the cache dict, oldest items
coming first.
)r<>r<>r<>)r<>rrr<00> __reversed__<5F>szLRUCache.__reversed__)N)N)rLrK<00> __qualname__<5F>__doc__r<5F>r<>r<>r<>r<>r<>r<>r<>r-r<>r<>rr<>r<>r<>r:r<>r<>r<>r<>r<><00>__iter__r<5F><00>__copy__rrrrr<>2s2

 r<><00>r|Zhtm<74>xmlcs:tdd<02>|D<00><01><01>tdd<02>|D<00><01><01><02><00><01><02>fdd<05>}|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|<01>d<00><01><01>VqdS)r N)<02>lstrip<69>lower)rtrrrrru sz$select_autoescape.<locals>.<genexpr>css |]}d|<01>d<00><01><01>VqdS)r N)r<>r<>)rtrrrrruscs4|dkr <0C>S|<00><00>}|<00><01><03>r"dS|<00><01><02>r0dS<00>S)NTF)r<>r_)Z template_name)r<><00>default_for_string<6E>disabled_patterns<6E>enabled_patternsrr<00>
autoescapes

z%select_autoescape.<locals>.autoescape)r<>)Zenabled_extensionsZdisabled_extensionsr<73>r<>r<>r)r<>r<>r<>r<>r<00>select_autoescape<70>s &

 r<>cKsB|dkrtj}||f|<02><01>dd<03><02>dd<05><02>dd<07><02>dd <09>}t|<03>S)
a<EFBFBD>Works exactly like :func:`dumps` but is safe for use in ``<script>``
tags. It accepts the same arguments and returns a JSON string. Note that
this is available in templates through the ``|tojson`` filter which will
also mark the result as safe. Due to how this function escapes certain
characters this is safe even if used outside of ``<script>`` tags.
The following characters are escaped in strings:
- ``<``
- ``>``
- ``&``
- ``'``
This makes it safe to embed such strings in any place in HTML with the
notable exception of double quoted attributes. In that case single
quote your attributes or HTML escape it in addition.
Nr z\u003crz\u003e<33>&z\u0026<32>'z\u0027)<04>json<6F>dumpsr<73>rz)r&Zdumper<65>kwargsr<73>rrr<00>htmlsafe_json_dumpss r<>c@s8eZdZdZdd<03>Zdd<05>Zedd<07><00>Zdd <09>ZeZ d
S) <0B>CyclerzA cycle helper for templates.cGs|s td<01><01>||_|<00><02>dS)Nz$at least one item has to be provided)<03> RuntimeErrorr:<00>reset)r<>r:rrrr<><szCycler.__init__cCs
d|_dS)zResets the cycle.rN)<01>pos)r<>rrrr<>Bsz Cycler.resetcCs |j|jS)zReturns the current item.)r:r<>)r<>rrr<00>currentFszCycler.currentcCs |j}|jdt|j<03>|_|S)z#Goes one item ahead and returns it.r0)r<>r<>rSr:)r<>r<>rrr<00>nextKsz Cycler.nextN)
rLrKr<>r<>r<>r<><00>propertyr<79>r<><00>__next__rrrrr<>8s  r<>c@s"eZdZdZddd<04>Zdd<06>ZdS) <09>JoinerzA joining helper for templates.<2E>, cCs||_d|_dS)NF)<02>sep<65>used)r<>r<>rrrr<>WszJoiner.__init__cCs|jsd|_dS|jS)NTr)r<>r<>)r<>rrr<00>__call__[szJoiner.__call__N)r<>)rLrKr<>r<>r<>r<>rrrrr<>Ts
r<>c@s0eZdZdZdd<03>Zdd<05>Zdd<07>Zdd <09>Zd
S) <0B> Namespacez}A namespace object that can hold arbitrary attributes. It may be
initialized from a dictionary or with keyword argments.cOs&|d|dd<00>}}t||<01>|_dS)Nrr0)<02>dict<63>_Namespace__attrs)<03>argsr<73>r<>rrrr<>fszNamespace.__init__cCs@|dkrt<00>||<01>Sy
|j|Stk
r:t|<01><01>YnXdS)Nr<4E>)<05>object<63>__getattribute__r<5F>r<>r7)r<>rMrrrr<>js  
zNamespace.__getattribute__cCs||j|<dS)N)r<>)r<>rMr<>rrrr<>rszNamespace.__setitem__cCs
d|jS)Nz<Namespace %r>)r<>)r<>rrrruszNamespace.__repr__N)rLrKr<>r<>r<>r<>r<>rrrrrr<>bs
r<>z,async def _():
async for _ in ():
yield _)rzrW<00> soft_unicode)F)r<)F)NNN)riTrjrk)r<>F)r<>rTF)N)=r<><00>rer<65>r?<00> collectionsr<00> threadingrZjinja2._compatrrrrr<00>compilerVr3<00>maprWrYr`Z _striptags_reZ
_entity_rer]r^<00>typer<00>setr <00>concatr<74>Z _slash_escaperrrr#r'r*r.r;rErNrQrhr<>r<>r<>r<><00>MutableMapping<6E>registerr<72>r<>r<>r<>r<><00>execZhave_async_gen<65> SyntaxErrorZ
markupsaferzr<>rrrr<00><module>
sh  



 



1
1
2 
3