%PDF- %PDF-
Mini Shell

Mini Shell

Direktori : /opt/alt/python37/lib/python3.7/site-packages/jinja2/__pycache__/
Upload File :
Create Path :
Current File : //opt/alt/python37/lib/python3.7/site-packages/jinja2/__pycache__/utils.cpython-37.pyc

B

��R%?�	@s�dZddlZddlZddlmZddlmZmZmZm	Z	m
Z
e�d�Ze�dd�
eejd��d�
eejd	��f�Ze�d
�Ze�d�Ze�d�Zd
ZdZeddddd�i��Ze�Zdj
Zdd�Zdd�Zdd�Zdd�Zdd�Zdd �Z d!d"�Z!d@d$d%�Z"dAd'd(�Z#d)d*�Z$dBd+d,�Z%dCd-d.�Z&dDd3d4�Z'dEd6d7�Z(Gd8d9�d9e)�Z*ydd:lm+Z+e+�,e*�Wne-k
�rxYnXeGd;d<�d<e)��Z.Gd=d>�d>e)�Z/dd?l0m1Z1mZm2Z2dS)Fz�
    jinja2.utils
    ~~~~~~~~~~~~

    Utility functions.

    :copyright: (c) 2010 by the Jinja Team.
    :license: BSD, see LICENSE for more details.
�N)�deque)�	text_type�string_types�implements_iterator�
allocate_lock�	url_quotez(\s+)z4^(?P<lead>(?:%s)*)(?P<middle>.*?)(?P<trail>(?:%s)*)$�|)�(�<z&lt;)�.�,�)�>�
z&gt;z&^\S+@[a-zA-Z0-9._-]+\.[a-zA-Z0-9._-]+$z(<!--.*?-->|<[^>]*>)z	&([^;]+);Z4abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ�
0123456789ZMissingType��__repr__cCsdS)N�missingr)�xrr�=/opt/alt/python37/lib/python3.7/site-packages/jinja2/utils.py�<lambda> �r�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)�contextfunction)�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)�evalcontextfunction)rrrrr8s	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)�environmentfunction)rrrrrEsrcCst�|j�|S)z%Marks the function as internally used)�
internal_code�add�__code__)rrrr�internalcodeOsr cCsddlm}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
    r)�	Undefined)Zjinja2.runtimer!�
isinstance)�objr!rrr�is_undefinedUsr$cCsx|D]}qWdS)z4Consumes an iterable without doing anything with it.Nr)�iterableZeventrrr�consumees
r&cCs,ddlm}ddlm}|��|��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
    messuring memory consumption you may want to clean the caches.
    r)�_spontaneous_environments)�_lexer_cacheN)Zjinja2.environmentr'Zjinja2.lexerr(�clear)r'r(rrr�clear_cachesksr*Fc	Cs�yfd|kr|�dd�\}}n6d|krJ|�d�}d�|dd��}|d}nt|�Stt|dd|g�|�Sttfk
r�|s��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
    �:�rN���)�split�join�
__import__�getattr�ImportError�AttributeError)Zimport_nameZsilent�moduler#�itemsrrr�
import_stringws

r6�rbc
CsFy
t||�Stk
r@}z|jtjtjfkr0�Wdd}~XYnXdS)zZReturns a file descriptor for the filename if that file exists,
    otherwise `None`.
    N)�open�IOError�errnoZENOENTZEISDIR)�filename�mode�errr�open_if_exists�s

