HEX
Server: Apache/2.4.52 (Ubuntu)
System: Linux spn-python 5.15.0-89-generic #99-Ubuntu SMP Mon Oct 30 20:42:41 UTC 2023 x86_64
User: arjun (1000)
PHP: 8.1.2-1ubuntu2.20
Disabled: NONE
Upload Files
File: //home/arjun/projects/env/lib64/python3.10/site-packages/mako/__pycache__/util.cpython-310.pyc
o

%we�)�@s�ddlmZddlZddlZddlZddlZddlZddlZddlm	Z	dd�Z
Gdd�d�Zd	d
�Zd#dd�Z
Gd
d�d�ZGdd�d�ZGdd�de�ZGdd�d�ZGdd�de�Ze�dej�Zdd�Zdd�Zdd�Zd$dd �Zd!d"�ZdS)%�)�parseN�)�importlib_metadata_getcCs||_|j|_|S�N)�__wrapped__�__name__)�	decorated�fn�r
�B/home/arjun/projects/env/lib/python3.10/site-packages/mako/util.py�update_wrappersrc@s$eZdZdd�Zdd�Zdd�ZdS)�PluginLoadercCs||_i|_dSr)�group�impls)�selfrr
r
r�__init__�
zPluginLoader.__init__cCsh||jvr|j|�St|j�D]}|j|kr#|j|j|<|��Sqddlm}|�d|j|f��)Nr)�
exceptionszCan't load plugin %s %s)rrr�name�load�makor�RuntimeException)rr�implrr
r
rrs

��zPluginLoader.loadcs��fdd�}||j|<dS)Ncs4t��}��d�dd�D]}t||�}q
t|��S)N�.r)�
__import__�split�getattr)�mod�token��
modulepath�objnamer
rr,s
z#PluginLoader.register.<locals>.load)r)rrr r!rr
rr�register+szPluginLoader.registerN)r�
__module__�__qualname__rrr"r
r
r
rr
sr
cCsPd}tj�|�s&z|d7}t�|d�Wn	|dkr�Ytj�|�rdSdS)z,create and/or verify a filesystem directory.rri��N)�os�path�exists�makedirs)�dir_�triesr
r
r�verify_directory5s��r,cCs$|dur|St|ttf�s|gS|Sr)�
isinstance�list�tuple)�x�defaultr
r
r�to_listCs
r2c@�"eZdZdZddd�Zdd�ZdS)�memoized_propertyz2A read-only @property that is only evaluated once.NcC�||_|p|j|_|j|_dSr��fget�__doc__r�rr7�docr
r
rrP�zmemoized_property.__init__cCs&|dur|S|�|�|j|j<}|Sr)r7�__dict__r)r�obj�cls�resultr
r
r�__get__Uszmemoized_property.__get__r�rr#r$r8rr@r
r
r
rr4Ls
r4c@r3)�memoized_instancemethodz�Decorate a method memoize its return value.

    Best applied to no-arg methods: memoization is not sensitive to
    argument values, and will always return the same value even when
    called with different arguments.

    NcCr5rr6r9r
r
rrfr;z memoized_instancemethod.__init__cs.�dur�S��fdd�}�j|_�j|_|S)NcsD�j�g|�Ri|����fdd�}�j|_�j|_|�j�j<�S)Ncs�Srr
)�a�kw�r?r
r�memorsz>memoized_instancemethod.__get__.<locals>.oneshot.<locals>.memo)r7rr8r<)�argsrDrF�r=rrEr�oneshotosz0memoized_instancemethod.__get__.<locals>.oneshot)rr8)rr=r>rIr
rHrr@kszmemoized_instancemethod.__get__rrAr
r
r
rrB\s
rBc@seZdZdZdd�ZdS)�SetLikeDictz0a dictionary that has some setlike methods on itcCstdi|��}|�|�|S)z�produce a 'union' of this dict and another (at the key level).

        values in the second dict take precedence over that of the firstNr
)rJ�update)r�otherr0r
r
r�union�s
zSetLikeDict.unionN)rr#r$r8rMr
r
r
rrJsrJc@s*eZdZdZd
dd�Zdd�Zdd	�ZdS)�FastEncodingBufferzVa very rudimentary buffer that is faster than StringIO,
    and supports unicode data.N�strictcCs*t��|_||_d|_||_|jj|_dS)N�)�collections�deque�data�encoding�delim�errors�append�write)rrTrVr
r
rr�s

zFastEncodingBuffer.__init__cCst��|_|jj|_dSr)rQrRrSrWrX�rr
r
r�truncate�s
zFastEncodingBuffer.truncatecCs.|jr|j�|j��|j|j�S|j�|j�Sr)rTrU�joinrS�encoderVrYr
r
r�getvalue�s
�zFastEncodingBuffer.getvalue)NrO)rr#r$r8rrZr]r
r
r
rrN�s

rNc@sPeZdZdZGdd�d�Zddd�Zdd�Zd	d
�Zdd�Zd
d�Z	dd�Z
dS)�LRUCachea$A dictionary-like object that stores a limited number of items,
    discarding lesser used items periodically.

    this is a rewrite of LRUCache from Myghty to use a periodic timestamp-based
    paradigm so that synchronization is not really needed.  the size management
    is inexact.
    c@seZdZdd�Zdd�ZdS)zLRUCache._ItemcCs||_||_t��|_dSr)�key�value�timeit�
