� ���g�)��N�ddlmZddlZddlZddlZddlZddlZddlZddlm Z d�Z Gd�d��Z d�Z dd �Z Gd �d ��ZGd �d ��ZGd�de��ZGd�d��ZGd�de��Zejdej��Zd�Zd�Zd�Zdd�Zd�ZdS)�)�parseN�)�importlib_metadata_getc�,�||_|j|_|S�N)� __wrapped__�__name__)� decorated�fns �Y/home/asafur/pinokio/api/open-webui.git/app/env/lib/python3.11/site-packages/mako/util.py�update_wrapperr s���I����I�� ��c� �eZdZd�Zd�Zd�ZdS)� PluginLoaderc�"�||_i|_dSr)�group�impls)�selfrs r �__init__zPluginLoader.__init__s���� ��� � � rc��||jvr|j|��St|j��D]2}|j|kr%|j|j|<|���cS�3ddlm}|�d|j�d|�����)Nr)� exceptionszCan't load plugin � )rrr�name�load�makor�RuntimeException)rr�implrs r rzPluginLoader.loads��� �4�:� � �#�4�:�d�#�%�%� %�*�4�:�6�6� #� #�D��y�D� � �#'�9�� �4� ��y�y�{�{�"�"�"�!� $�#�#�#�#�#��)�)�)�)-����T�T� :� � � rc�*�����fd�}||j|<dS)Nc���t���}��d��dd�D]}t||��}�t|���S)N�.r)� __import__�split�getattr)�mod�token� modulepath�objnames ��r rz#PluginLoader.register.<locals>.load,sW����Z�(�(�C�#�)�)�#�.�.�q�r�r�2� *� *���c�5�)�)����3��(�(� (r)r)rrr&r'rs `` r �registerzPluginLoader.register+s6���� )� )� )� )� )� )�  �� �4���rN)r � __module__� __qualname__rrr(�rr rrsA���������  �  �  � � � � � rrc���d}tj�|��sK |dz }tj|d��n#|dkr�YnxYwtj�|���IdSdS)z,create and/or verify a filesystem directory.rri��N)�os�path�exists�makedirs)�dir_�triess r �verify_directoryr45s��� �E��g�n�n�T�"�"�� � �Q�J�E� �K��e� $� $� $� $�� ��q�y�y���y���� �g�n�n�T�"�"�����s �>� A c�L�|�|St|ttf��s|gS|Sr)� isinstance�list�tuple)�x�defaults r �to_listr;Cs.���y��� �a�$��� '� '���s� ��rc� �eZdZdZdd�Zd�ZdS)�memoized_propertyz2A read-only @property that is only evaluated once.Nc�H�||_|p|j|_|j|_dSr��fget�__doc__r �rr@�docs r rzmemoized_property.__init__P�$���� ��*�d�l�� �� �� � � rc�V�|�|S|�|��x|j|j<}|Sr)r@�__dict__r )r�obj�cls�results r �__get__zmemoized_property.__get__Us.�� �;��K�/3�y�y��~�~�=�� �T�]�#�f�� rr�r r)r*rArrJr+rr r=r=Ls=������<�<�&�&�&�&� ����rr=c� �eZdZdZdd�Zd�ZdS)�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. Nc�H�||_|p|j|_|j|_dSrr?rBs r rz memoized_instancemethod.__init__frDrc�N������S��fd�}�j|_�j|_|S)Nc�����j�g|�Ri|����fd�}�j|_�j|_|�j�j<�S)Nc����Srr+)�a�kwrIs �r �memoz>memoized_instancemethod.__get__.<locals>.oneshot.<locals>.memors���� r)r@r rArF)�argsrSrTrIrGrs @��r �oneshotz0memoized_instancemethod.__get__.<locals>.oneshotose�����T�Y�s�0�T�0�0�0�R�0�0�F� � � � � �!�M�D�M��<�D�L�*.�C�L��� '��Mr)r rA)rrGrHrVs`` r rJzmemoized_instancemethod.__get__ksF���� �;��K� � � � � � � �=����,����rrrKr+rr rMrM\sA��������&�&�&�&� ����rrMc��eZdZdZd�ZdS)� SetLikeDictz0a dictionary that has some setlike methods on itc�H�tdi|��}|�|��|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 firstr+)rX�update)r�otherr9s r �unionzSetLikeDict.union�s+�� � � �$� � �� ��������rN)r r)r*rAr\r+rr rXrXs)������:�:�����rrXc�&�eZdZdZdd�Zd�Zd�ZdS)�FastEncodingBufferzVa very rudimentary buffer that is faster than StringIO, and supports unicode data.N�strictc��tj��|_||_d|_||_|jj|_dS)N�)� collections�deque�data�encoding�delim�errors�append�write)rrergs r rzFastEncodingBuffer.__init__�s7���%�'�'�� � �� ��� ��� ��Y�%�� � � rc�X�tj��|_|jj|_dSr)rbrcrdrhri�rs r �truncatezFastEncodingBuffer.truncate�s"���%�'�'�� ��Y�%�� � � rc���|jr=|j�|j���|j|j��S|j�|j��Sr)rerf�joinrd�encodergrks r �getvaluezFastEncodingBuffer.getvalue�sU�� �=� .��:�?�?�4�9�-�-�4�4�� �t�{��� ��:�?�?�4�9�-�-� -r)Nr_)r r)r*rArrlrpr+rr r^r^�sP������"�"�&�&�&�&�&�&�&�.�.�.�.�.rr^c�R�eZdZdZGd�d��Zd d�Zd�Zd�Zd�Zd �Z d �Z d S) �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��eZdZd�Zd�ZdS)�LRUCache._Itemc�R�||_||_tj��|_dSr)�key�value�timeit� default_timer� timestamp�rrvrws r rzLRUCache._Item.__init__�s$���D�H��D�J�#�1�3�3�D�N�N�Nrc�*�t|j��Sr)�reprrwrks r �__repr__zLRUCache._Item.__repr__�s���� �#�#� #rN)r r)r*rr~r+rr �_Itemrt�s2������ 4� 4� 4�  $� $� $� $� $rr��?c�"�||_||_dSr)�capacity� threshold)rr�r�s r rzLRUCache.__init__�s�� �� �"����rc�v�t�||��}tj��|_|jSr)�dict� __getitem__rxryrzrw)rrv�items r r�zLRUCache.__getitem__�s/������c�*�*���-�/�/����z�rc�J�d�t�|��D��S)Nc��g|] }|j�� Sr+)rw)�.0�is r � <listcomp>z#LRUCache.values.<locals>.<listcomp>�s��3�3�3�A���3�3�3r)r��valuesrks r r�zLRUCache.values�s"��3�3����T�!2�!2�3�3�3�3rc�(�||vr||S|||<|Srr+r{s r � setdefaultzLRUCache.setdefault�s#�� �$�;�;���9� ���S� �� rc���t�||��}|�3|�||��}t�|||��n||_|���dSr)r��getr� __setitem__rw� _manage_size)rrvrwr�s r r�zLRUCache.__setitem__�sg���x�x��c�"�"�� �<��:�:�c�5�)�)�D� � � �T�3�� -� -� -� -��D�J� �������rc�z�t|��|j|j|jzzkr�tt�|��t jd��d���}||jd�D]} ||j=� #t$rYnwxYwt|��|j|j|jzzk��dSdS)NrzT)rv�reverse) �lenr�r��sortedr�r��operator� attrgetterrv�KeyError)r�bytimer�s r r�zLRUCache._manage_size�s����$�i�i�$�-�$�-�$�.�*H�H�H�H��� � �D�!�!��'� �4�4�����F� �t�}���/� � ����T�X���������E�E������$�i�i�$�-�$�-�$�.�*H�H�H�H�H�H�H�Hs�7B� B� BN)r�) r r)r*rArrr�r�r�r�r�r+rr rrrr�s���������$�$�$�$�$�$�$�$�#�#�#�#���� 4�4�4���� ��� � � � � rrrz([ \t\f]* \# .* coding[=:][ \t]*([-\w.]+)c�p�|���}|�d�� |���}|�tj��}|r!|t tj��d�}t�|� dd����}|s~ t|� dd����|���}t�|� dd����}n#ttf$rYnwxYw|r)|rtd��� |�|��dS|r*|� d��|�|��S |�|��dS#|�|��wxYw)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_UTF8r��_PYTHON_MAGIC_COMMENT_re�match�decoder� ImportError� SyntaxErrorr)�fp�pos�line1�has_bom�m�line2s r �parse_encodingr��s��� �'�'�)�)�C��G�G�A�J�J�J�"�� � � � ���"�"�6�?�3�3�� � 2��#�f�o�.�.�0�0�1�E� $� *� *�5�<�<���+J�+J� K� K��� � ��e�l�l�7�H�5�5�6�6�6�� � � � ��,�2�2��L�L��(�3�3������ ��-� � � � ��  ���� � �� �!�D����� ���� � � � � � � ��7�7�1�:�:� ���� � � � �� ���� � � � � ������ � � � ���s7�BF�2#D�AF�D,�)F�+D,�,F�F�F5c���t������}|���dd��fd�|D����zdzS)z{repr() a dictionary with the keys in order. Used by the lexer unit test to compare parse trees based on strings. �{z, c3�2�K�|]}|�d�|��V��dS)z: Nr+)r��k�ds �r � <genexpr>z#sorted_dict_repr.<locals>.<genexpr>"s2�����>�>�A�q�q�q�!�A�$�$�/�>�>�>�>�>�>r�})r7�keys�sortrn)r�r�s` r �sorted_dict_reprr�sV��� ������>�>�D��I�I�K�K�K� ����>�>�>�>��>�>�>�>�>� >�� D�Drc�~ �t|d��rdSd|_tddd|j��}t|��|_|jjD]'}|jdkr||_�|jdkr||_�(t|j d��|_ t|j d ��|_ t|j d ��|_ t|j d j d��|_t|j d j dj��|_t|j d j��|_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>�execr$rr���r-���� � � � )4�hasattr� PyCF_ONLY_AST�compile�type�Module�__mro__r r$r��body� FunctionDef�ClassDef�If�targets�Name�ctx�Storerw�Str�op�Sub�left�Add�right�Div�Mult�RShift�LShift�Mod�FloorDiv�BitOr�BitXor�BitAnd�Orr��And�Invert�Not�operand�UAdd�USub�ops�IsNot�NotEq�Is�Eq�Gt�Lt�GtE�LtE�In�NotIn)�_astr�rHs r � restore__astr�%s����t�U�������D��� � �� ��# � �A�&�q�'�'�D�K��{�"���� �<�5� � ��D�H�H� �\�U� "� "��D�H���A�F�1�I���D�������O�O�D�M��1�6�!�9�o�o�D�G��Q�V�A�Y�&�q�)�*�*�D�I��a�f�Q�i�'��*�.�/�/�D�J��A�F�1�I�O�$�$�D�H��A�F�1�I�O�&�'�'�D�H��A�F�1�I�O�(�+�,�,�D�H��A�F�1�I�O�)�,�-�-�D�H��Q�V�A�Y�_�*�/�2�3�3�D�I��q�v�a�y��)�*�*�D�K��q�v�a�y��+�.�/�/�D�K��A�F�1�I�O�(�-�0�1�1�D�H�������-�2�7�:�;�;�D�M��a�f�Q�i�o�(�)�)�D�J��q�v�a�y��+�.�/�/�D�K��q�v�a�y��+�0�3�4�4�D�K��1�6�!�9�?�%�&�&�D�G��A�F�1�I�O�*�1�-�0�1�1�D�H��q�v�a�y��,�/�0�0�D�K��A�F�1�I�O�(�.�1�2�2�D�H��Q�V�A�Y�_�)�/�7�:�;�;�D�I��Q�V�A�Y�_�)�.�1�2�2�D�I��1�6�!�9�?�%�&�&�D�G��A�F�1�I�O�*�1�-�0�1�1�D�H��a�f�R�j�&�*�1�-�.�.�D�J��a�f�R�j�&�*�1�-�.�.�D�J��1�6�"�:�#�(�,�Q�/�0�0�D�G��1�6�"�:�#�(�,�Q�/�0�0�D�G��1�6�"�:�#�'��*�+�+�D�G��1�6�"�:�#�'��*�+�+�D�G��A�F�2�J�$�(��+�,�,�D�H��A�F�2�J�$�(��+�,�,�D�H��1�6�"�:�#�'��*�+�+�D�G��a�f�R�j�&�*�1�-�.�.�D�J�J�Jr�rbc�~�t||��5}|���cddd��S#1swxYwYdSr)�open�read)r/�moder�s r � read_filer�vs~�� �d�D� � ��R��w�w�y�y���������������������s �2�6�6c���t|d��} t|��}|���}|r|�|��}||���S#|���wxYw)Nr�)r�r�r�r��close)r/r�rerds r �read_python_filer{sm�� �d�D� � �B��!�"�%�%���w�w�y�y�� � )��;�;�x�(�(�D�� ��� � � � ����� � � � ���s �;A"�"A8r)r�)�astrr�rbr�r.�rerx�compatrr rr4r;r=rMr�rXr^rrr��VERBOSEr�r�r�r�r�rr+rr �<module>rs �� ������ � � � ��������� � � � � � � � � � � � �*�*�*�*�*�*����  � � � � � � � �< � � ����� � � � � � � � � � � � � � � � �F � � � � �$� � � �.�.�.�.�.�.�.�.�2;�;�;�;�;�t�;�;�;�~&�2�:�/������ .�.�.�bE�E�E�N/�N/�N/�b���� � � � � r
Memory