r>cCsJ|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�Ellipsis)Z__builtin__�builtinsrz	%s object)r@�	__class__�
__module__�__name__)r#�namerrr�object_type_repr�s
rFcCsByddlm}|||d�Stk
r<ddlm}||�SXdS)zYPrettyprint an object.  Either use the `pretty` library or the
    builtin `pprint`.
    r)�pretty)�verbose)�pformatN)rGr2ZpprintrI)r#rHrGrIrrrrI�srIcCsZ|fdd�}t�tt|���}|r&dp(d}�x"t|�D�]\}}t�|�}|r6|��\}	}
}|
�d�s�d|
kr�|
�d�s�|
�d�s�t	|
�d	kr�|
d	t
tkr�|
�d
�s�|
�d�s�|
�d�r�d
|
|||
�f}
|
�d�s�|
�d�r�d|
|||
�f}
d|
k�r,|
�d��s,d|
k�r,t
�|
��r,d|
|
f}
|	|
||kr6|	|
|||<q6Wd�|�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.
    cSs,|dk	r(|d|�t|�|kr"dp$dp*|S)Nz...r)�len)r�limitrrrr�szurlize.<locals>.<lambda>z rel="nofollow"rzwww.�@zhttp://zhttps://rz.orgz.netz.comz<a href="http://%s"%s>%s</a>z<a href="%s"%s>%s</a>r+z<a href="mailto:%s">%s</a>)�_word_split_rer.r�escape�	enumerate�_punctuation_re�match�groups�
startswithrJ�_letters�_digits�endswith�_simple_email_rer/)�textZtrim_url_limitZnofollowZtrim_url�wordsZ
nofollow_attr�i�wordrQZleadZmiddle�trailrrr�urlize�s8








r]�T��dcCsfddlm}ddlm}m}|��}g}�xt|�D�]}	d}
d}}d}
d}g}x�tt|||���D]�\}}	x||�}
|
|krp|
}PqpW|
r�|
��}
d}
||dd�|kr�|}|d	7}|
d
7}
||dd�|kr�|}}|
d
7}
d}
|�	|
�qfWd�
|�}|�d
��r|dd�d
}n|�d
��s0|d
7}|�	|�q4W|�sNd�
|�Std�
dd�|D���S)z,Generate some lorem impsum for the template.r)�LOREM_IPSUM_WORDS)�choice�	randrangeTNF���r�
r_r� r-z

rcss|]}dt|�VqdS)z	<p>%s</p>N)rN)�.0rrrr�	<genexpr>sz'generate_lorem_ipsum.<locals>.<genexpr>)
Zjinja2.constantsraZrandomrbrcr.�rangerO�
capitalize�appendr/rV�Markup)�nZhtml�min�maxrarbrcrY�result�_Znext_capitalizedZ
last_commaZ
last_fullstopr[Zlast�p�idxrrr�generate_lorem_ipsum�sJ

rv�utf-8cCs2t|t�st|�}t|t�r&|�|�}tt|��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.
    )r"rr�encoder)r#�charsetrrr�unicode_urlencodes



rzc@s�eZdZdZdd�Zdd�Zdd�Zdd	�Zd
d�Zdd
�Z	d/dd�Z
d0dd�Zdd�Zdd�Z
dd�Zdd�Zdd�Zdd�Zdd �Zd!d"�Zd#d$�Zd%d&�Zd'd(�Zd)d*�Zd+d,�ZeZd-d.�Ze	ZdS)1�LRUCachez"A simple LRU Cache implementation.cCs ||_i|_t�|_|��dS)N)�capacity�_mappingr�_queue�	_postinit)�selfr|rrr�__init__-szLRUCache.__init__cCs4|jj|_|jj|_|jj|_t�|_|jj	|_
dS)N)r~�popleft�_popleft�popZ_pop�remove�_remover�_wlockrm�_append)r�rrrr3s



zLRUCache._postinitcCs|j|j|jd�S)N)r|r}r~)r|r}r~)r�rrr�__getstate__;szLRUCache.__getstate__cCs|j�|�|��dS)N)�__dict__�updater)r��drrr�__setstate__BszLRUCache.__setstate__cCs|jfS)N)r|)r�rrr�__getnewargs__FszLRUCache.__getnewargs__cCs*|�|j�}|j�|j�t|j�|_|S)z&Return a shallow copy of the instance.)rBr|r}r�rr~)r��rvrrr�copyIsz
LRUCache.copyNcCs"y||Stk
r|SXdS)z/Return an item from the cache dict or `default`N)�KeyError)r��key�defaultrrr�getPszLRUCache.getcCsF|j��z*y||Stk
r0|||<|SXWd|j��XdS)zvSet `default` if the key is not in the cache otherwise
        leave unchanged. Return the value of this key.
        N)r��acquirer��release)r�r�r�rrr�
setdefaultWs

zLRUCache.setdefaultcCs4|j��z|j��|j��Wd|j��XdS)zClear the cache.N)r�r�r}r)r~r�)r�rrrr)es


