� ���g����dZddlZddlmZddlmZGd�d��ZGd�d��ZGd �d e��ZGd �d ��ZGd �de��Z dS)zjutilities for analyzing expressions and blocks of Python code, as well as generating Python from AST nodes�N)� exceptions)�pyparserc��eZdZdZd�ZdS)� PythonCodez<represents information about a string containing Python codec �(�||_t��|_t��|_t |t ��r&t j|���dfi|��}n|}t j |fi|��}|� |��dS)N�exec) �code�set�declared_identifiers�undeclared_identifiers� isinstance�strr�parse�lstrip�FindIdentifiers�visit��selfr �exception_kwargs�expr�fs �X/home/asafur/pinokio/api/open-webui.git/app/env/lib/python3.11/site-packages/mako/ast.py�__init__zPythonCode.__init__s����� �%(�E�E��!�'*�e�e��#� �d�C� � � ��>�$�+�+�-�-��L�L�;K�L�L�D�D��D� � $�T� >� >�-=� >� >�� ���� � � � � �N��__name__� __module__� __qualname__�__doc__r�rrrrs)������F�F�����rrc��eZdZdZd�ZdS)� ArgumentListzBparses a fragment of code as a comma-separated list of expressionsc �|�g|_g|_t��|_t��|_t |t ��rCtjd|��rtjd|��s|dz }tj |dfi|��}n|}tj |tfi|��}|� |��dS)Nz\Sz,\s*$�,r)�codeargs�argsr r r r r�re�matchrr� FindTuplerrrs rrzArgumentList.__init__6s����� ��� �$'�E�E��!�&)�e�e��#� �d�C� � � ��x��t�$�$� �R�X�h��-E�-E� ��� ���>�$��C�C�2B�C�C�D�D��D� � �t�Z� D� D�3C� D� D�� ���� � � � � rNrr rrr"r"2s)������L�L�����rr"c�"��eZdZdZ�fd�Z�xZS)�PythonFragmentz�extends PythonCode to provide identifier lookups in partial control statements e.g.:: for x in 5: elif y==9: except (MyException, e): c � ��tjd|���tj��}|st jd|zfi|���|�d��r|d|�d���}|�dd��\}}|dvr|dz}nI|dkr|d z}n=|d vr d |zdz}n0|d kr d |zdz}n!|dkr|dz}nt jd|zfi|���t��j |fi|��dS)Nz^(\w+)(?:\s+(.*?))?:\s*(#|$)z0Fragment '%s' is not a partial control statement���)�for�if�while�pass�tryzpass except:pass)�elif�elsezif False:pass �exceptz try:pass �withz!Unsupported control keyword: '%s') r'r(�strip�Sr�CompileException�group�start�superr)rr r�m�keywordr� __class__s �rrzPythonFragment.__init__Usd��� �H�4�d�j�j�l�l�B�D� I� I��� ��-�B�T�I���"��� � �7�7�1�:�:� &�� �!�'�'�!�*�*� �%�D��'�'�!�Q�-�-���$� �,� ,� ,��&�=�D�D� �� � ��-�-�D�D� �(� (� (�$�t�+�f�4�D�D� �� � ��$�&��/�D�D� �� � ��&�=�D�D��-�3�g�=���"��� � ������2�2�!1�2�2�2�2�2r�rrrrr� __classcell__�rAs@rr+r+HsB������� � �3�3�3�3�3�3�3�3�3rr+c�8�eZdZdZdd�Zd d�Zed���ZdS) � FunctionDeclzfunction declarationTc �(�||_tj|dfi|��}tj|fi|��}|�|��t |d��st jd|zfi|���|s'|jr"t jd|j dzfi|���dSdS)Nr�funcnamez'Code '%s' is not a function declarationz('**%s' keyword argument not allowed here�����) r rr� ParseFuncr�hasattrrr;�kwargs� kwargnames)rr � allow_kwargsrrrs rrzFunctionDecl.__init__us����� ��~�d�F�?�?�.>�?�?�� � �t� 8� 8�'7� 8� 8�� ���� � � ��t�Z�(�(� ��-�9�D�@���"��� �� �� � ��-�:��/�"�%�&���#��� � � � � rFc��g}|jddd�}|jddd�}|jddd�}|jddd�}|jr+|�d|�d��z��|D]�}|r|�|�d|�����|rl|�d��}|�|�|���N|�|�dtj|��� ��������|�|����|j r+|�d|�d��z��|D]o}|s|s|�|���|�d��}|�|�dtj|��� �������p|� ��|S)aEReturn the argument declarations of this FunctionDecl as a printable list. By default the return value is appropriate for writing in a ``def``; set `as_call` to true to build arguments to be passed to the function instead (assuming locals with the same names as the arguments exist). NrIz**r�=�*) �argnamesrM�defaults� kwdefaultsrL�append�popr�ExpressionGenerator�value�varargs�reverse) r�as_call� namedeclsrRrMrSrT�name�defaults r�get_argument_expressionsz%FunctionDecl.get_argument_expressions�s(��� ��=���2��&���_�T�T�r�T�*� ��=���2��&���_�T�T�r�T�*� � �;� 7� � � �T�J�N�N�1�$5�$5�5� 6� 6� 6�� '� '�D�� '�� � �D�D�D�$�$�!7�8�8�8�8�� '�$�.�.��+�+���?��$�$�T�*�*�*�*��$�$��4�4��!=�g�!F�!F�!L�!L�!N�!N�!N�P����� � � ��&�&�&�&� �<� 4� � � �S�8�<�<��?�?�2� 3� 3� 3�� � �D�� �h� �� � ��&�&�&�&�"�,�,�q�/�/��� � ��t�t�X�9�'�B�B�H�H�J�J�J�L����� �������rc�T�t|j��t|j��zS)N)�tuplerRrM)rs r� allargnameszFunctionDecl.allargnames�s!���T�]�#�#�e�D�O�&<�&<�<�<rN)T)F)rrrrrr_�propertyrbr rrrFrFqs^������������$7�7�7�7�r�=�=��X�=�=�=rrFc�"��eZdZdZ�fd�Z�xZS)� FunctionArgsz.the argument portion of a function declarationc �B��t��jd|zfi|��dS)Nzdef ANON(%s):pass)r>r)rr rLrAs �rrzFunctionArgs.__init__�s.��������,�t�3�>�>�v�>�>�>�>�>rrBrDs@rrere�s>�������8�8�?�?�?�?�?�?�?�?�?rre) rr'�makorrrr"r+rFrer rr�<module>rhs��5�5� � � � ���������������������D��������,&3�&3�&3�&3�&3�Z�&3�&3�&3�RQ=�Q=�Q=�Q=�Q=�Q=�Q=�Q=�h?�?�?�?�?�<�?�?�?�?�?r
Memory