default_timer�	timestamp�rr_r`r
r
rr�szLRUCache._Item.__init__cCs
t|j�Sr)�reprr`rYr
r
r�__repr__�s
zLRUCache._Item.__repr__N)rr#r$rrfr
r
r
r�_Item�srg��?cCs||_||_dSr)�capacity�	threshold)rrirjr
r
rr�rzLRUCache.__init__cCst�||�}t��|_|jSr)�dict�__getitem__rarbrcr`)rr_�itemr
r
rrl�s
zLRUCache.__getitem__cCsdd�t�|�D�S)NcSsg|]}|j�qSr
)r`)�.0�ir
r
r�
<listcomp>�sz#LRUCache.values.<locals>.<listcomp>)rk�valuesrYr
r
rrq�szLRUCache.valuescCs||vr||S|||<|Srr
rdr
r
r�
setdefault�szLRUCache.setdefaultcCsBt�||�}|dur|�||�}t�|||�n||_|��dSr)rk�getrg�__setitem__r`�_manage_size)rr_r`rmr
r
rrt�szLRUCache.__setitem__c	Cs�t|�|j|j|jkrCtt�|�t�d�dd�}||jd�D]}z||j=Wq!t	y3Ynwt|�|j|j|jks
dSdS)NrcT)r_�reverse)
�lenrirj�sortedrkrq�operator�
attrgetterr_�KeyError)r�bytimermr
r
rru�s��"�zLRUCache._manage_sizeN)rh)rr#r$r8rgrrlrqrrrtrur
r
r
rr^�s
		r^z([ \t\f]* \# .* coding[=:][ \t]*([-\w.]+)c	Cs�|��}|�d�zh|��}|�tj�}|r|ttj�d�}t�|�	dd��}|sMz
t
|�	dd��Wnttfy?Ynw|��}t�|�	dd��}|r]|rUtd��W|�|�dS|rj|�
d�W|�|�SW|�|�dS|�|�w)aDeduce the encoding of a Python source file (binary mode) from magic
    comment.

    It does this in the same way as the `Python interpreter`__

    .. __: http://docs.python.org/ref/encodings.html

    The ``fp`` argument should be a seekable file object in binary mode.
    rN�ascii�ignorez\python refuses to compile code with both a UTF8 byte-order-mark and a magic encoding comment�utf_8r)�tell�seek�readline�
startswith�codecs�BOM_UTF8rw�_PYTHON_MAGIC_COMMENT_re�match�decoder�ImportError�SyntaxErrorr)�fp�pos�line1�has_bom�m�line2r
r
r�parse_encoding�s<

�
���
�r�cs4t����}|��dd��fdd�|D��dS)z{repr() a dictionary with the keys in order.

    Used by the lexer unit test to compare parse trees based on strings.

    �{z, c3s �|]}d|�|fVqdS)z%r: %rNr
)rn�k��dr
r�	<genexpr>"s�z#sorted_dict_repr.<locals>.<genexpr>�})r.�keys�sortr[)r�r�r
r�r�sorted_dict_reprs r�cCsxt|d�rdSd|_tddd|j�}t|�|_|jjD]}|jdkr&||_q|jdkr.||_qt|j	d�|_
t|j	d	�|_t|j	d
�|_t|j	dj
d�|_t|j	dj
dj�|_t|j	dj�|_t|j	djj�|_t|j	djjj�|_t|j	djjj�|_t|j	djjjj�|_t|j	d
jj�|_t|j	d
jjj�|_t|j	d
jjjj�|_t|j	d
jjjjj�|_t|j	djj�|_t|j	djjj�|_t|j	djjjj�|_ t|j	djj�|_!t|j	djj"dj�|_#t|j	djjj�|_$t|j	djjjj�|_%t|j	djjjj&j�|_'t|j	djjjj�|_(t|j	djj�|_!t|j	djj"dj�|_#t|j	djj)d�|_*t|j	djj)d	�|_+t|j	djjj)d�|_,t|j	djjj)d	�|_-t|j	djj)d�|_.t|j	djj)d	�|_/t|j	djj)d
�|_0t|j	djj)d�|_1t|j	djj)d�|_2t|j	djj)d	�|_3dS)zdAttempt to restore the required classes to the _ast module if it
    appears to be missing them
    �ASTNiadef foo(): pass
class Bar: pass
if False: pass
baz = 'mako'
1 + 2 - 3 * 4 / 5
6 // 7 % 8 << 9 >> 10
11 & 12 ^ 13 | 14
15 and 16 or 17
-baz + (not +18) - ~17
baz and 'foo' or 'bar'
(mako is baz == baz) is not baz != mako
mako > baz < mako >= baz <= mako
mako in baz not in makoz	<unknown>�execrrr���r%����	�
��)4�hasattr�
PyCF_ONLY_AST�compile�type�Module�__mro__rrr��body�FunctionDef�ClassDef�If�targets�Name�ctx�Storer`�Str�op�Sub�left�Add�right�Div�Mult�RShift�LShift�Mod�FloorDiv�BitOr�BitXor�BitAnd�Orrq�And�Invert�Not�operand�UAdd�USub�ops�IsNot�NotEq�Is�Eq�Gt�Lt�GtE�LtE�In�NotIn)�_astr�r>r
r
r�restore__ast%sf
�


�r��rbcCs6t||��}|��Wd�S1swYdSr)�open�read)r'�moder�r
r
r�	read_filevs$�r�cCsBt|d�}zt|�}|��}|r|�|�}|W|��S|��w)Nr�)r�r�r�r��close)r'r�rTrSr
r
r�read_python_file{s

r�r)r�)�astrr�rQryr&�rera�compatrrr
r,r2r4rBrkrJrNr^r��VERBOSEr�r�r�r�r�r�r
r
r
r�<module>s2
	#
?�1
Q