zLRUCache.clearcCs
||jkS)z$Check if a key exists in this cache.)r})r�r�rrr�__contains__nszLRUCache.__contains__cCs
t|j�S)z%Return the current size of the cache.)rJr})r�rrr�__len__rszLRUCache.__len__cCsd|jj|jfS)Nz<%s %r>)rBrDr})r�rrrrvszLRUCache.__repr__cCsf|j��zJ|j|}|jd|krRy|�|�Wntk
rFYnX|�|�|S|j��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.
        r-N)r�r�r}r~r��
ValueErrorr�r�)r�r�r�rrr�__getitem__|s


zLRUCache.__getitem__cCsf|j��zJ||jkr"|�|�nt|j�|jkr>|j|��=|�|�||j|<Wd|j��XdS)zhSets the value for an item. Moves the item up so that it
        has the highest priority then.
        N)	r�r�r}r�rJr|r�r�r�)r�r��valuerrr�__setitem__�s


zLRUCache.__setitem__cCsL|j��z0|j|=y|�|�Wntk
r6YnXWd|j��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�__delitem__�s

zLRUCache.__delitem__cs$�fdd�t�j�D�}|��|S)zReturn a list of items.csg|]}|�j|f�qSr)r})rir�)r�rr�
<listcomp>�sz"LRUCache.items.<locals>.<listcomp>)�listr~�reverse)r�rrr)r�rr5�szLRUCache.itemscCst|���S)zIterate over all items.)�iterr5)r�rrr�	iteritems�szLRUCache.iteritemscCsdd�|��D�S)zReturn a list of all values.cSsg|]}|d�qS)r,r)rirrrrr��sz#LRUCache.values.<locals>.<listcomp>)r5)r�rrr�values�szLRUCache.valuescCst|���S)zIterate over all values.)r�r�)r�rrr�	itervalue�szLRUCache.itervaluecCst|�S)z7Return a list of all keys ordered by most recent usage.)r�)r�rrr�keys�sz
LRUCache.keyscCstt|j��S)z[Iterate over all keys in the cache dict, ordered by
        the most recent usage.
        )�reversed�tupler~)r�rrr�iterkeys�szLRUCache.iterkeyscCstt|j��S)zVIterate over the values in the cache dict, oldest items
        coming first.
        )r�r�r~)r�rrr�__reversed__�szLRUCache.__reversed__)N)N)rDrC�__qualname__�__doc__r�rr�r�r�r�r�r�r)r�r�rr�r�r�r5r�r�r�r�r��__iter__r��__copy__rrrrr{&s2

	r{)�MutableMappingc@s4eZdZdZdd�Zdd�Zedd��Zdd	�Zd
S)�CyclerzA cycle helper for templates.cGs|std��||_|��dS)Nz$at least one item has to be provided)�RuntimeErrorr5�reset)r�r5rrrr��szCycler.__init__cCs
d|_dS)zResets the cycle.rN)�pos)r�rrrr��szCycler.resetcCs|j|jS)zReturns the current item.)r5r�)r�rrr�current�szCycler.currentcCs |j}|jdt|j�|_|S)z#Goes one item ahead and returns it.r,)r�r�rJr5)r�r�rrr�__next__�szCycler.__next__N)	rDrCr�r�r�r��propertyr�r�rrrrr��s
r�c@s"eZdZdZddd�Zdd�ZdS)	�JoinerzA joining helper for templates.�, cCs||_d|_dS)NF)�sep�used)r�r�rrrr��szJoiner.__init__cCs|jsd|_dS|jS)NTr)r�r�)r�rrr�__call__szJoiner.__call__N)r�)rDrCr�r�r�r�rrrrr��s
r�)rnrN�soft_unicode)F)r7)F)NF)r^Tr_r`)rw)3r��rer:�collectionsrZjinja2._compatrrrrr�compilerMr/�maprNrPrWZ
_striptags_reZ
_entity_rerTrU�typer�setr�concatrrrr r$r&r*r6r>rFrIr]rvrz�objectr{r��registerr2r�r�Z
markupsafernr�rrrr�<module>
sT









-
1
3

Zerion Mini Shell 1.0