� c��j�����dZddlZddlZddl�ddlmZmZddlmZm Z m Z dPddd�d�Z d �Z dQdd �d �Z d �Zd �ZdRd�Zd�Zd�ZdSd�Zej(d�ZdTd�Zd�Zdd�d�Zd�ZGd�de�ZGd�de�ZdZdZee d�s(d �Z!d!�Z"d"�Z#d#�Z$e%e!e"�e _&e%e#e$�e _'Gd$�d%e(�Z)d&�Z*Gd'�d(e e)�)�Z+Gd*�d+e e)�)�Z,Gd,�d-e e)�)�Z-Gd.�d/e e)�)�Z.Gd0�d1e e)�)�Z/e/Z0e+e1e2e3fe,e4fe-e5fe.e(d�e6fe/e(d2�fiZ7e+e6fiZ8e6d/e(d�d/e1d(e2d(e3d(e4d+e5d-e(d2�d1iZ9Gd3�d4e:�Z;Gd5�d6e;�Z<Gd7�d8e;�Z=ee>d9�sd:�Z?d;�Z@e%e?e@�e>_AGd<�d=eB�ZCGd>�d?eD�ZEGd@�dAeD�ZFGdB�dCeD�ZGdDeHej�j�dz�zZKe e�GdE�dF��ZLdGZMdHZNgeM�eN��ZOGdI�dJe�ZPdK�ZQdLD�cic]}|eR�j�|���c}ZTdM�ZUdN�ZVeWdOk(reV�yycc}w)UaH ast ~~~ The `ast` module helps Python applications to process trees of the Python abstract syntax grammar. The abstract syntax itself might change with each Python release; this module helps to find out programmatically what the current grammar looks like and allows modifications of it. An abstract syntax tree can be generated by passing `ast.PyCF_ONLY_AST` as a flag to the `compile()` builtin function or by using the `parse()` function from this module. The result will be a tree of objects whose classes all inherit from `ast.AST`. A modified abstract syntax tree can be compiled into a Python code object using the built-in `compile()` function. Additionally various helper functions are provided that make working with the trees simpler. The main intention of the helper functions and this module in general is to provide an easy to use interface for libraries that work tightly with the python syntax (template engines for example). :copyright: Copyright 2008 by Armin Ronacher. :license: Python License. �N)�*)�contextmanager� nullcontext)�IntEnum�auto� _simple_enumF)� type_comments�feature_versionc��t}|r |tz}|�d}n*t|t�r|\}}|dk7rt d|����|}t |||||��S)z� Parse the source into an AST node. Equivalent to compile(source, filename, mode, PyCF_ONLY_AST). Pass type_comments=True to get back type comments where the syntax allows. ������zUnsupported major version: )�_feature_version)� PyCF_ONLY_AST�PyCF_TYPE_COMMENTS� isinstance�tuple� ValueError�compile)�source�filename�moder r �flags�major�minors �/usr/lib64/python3.12/ast.py�parser"sl�� �E�� �#�#������ �O�U� +�&� ��u� �A�:��:�5�'�B�C� C��� �6�8�T�5�$3� 5�5�c�������t|t�rt|jd�d��}t|t�r |j }d���fd���fd������fd���|�S)aT Evaluate an expression node or a string containing only a Python expression. The string or node provided may only consist of the following Python literal structures: strings, bytes, numbers, tuples, lists, dicts, sets, booleans, and None. Caution: A complex expression can overflow the C stack and cause a crash. z �eval�rc�V�d}t|dd�x}r|d|��z }t|d|��z��)Nzmalformed node or string�linenoz on line �: )�getattrr)�node�msg�lnos r�_raise_malformed_nodez+literal_eval.._raise_malformed_nodeEsB��(���$��$�/� /�3� /� �Y�s�e�$� $�C����D�8�}�,�-�-rc���t|t�r&t|j�tt t fvr�|�|jS�N)r�Constant�type�value�int�float�complex)r%r(s �r� _convert_numz"literal_eval.._convert_numJs7����$��)�T�$�*�*�-=�c�5�RY�EZ�-Z� !�$� '��z�z�rc����t|t�rRt|jttf�r2�|j �}t|jt�r|�S| S�|�Sr*)r�UnaryOp�op�UAdd�USub�operand)r%r7r1s �r�_convert_signed_numz)literal_eval.._convert_signed_numNsU��� �d�G� $��D�G�G�d�D�\�)J�"�4�<�<�0�G��$�'�'�4�(� �y� � �y� ��D�!�!rc �|��t|t�r |jSt|t�rt t �|j ��St|t�rtt �|j ��St|t�rtt �|j ��St|t�r]t|jt�rC|jjdk(r*|j|j cxk(rgk(r t�St|t"�rpt%|j&�t%|j(�k7r�|�t+t-t �|j&�t �|j(���St|t.�r�t|j0t2t4f�rn�|j6�}�|j8�}t|t:t<f�r4t|t>�r$t|j0t2�r||zS||z S�|�S)N�set) rr+r-�Tupler�map�elts�List�list�Setr:�Call�func�Name�id�args�keywords�Dict�len�keys�values�dict�zip�BinOpr4�Add�Sub�left�rightr.r/r0)r%rPrQ�_convertr1r8r(s ����rrRzliteral_eval.._convertVs���� �d�H� %��:�:� � ��e� $���X�t�y�y�1�2� 2� ��d� #���H�d�i�i�0�1� 1� ��c� "��s�8�T�Y�Y�/�0� 0���t�$��D�I�I�t�)D��i�i�l�l�e�#�� � �T�]�]�(H�b�(H��5�L�)I� ��d� #��4�9�9�~��T�[�[�!1�1�%�d�+���C��$�)�)�4���$�+�+�6�8�9� 9� ��e� $��D�G�G�c�3�Z�)H�&�t�y�y�1�D� ����,�E��$��e� �-�*�U�G�2L��d�g�g�s�+��%�<�'��%�<�'�"�4�(�(r)r�strr�lstrip� Expression�body)�node_or_stringrRr1r8r(s @@@@r� literal_evalrX8s\����.�#�&��~�4�4�U�;�&�I���.�*�-�'�,�,��.� �"�)�4 �N� #�#r)�indentc�������d����fd� �t|t�s"td|jjz����t�t �sd�z��|�dS)a� Return a formatted dump of the tree in node. This is mainly useful for debugging purposes. If annotate_fields is true (by default), the returned string will show the names and the values for fields. If annotate_fields is false, the result string will be more compact by omitting unambiguous field names. Attributes such as line numbers and column offsets are not dumped by default. If this is wanted, include_attributes can be set to true. If indent is a non-negative integer or string, then the tree will be pretty-printed with that indent level. None (the default) selects the single line representation. rc��������dz �d��zz}d��zz}nd}d}t|t��rNt|�}g}d}� }|jD]]} t ||�} | �t ||d��d}�"� | ��\} } |xr| }|r|j |�d| ����M|j | ��_� rb|jrV|jD]G} t ||�} | �t ||d��� � | ��\} } |xr| }|j |�d| ����I|rz(dump.._format..�s�����/S�d����5�0A�!�0D�d�s��])r�ASTr,�_fieldsr$�AttributeError�append� _attributesrH� __class__�__name__�joinr?�repr)r%rj�prefix�sep�clsrE� allsimplerF�namer-�simpleri�annotate_fields�include_attributesrYs ` ����rrizdump.._formats ��� � � �Q�J�E��F�U�N�*�F��&�5�.�(�C��F��C� �d�C� ��t�*�C��D��I�&�H�� � ���#�D�$�/�E��=�W�S�$��%<�%D�#�H�� '��u� 5� ��v�%�0�&� ���K�K�4�� 7�8��K�K��&�%�"�d�&6�&6� �,�,�D�!� '��d� 3���}���d�C�)@�)H� �$+�E�5�$9�M�E�6� )� 4�f�I��K�K�4�� 7�8�-��S��Y�!�^�#'�>�>�#:�#:�D�I�I�d�O�L�RV�h�V�V�!%���!8�!8�&�#�(�(�4�.�Q�SX�X� X� ��d� #��!��%�s�x�x�/S�d�/S�'S�T�V[�[� [��D�z�4����=&��#�H���� *�!� �!�s$� G� G� G�G� G �G zexpected AST, got %r� )r)rrm� TypeErrorrrrsrS)r%r|r}rYris ```@r�dumpr�ss\���. �. �` �d�C� ��.����1H�1H�H�I�I� ��*�V�S�"9��v��� �4�=�� �rc���dD][}||jvs�||jvs�!t||d�}|�t||�s�=|jd�s�Ot |||��]|S)z� Copy source location (`lineno`, `col_offset`, `end_lineno`, and `end_col_offset` attributes) from *old_node* to *new_node* if possible, and return *new_node*. )r"� col_offset� end_lineno�end_col_offsetN�end_)rqr$�hasattr� startswith�setattr)�new_node�old_node�attrr-s r� copy_locationr��si�� G�� �8�'�'� '�D�H�4H�4H�,H��H�d�D�1�E�� ���$�'�D�O�O�F�,C���$��.�G� �Orc�*���fd���|dddd�|S)a{ When you compile a node tree with compile(), the compiler expects lineno and col_offset attributes for every node that supports them. This is rather tedious to fill in for generated nodes, so this helper adds these attributes recursively where not already set, by setting them to the values of the parent node. It works recursively starting at *node*. c���d|jvr t|d�s||_n |j}d|jvr!t|dd��||_n |j}d|jvr t|d�s||_n |j }d|jvr!t|dd��||_n |j }t|�D]}�|||||��y)Nr"r�r�r�)rqr�r"r$r�r�r��iter_child_nodes)r%r"r�r�r��child�_fixs �rr�z#fix_missing_locations.._fix�s���� �t�'�'� '��4��*�$�� ����� �4�+�+� +��t�\�4�0�8�",���!�_�_� � �4�+�+� +��4��.�",���!�_�_� � �t�/�/� /��t�-�t�4�<�&4��#�!%�!4�!4��%�d�+�E� ��� �J�� G�,rr\rrf)r%r�s @r�fix_missing_locationsr��s ���H�. ��q�!�Q��� �Krr\c� �t|�D]t}t|t�rt|dd�|z|_�)d|j vrt|dd�|z|_d|j vs�[t|dd�x}��k||z|_�v|S)z� Increment the line number and end line number of each node in the tree starting at *node* by *n*. This is useful to "move code" to a different location in a file. r"rr�)�walkr� TypeIgnorer$r"rqr�)r%�nr�r�s r�increment_linenor��s��� �d��� �e�Z� (�"�5�(�A�6��:�E�L� � �u�(�(� (�"�5�(�A�6��:�E�L� �E�-�-� -�&�u�l�A�>�>��K�)�A�~�E� �� �Krc#�nK�|jD]} |t||�f���y#t$rY�"wxYw�w)zs Yield a tuple of ``(fieldname, value)`` for each field in ``node._fields`` that is present on *node*. N)rnr$ro)r%�fields r� iter_fieldsr�s@���� ���� ����u�-�-� -���� � � �s�5�&�5� 2�5�2�5c#�K�t|�D]G\}}t|t�r|���t|t�s�,|D]}t|t�s�|����Iy�w)z� Yield all direct child nodes of *node*, that is, all fields that are nodes and all items of fields that are lists of nodes. N)r�rrmr?)r%rzr��items rr�r� sM���� #�4�(� ��e� �e�S� !��K� ��t� $����d�C�(��J�� )�s�7A�A� Ac��t|ttttf�s"t d|j jz��|jrt|jdt�sy|jdj}t|t�r't|jt�r |j}ny|rddl }|j|�}|S)aC Return the docstring for the given node or None if no docstring can be found. If the node provided does not have docstrings a TypeError will be raised. If *clean* is `True`, all tabs are expanded to spaces and any whitespace that can be uniformly removed from the second line onwards is removed. z%r can't have docstringsrN)r�AsyncFunctionDef� FunctionDef�ClassDef�ModulerrrrsrV�Exprr-r+rS�inspect�cleandoc)r%�clean�textr�s r� get_docstringr�s��� �d�-�{�H�f�M� N��2�T�^�^�5L�5L�L�M�M� �9�9��D�I�I�a�L�$�7�� �9�9�Q�<� � �D��$��!�j����S�&A��z�z��� ������%�� �Krz(.*?(?:\r\n|\n|\r|$))c��g}ttj|�d�D]#\}}|�||kDr|S|j|d��%|S)z}Split a string into lines ignoring form feed and other chars. This mimics how the Python parser splits source code. r\r)� enumerate� _line_pattern�finditerrp)r�maxlines�linesr"�matchs r�_splitlines_no_ffr�4sX�� �E�"�=�#9�#9�&�#A�1�E� ��� � �F�X�$5� � �L� � � �U�1�X��F� �Lrc�6�d}|D]}|dvr||z }� |dz }�|S)z6Replace all chars except '\f\t' in a line with spaces.r^z r~rf)r�result�cs r�_pad_whitespacer�As1�� �F� �� ��;� �a�K�F� �c�M�F� � �Mr)�paddedc�� |j� |j�y|jdz }|jdz }|j}|j}t ||dz��}||k(r$||j �||j�S|r.t||j �d|j��}nd}|||j �|dj�z} ||j �d|j�} ||dz|}|jd| �|j| �dj|�S#t$rYywxYw)aBGet source code segment of the *source* that generated *node*. If some location information (`lineno`, `end_lineno`, `col_offset`, or `end_col_offset`) is missing, return None. If *padded* is `True`, the first line of a multi-line statement will be padded with spaces to match its original position. Nr\)r�r^r) r�r�r"r�ror��encode�decoder��insertrprt) rr%r�r"r�r�r�r��padding�first�lasts r�get_source_segmentr�LsP��� �?�?� "�d�&9�&9�&A�����q����_�_�q�(� ��_�_� ��,�,�� �f�z�!�|� <�E��V���V�}�#�#�%�j��@�G�G�I�I� �!�%��-�"6�"6�"8��*�"E�"L�"L�"N�O���� �e�F�m�*�*�,�Z�[�9�@�@�B� B�E� �� � #� #� %�o�~� 6� =� =� ?�D� �&��(�:� &�E� �L�L��E�� �L�L��� �7�7�5�>���% ����s�E�6E� E�Ec#�K�ddlm}||g�}|r2|j�}|jt |��|��|r�1yy�w)z� Recursively yield all descendant nodes in the tree starting at *node* (including *node* itself), in no specified order. This is useful if you only want to modify nodes in place and don't care about the context. r)�dequeN)� collectionsr��popleft�extendr�)r%r��todos rr�r�qs@���� "� �$��=�D� ��|�|�~�� � � �$�T�*�+�� � �s �AA�Ac�"�eZdZdZd�Zd�Zd�Zy)� NodeVisitora< A node visitor base class that walks the abstract syntax tree and calls a visitor function for every node found. This function may return a value which is forwarded by the `visit` method. This class is meant to be subclassed, with the subclass adding visitor methods. Per default the visitor functions for the nodes are ``'visit_'`` + class name of the node. So a `TryFinally` node visit function would be `visit_TryFinally`. This behavior can be changed by overriding the `visit` method. If no visitor function exists for a node (return value `None`) the `generic_visit` visitor is used instead. Don't use the `NodeVisitor` if you want to apply changes to nodes during traversing. For this a special visitor exists (`NodeTransformer`) that allows modifications. c�r�d|jjz}t|||j�}||�S)z Visit a node.�visit_)rrrsr$� generic_visit)�selfr%�method�visitors r�visitzNodeVisitor.visit�s4���D�N�N�3�3�3���$���(:�(:�;���t�}�rc���t|�D]a\}}t|t�r*|D]$}t|t�s�|j |��&�@t|t�s�Q|j |��cy)z9Called if no explicit visitor function exists for a node.N)r�rr?rmr�)r�r%r�r-r�s rr�zNodeVisitor.generic_visit�sW��'��-�L�E�5��%��&�!�D�!�$��,�� � �4�(�"��E�3�'�� � �5�!� .rc�f�|j}tjt|��}|�,tj �D]\}}t ||�s�|}n|�8d|z} t ||�}ddl}|j|�d�td�||�S|j|�S#t$rY�wxYw)Nr�rz" is deprecated; add visit_Constant�) r-�_const_node_type_names�getr,�itemsrr$�warnings�warn�DeprecationWarningror�) r�r%r-� type_namerxrzr�r�r�s r�visit_ConstantzNodeVisitor.visit_Constant�s���� � ��*�.�.�t�E�{�;� � � �3�9�9�;� ��T��e�S�)� $�I��<� � �� �)�F� %�!�$��/�� �� � ���(J�K�0�!�5��t�}�$��!�!�$�'�'��"� �� �s�! B$�$ B0�/B0N)rs� __module__� __qualname__�__doc__r�r�r�rfrrr�r�s���&� "�(rr�c��eZdZdZd�Zy)�NodeTransformeraC A :class:`NodeVisitor` subclass that walks the abstract syntax tree and allows modification of nodes. The `NodeTransformer` will walk the AST and use the return value of the visitor methods to replace or remove the old node. If the return value of the visitor method is ``None``, the node will be removed from its location, otherwise it is replaced with the return value. The return value may be the original node in which case no replacement takes place. Here is an example transformer that rewrites all occurrences of name lookups (``foo``) to ``data['foo']``:: class RewriteName(NodeTransformer): def visit_Name(self, node): return Subscript( value=Name(id='data', ctx=Load()), slice=Constant(value=node.id), ctx=node.ctx ) Keep in mind that if the node you're operating on has child nodes you must either transform the child nodes yourself or call the :meth:`generic_visit` method for the node first. For nodes that were part of a collection of statements (that applies to all statement nodes), the visitor may also return a list of nodes rather than just a single node. Usually you use the transformer like this:: node = YourTransformer().visit(node) c��t|�D]�\}}t|t�rfg}|D]Y}t|t�r6|j |�}|��'t|t�s|j |��I|j |��[||dd�|t|t�s��|j |�}|� t||���t|||���|Sr*) r�rr?rmr�r�rp�delattrr�)r�r%r�� old_value� new_valuesr-r�s rr�zNodeTransformer.generic_visit�s��� +�D� 1� �E�9��)�T�*�� �&�E�!�%��-� $� � �5� 1�� �=�$�!+�E�3�!7�&�-�-�e�4�$��%�%�e�,�'� *� �!� ��I�s�+��:�:�i�0���#��D�%�(��D�%��2�%!2�&� rN)rsr�r�r�r�rfrrr�r��s ��!�Frr�zN{name} is deprecated and will be removed in Python {remove}; use value insteadzU{name} is deprecated and will be removed in Python {remove}; use ast.Constant insteadr�c�R�ddl}|jdtd��|jS)�Deprecated. Use value instead.rN� Attribute n�r ���message�remove�r�� _deprecated�_DEPRECATED_VALUE_ALIAS_MESSAGEr-�r�r�s r� _n_getterr��,������ �#B�7� � ��z�z�rc�J�ddl}|jdtd��||_y)Nrr�r�r�r��r�r-r�s r� _n_setterr� �)������ �#B�7� � ��� rc�R�ddl}|jdtd��|jS)r�rN� Attribute sr�r�r�r�s r� _s_getterr�r�rc�J�ddl}|jdtd��||_y)Nrr�r�r�r�r�s r� _s_setterr�r�rc��eZdZd�Zd�Zy)�_ABCc��d|_y)Nz3Deprecated AST node class. Use ast.Constant instead)r�)rxrEs r�__init__z _ABC.__init__%s ��O�� rc�f�|tvr)ddl}|jd|j��td��t |t �sy|tvrC |j}t |t|�xr!t |tj|d�� Stj||�S#t$rYywxYw)Nr�ast.r�r�Frf) � _const_typesr�r�r��_DEPRECATED_CLASS_MESSAGErr+r-�_const_types_notr�ror,�__instancecheck__)rx�instr�r-s rrz_ABC.__instancecheck__(s��� �,� � � � � ��s�'�'�(�)�1�� !� � �$��)�� �,� � �� � �� �u�l�3�&7�8�I�"�5�*:�*>�*>�s�B�*G�H�H���%�%�c�4�0�0��"� �� �s� B$�$ B0�/B0N)rsr�r�r�rrfrrr�r�#s ��P�1rr�c�^�|D]T}||jvr�|jj|�}|t|�ks�s����� �c�k�k� !� ��k�k����$�� ��T��?��s�|�|�n�,N�s�g�V�W� W� � �l�������3�#�#�$� %�/H�QX� � ���(��(�(� � � �C� 1�$� 1�&� 1�1rc��eZdZdZeZy)�Num)r�N�rsr�r�rnrrrfrrr r N� ���G��Grr )� metaclassc��eZdZdZeZy)�Str��sNr rfrrrrRr rrc��eZdZdZeZy)�BytesrNr rfrrrrVr rrc��eZdZeZy)� NameConstantN)rsr�r�rrrfrrrrZs���Grrc��eZdZdZd�Zy)�Ellipsisrfc��|tur+ddl}|jdtd��t dg|��i|��St j |g|��i|��S)Nrz ast.Ellipsisr�r�.)� _ast_Ellipsisr�r�r�r+r)rxrErr�s rrzEllipsis.__new__`sZ�� �-� � � � � ��(A�'� !� ��C�1�$�1�&�1� 1�����5�d�5�f�5�5rN)rsr�r�rnrrfrrrr]s ���G�6rr.c��eZdZdZy)�slicezDeprecated AST node class.N�rsr�r�r�rfrrrr�s��$rrc��eZdZdZd�Zy)�Indexz@Deprecated AST node class. Use the index value directly instead.c ��|Sr*rf)rxr-rs rrz Index.__new__�s��� rN�rsr�r�r�rrfrrrr�s ��J�rrc��eZdZdZdd�Zy)�ExtSlicez1Deprecated AST node class. Use ast.Tuple instead.c �>�tt|�t�fi|��Sr*)r;r?�Load)rx�dimsrs rrzExtSlice.__new__�s���T�$�Z���2�6�2�2rN)rfr rfrrr"r"�s ��;�3rr"r%c��|jS)zDeprecated. Use elts instead.�r=�r�s r� _dims_getterr)�s ���y�y�rc��||_yr*r'�r�r-s r� _dims_setterr,�s ���� rc��eZdZdZy)�Suite�/Deprecated AST node class. Unused in Python 3.Nrrfrrr.r.����9rr.c��eZdZdZy)�AugLoadr/Nrrfrrr2r2�r0rr2c��eZdZdZy)�AugStorer/Nrrfrrr4r4�r0rr4c��eZdZdZy)�Paramr/Nrrfrrr6r6�r0rr6�1ec��eZdZdZe�Ze�Ze�Ze�Ze�Z e�Z e�Z e�Z e�Z e Ze�Ze�Ze�Ze�Ze�Ze�Ze�Ze�Ze�Zd�Zy)� _Precedencez5Precedence table that originated from python grammar.c�N� |j|dz�S#t$r|cYSwxYw�Nr\)rrrr(s r�nextz_Precedence.next�s.�� ��>�>�$��(�+� +��� ��K� �s �� $�$N)rsr�r�r�r� NAMED_EXPR�TUPLE�YIELD�TEST�OR�AND�NOT�CMP�EXPR�BOR�BXOR�BAND�SHIFT�ARITH�TERM�FACTOR�POWER�AWAIT�ATOMr<rfrrr9r9�s���?���J� �F�E� �F�E� �6�D� ��B� �&�C� �&�C� �&�C� �6�D� �C� �6�D� �6�D� �F�E� �F�E� �6�D� �V�F� �F�E� �F�E� �6�D�rr9)�'�")z"""�'''c����eZdZdZdd�d�Zd�Zd�Zd�Zd�d�Zd �Z e d�d ��Z e d d �d ��Z e d��Z d�Zd�Zd�Zd�Zd�Zd�Z�fd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd �Zd!�Z d"�Z!d#�Z"d$�Z#d%�Z$d&�Z%d'�Z&d(�Z'd)�Z(d*�Z)d+�Z*d,�Z+d-�Z,d.�Z-d/�Z.d0�Z/d1�Z0d2�Z1d3�Z2d4�Z3d5�Z4d6�Z5d7�Z6d8�Z7d9�Z8d:�Z9d;�Z:d<�Z;d=�Z�Z=d?�Z>d@�Z?e@ddA�dB�ZAe@dC�dD�ZBdE�ZCd�dF�ZDdG�ZEdH�ZFdI�ZGdJ�ZHdK�ZIdL�ZJdM�ZKdN�ZLdO�ZMdP�ZNdQ�ZOdR�ZPdS�ZQdT�ZRdU�ZSdVdWdXdYdZ�ZTeUj�eUj�eUj�eUj�d[�ZXd\�ZYdXdYd]d^d_d`dadbdcdddedfdgdh� ZZeUj�eUj�eUj�eUj�eUj�eUj�eUj�eUj�eUj�eUj�eUj�eUj�eUj�di� Zbecdj�Zddk�Zedldmdndodpdqdrdsdtdudv� Zfdw�Zgdxdydz�ZheUj�eUj�d{�Zkd|�Zld}�Zmd~�Znd�Zod��Zpd��Zqd��Zrd��Zsd��Ztd��Zud��Zvd��Zwd��Zxd��Zyd��Zzd��Z{d��Z|d��Z}d��Z~d��Zd��Z�d��Z�d��Z��xZ�S)�� _Unparserz�Methods in this class recursively traverse an AST and output source code for the abstract syntax; original formatting is disregarded.F)�_avoid_backslashesc�X�g|_i|_i|_d|_||_d|_y)NrF)�_source� _precedences� _type_ignores�_indentrU� _in_try_star)r�rUs rr�z_Unparser.__init__�s0���� ��������� �"4���!��rc��t|�} |t|��|D]}|�||��y#t$rYywxYw)z7Call f on each item in seq, calling inter() in between.N)�iterr<� StopIteration)r��inter�f�seqrhs r� interleavez_Unparser.interleave�sG���3�i�� � �d�3�i�L������!����� � � �s�5� A�Ac���t|�dk(r||d��jd�y�j�fd�||�y)z�Traverse and separate the given *items* with a comma and append it to the buffer. If *items* is a single item sequence, a trailing comma will be added.r\r�,c�&���jd�S�Nr_��writer(s�r�z&_Unparser.items_view..�����D�J�J�t�$4rN)rHrhrb)r�� traverserr�s` r� items_viewz_Unparser.items_view�s8��� �u�:��?� �e�A�h� � �J�J�s�O� �O�O�4�i�� Grc�@�|jr|jd�yy)z8Adds a newline if it isn't the start of generated sourcer]N)rWrhr(s r� maybe_newlinez_Unparser.maybe_newline�s�� �<�<� �J�J�t� � rc�f�|j�|jd|jz|z�y)zXIndent a piece of text and append it, according to the current indentation levelz N)rnrhrZ�r�r�s r�fillz_Unparser.fill�s*�� ���� � � �6�D�L�L�(�4�/�0rc�:�|jj|�y)zAdd new source partsN)rWr�rps rrhz_Unparser.writes�� � � ���D�!rNc#�PK�|�g}|j}||_|��||_y�wr*)rW)r��buffer�original_sources r�bufferedz_Unparser.buffereds,���� �>��F��,�,���� �� �&�� �s�$&��extrac#�K�|jd�|r|j|�|xjdz c_d��|xjdzc_y�w)aA context manager for preparing the source for blocks. It adds the character':', increases the indentation on enter and decreases the indentation on exit. If *extra* is given, it will be directly appended after the colon character. �:r\N)rhrZ)r�rxs r�blockz_Unparser.blocksA���� � � �3�� � �J�J�u� � � � ��� � � � � ��� �s�AAc#�XK�|j|�d��|j|�y�w)z�A context manager for preparing the source for expressions. It adds *start* to the buffer and enters, after exit it adds *end*.Nrg)r��start�ends r�delimitz_Unparser.delimits"���� � � �5�� � � � �3��s�(*c�>�|r|j||�St�Sr*)rr)r�r}r~� conditions r� delimit_ifz_Unparser.delimit_if's�� ��<�<��s�+� +��=� rc�L�|jdd|j|�|kD�S)z,Shortcut to adding precedence related parensrarb)r��get_precedence)r�� precedencer%s r�require_parensz_Unparser.require_parens-s%�����s�C��)<�)<�T�)B�Z�)O�P�Prc�V�|jj|tj�Sr*)rXr�r9r@�r�r%s rr�z_Unparser.get_precedence1s!��� � �$�$�T�;�+;�+;�<�.p����� � �4�(r� -> )rrbr��argtypesrh�returnsr�s` r�visit_FunctionTypez_Unparser.visit_FunctionTypemsX��� �\�\�#�s� #� �O�O�(�$�-�-���� �$� � � �6�� � � �d�l�l�#� $� #�s �+A4�4A=c��|j�|jtj|j�|j |j�yr*)rqr�r9r?r-r�r�s r� visit_Exprz_Unparser.visit_Exprvs5�� � � � � ���K�-�-�t�z�z�:� � � �d�j�j�!rc�f�|jtj|�5|jtj|j |j �|j|j �|jd�|j|j �ddd�y#1swYyxYw)Nz := ) r�r9r=r�rO�targetr-r�rhr�s r�visit_NamedExprz_Unparser.visit_NamedExpr{sp�� � � ��!7�!7�� >� � � � � 0� 0�$�+�+�t�z�z� J� �M�M�$�+�+� &� �J�J�v� � �M�M�$�*�*� %� ?� >� >�s �A=B'�'B0c�|���jd��j�fd��j|j�y)Nzimport c�&���jd�Srfrgr(s�rriz(_Unparser.visit_Import..������ � �4� 0r)rqrbr��namesr�s` r� visit_Importz_Unparser.visit_Import�s(��� � � �)�� ���0�$�-�-����Lrc�0���jd��jd|jxsdz�|jr�j|j��jd��j �fd��j |j �y)Nzfrom �.rz import c�&���jd�Srfrgr(s�rriz,_Unparser.visit_ImportFrom..�r�r)rqrhrj�modulerbr�r�r�s` r�visit_ImportFromz_Unparser.visit_ImportFrom�sd��� � � �'�� � � �3�$�*�*�/��*�+� �;�;� �J�J�t�{�{� #� � � �:�� ���0�$�-�-����Lrc�J�|j�|jD]D}|jtj|�|j |�|j d��F|j |j�|j|�x}r|j |�yy)N� = ) rq�targetsr�r9r>r�rhr-r�)r�r%r�r�s r� visit_Assignz_Unparser.visit_Assign�s��� � � � ��l�l�F� � � � � 1� 1�6� :� �M�M�&� !� �J�J�u� �#� � � �d�j�j�!��0�0��6� 6�<� 6� �J�J�|� $� 7rc��|j�|j|j�|jd|j|j j jzdz�|j|j�y)Nr~z= ) rqr�r�rh�binopr4rrrsr-r�s r�visit_AugAssignz_Unparser.visit_AugAssign�sZ�� � � � � � � �d�k�k�"� � � �3����D�G�G�$5�$5�$>�$>�?�?�$�F�G� � � �d�j�j�!rc���|j�|jdd|j xrt|jt ��5|j |j�ddd�|jd�|j |j�|jr-|jd�|j |j�yy#1swY�oxYw)Nrarbr#r�) rqr�r{rr�rCr�rh� annotationr-r�s r�visit_AnnAssignz_Unparser.visit_AnnAssign�s��� � � � � �_�_�S�#�4�;�;��'X�:�d�k�k�SW�;X� Y� �M�M�$�+�+� &�Z� � � �4�� � � �d�o�o�&� �:�:� �J�J�u� � �M�M�$�*�*� %� � Z� Y�s � C�Cc��|jd�|jr-|jd�|j|j�yy)N�returnr~)rqr-rhr�r�s r� visit_Returnz_Unparser.visit_Return�s5�� � � �(�� �:�:� �J�J�s�O� �M�M�$�*�*� %� rc�&�|jd�y)N�pass�rqr�s r� visit_Passz_Unparser.visit_Pass�s�� � � �&�rc�&�|jd�y)N�breakr�r�s r� visit_Breakz_Unparser.visit_Break�s�� � � �'�rc�&�|jd�y)N�continuer�r�s r�visit_Continuez_Unparser.visit_Continue�s�� � � �*�rc�|���jd��j�fd��j|j�y)Nzdel c�&���jd�Srfrgr(s�rriz(_Unparser.visit_Delete..�r�r)rqrbr�r�r�s` r� visit_Deletez_Unparser.visit_Delete�s(��� � � �&�� ���0�$�-�-����Nrc���|jd�|j|j�|jr-|j d�|j|j�yy)Nzassert r_)rqr��testr&rhr�s r� visit_Assertz_Unparser.visit_Assert�sF�� � � �)�� � � �d�i�i� � �8�8� �J�J�t� � �M�M�$�(�(� #� rc�|���jd��j�fd��j|j�y)Nzglobal c�&���jd�Srfrgr(s�rriz(_Unparser.visit_Global..�r�r�rqrbrhr�r�s` r� visit_Globalz_Unparser.visit_Global�s(��� � � �)�� ���0�$�*�*�d�j�j�Irc�|���jd��j�fd��j|j�y)Nz nonlocal c�&���jd�Srfrgr(s�rriz*_Unparser.visit_Nonlocal..�r�rr�r�s` r�visit_Nonlocalz_Unparser.visit_Nonlocal�s(��� � � �+�� ���0�$�*�*�d�j�j�Irc�T�|jtj|�5|jd�|jrV|jd�|j tj |j�|j|j�ddd�y#1swYyxYw)N�awaitr~)r�r9rNrhr-r�rOr�r�s r� visit_Awaitz_Unparser.visit_Await��l�� � � ��!2�!2�D� 9� �J�J�w� ��z�z�� � �3���#�#�K�$4�$4�d�j�j�A�� � �d�j�j�)� :� 9� 9�� �A4B�B'c�T�|jtj|�5|jd�|jrV|jd�|j tj |j�|j|j�ddd�y#1swYyxYw)N�yieldr~)r�r9r?rhr-r�rOr�r�s r� visit_Yieldz_Unparser.visit_Yield�r�r�c�H�|jtj|�5|jd�|js t d��|j tj|j�|j|j�ddd�y#1swYyxYw)Nz yield from z-Node can't be used without a value attribute.) r�r9r?rhr-rr�rOr�r�s r�visit_YieldFromz_Unparser.visit_YieldFrom�sm�� � � ��!2�!2�D� 9� �J�J�}� %��:�:� �!P�Q�Q� � � � � 0� 0�$�*�*� =� �M�M�$�*�*� %� :� 9� 9�s �A.B�B!c�8�|jd�|js|jr td��y|j d�|j |j�|jr-|j d�|j |j�yy)N�raisez*Node can't use cause without an exception.r~z from )rq�exc�causerrhr�r�s r� visit_Raisez_Unparser.visit_Raise�sn�� � � �'���x�x��z�z� �#M�O�O� � � � �3�� � � �d�h�h�� �:�:� �J�J�x� � �M�M�$�*�*� %� rc�`�|jd�|j�5|j|j�ddd�|jD]}|j|��|j rE|jd�|j�5|j|j �ddd�|j rF|jd�|j�5|j|j �ddd�yy#1swY��xYw#1swY�hxYw#1swYyxYw)N�try�else�finally)rqr{r�rV�handlers�orelse� finalbody)r�r%�exs r� do_visit_tryz_Unparser.do_visit_try�s��� � � �%�� �Z�Z�\� �M�M�$�)�)� $���-�-�B� �M�M�"� � � �;�;� �I�I�f� ������ � �d�k�k�*�� �>�>� �I�I�i� ������ � �d�n�n�-��� ��\�� �����s#�D �D�&D$� D�D!�$D-c�t�|j} d|_|j|�||_y#||_wxYw)NF�r[r��r�r%�prev_in_try_stars r� visit_Tryz_Unparser.visit_Try�s;���,�,�� 1� %�D� � � � �d� #� 0�D� �� 0�D� ���.� 7c�t�|j} d|_|j|�||_y#||_wxYw)NTr�r�s r� visit_TryStarz_Unparser.visit_TryStars;���,�,�� 1� $�D� � � � �d� #� 0�D� �� 0�D� �r�c��|j|jrdnd�|jr,|jd�|j |j�|j r,|jd�|j|j �|j �5|j |j�ddd�y#1swYyxYw)Nzexcept*�exceptr~� as )rqr[r,rhr�rzr{rVr�s r�visit_ExceptHandlerz_Unparser.visit_ExceptHandler s��� � � �t�0�0�)�h�?� �9�9� �J�J�s�O� �M�M�$�)�)� $� �9�9� �J�J�v� � �J�J�t�y�y� !� �Z�Z�\� �M�M�$�)�)� $��\�\�s � C�Cc���|j�|jD]$}|jd�|j|��&|jd|jz�t |d�r|j |j�|jdd|jxs |j��5d}|jD])}|r|jd�nd }|j|��+|jD])}|r|jd�nd }|j|��+ ddd�|j�5|j|�ddd�y#1swY�4xYw#1swYyxYw) N�@zclass � type_paramsrarb)r�Fr_T)rn�decorator_listrqr�rzr��_type_params_helperrr��basesrFrhr{r�)r�r%�deco�comma�es r�visit_ClassDefz_Unparser.visit_ClassDefs$�� �����'�'�D� �I�I�c�N� �M�M�$� �(� � � �(�T�Y�Y�&�'� �4�� '� � $� $�T�%5�%5� 6� �_�_�S�#�4�:�:�3N����_� O��E��Z�Z����J�J�t�$� �E�� � �a� �  � �]�]����J�J�t�$� �E�� � �a� � #�P��Z�Z�\� � 3� 3�D� 9��\�P� O���\�s�5A3E�E(�E%�(E1c�(�|j|d�y)N�def��_function_helperr�s r�visit_FunctionDefz_Unparser.visit_FunctionDef2s�� ���d�E�*rc�(�|j|d�y)Nz async defr r�s r�visit_AsyncFunctionDefz _Unparser.visit_AsyncFunctionDef5s�� ���d�K�0rc��|j�|jD]$}|jd�|j|��&|dz|jz}|j|�t |d�r|j |j�|jdd�5|j|j�ddd�|jr,|jd�|j|j�|j|j|���5|j|�ddd�y#1swY�}xYw#1swYyxYw)Nr�r~rrarbr�rw)rnrrqr�rzr�rrrrEr�rhr{r�r�)r�r%� fill_suffixr�def_strs rr z_Unparser._function_helper8s��� �����'�'�D� �I�I�c�N� �M�M�$� �(���#�d�i�i�/�� � � �'�� �4�� '� � $� $�T�%5�%5� 6� �\�\�#�s� #� �M�M�$�)�)� $�$� �<�<� �J�J�v� � �M�M�$�,�,� '� �Z�Z�d�3�3�D�9�Z� :� � 3� 3�D� 9�;� :� $� #�� ;� :�s� D8�E�8E�E c���|�Kt|�dkDr<�jdd�5�j�fd��j|�ddd�yyy#1swYyxYw)Nrrcrlc�&���jd�Srfrgr(s�rriz/_Unparser._type_params_helper..L����� � �4�(8r)rHrrbr�)r�rs` rrz_Unparser._type_params_helperIsO��� � "�s�;�'7�!�';����c�3�'���� 8�$�-�-��U�(�'�(<� "�'�'�s �!A�Ac��|j|j�|jr-|jd�|j|j�yy�Nr#)rhrz�boundr�r�s r� visit_TypeVarz_Unparser.visit_TypeVarNs:�� � � �4�9�9�� �:�:� �J�J�t� � �M�M�$�*�*� %� rc�@�|jd|jz�y�Nr�rhrzr�s r�visit_TypeVarTuplez_Unparser.visit_TypeVarTupleTs�� � � �3����?�#rc�@�|jd|jz�y�N�**rr�s r�visit_ParamSpecz_Unparser.visit_ParamSpecWs�� � � �4�$�)�)�#�$rc���|jd�|j|j�|j|j�|j d�|j|j �y)Nztype r�)rqr�rzrrrhr-r�s r�visit_TypeAliasz_Unparser.visit_TypeAliasZsN�� � � �'�� � � �d�i�i� � � � ��!1�!1�2� � � �5�� � � �d�j�j�!rc�(�|jd|�y)Nzfor �� _for_helperr�s r� visit_Forz_Unparser.visit_Foras�� �����&rc�(�|jd|�y)Nz async for r$r�s r�visit_AsyncForz_Unparser.visit_AsyncFords�� ����t�,rc�f�|j|�|jtj|j�|j |j�|j d�|j |j�|j|j|���5|j |j�ddd�|jrF|jd�|j�5|j |j�ddd�yy#1swY�\xYw#1swYyxYw)N� in rwr�) rqr�r9r>r�r�rhr]r{r�rVr�)r�rqr%s rr%z_Unparser._for_helpergs��� � � �$�� ���K�-�-�t�{�{�;� � � �d�k�k�"� � � �6�� � � �d�i�i� � �Z�Z�d�3�3�D�9�Z� :� �M�M�$�)�)� $�;� �;�;� �I�I�f� ������ � �d�k�k�*��� �;� :����s�$D�5D'�D$�'D0c��|jd�|j|j�|j�5|j|j�ddd�|j r�t |j �dk(r�t|j dt�r�|j d}|jd�|j|j�|j�5|j|j�ddd�|j r6t |j �dk(rt|j dt�r��|j rF|jd�|j�5|j|j �ddd�yy#1swY��OxYw#1swY��xYw#1swYyxYw)Nzif r\rzelif r�) rqr�r�r{rVr�rHr�Ifr�s r�visit_Ifz_Unparser.visit_Ifts+�� � � �%�� � � �d�i�i� � �Z�Z�\� �M�M�$�)�)� $���k�k�c�$�+�+�.�!�3� �4�;�;�q�>�SU�8V��;�;�q�>�D� �I�I�g� � �M�M�$�)�)� $������ � �d�i�i�(�� �k�k�c�$�+�+�.�!�3� �4�;�;�q�>�SU�8V� �;�;� �I�I�f� ������ � �d�k�k�*��� ��\����� ��s#�F&�-F3�F?�&F0�3F<�?Gc��|jd�|j|j�|j�5|j|j�ddd�|j rF|jd�|j�5|j|j �ddd�yy#1swY�\xYw#1swYyxYw)Nzwhile r�)rqr�r�r{rVr�r�s r� visit_Whilez_Unparser.visit_While�s��� � � �(�� � � �d�i�i� � �Z�Z�\� �M�M�$�)�)� $�� �;�;� �I�I�f� ������ � �d�k�k�*��� ��\����s�B4�C�4B=�C c����jd��j�fd��j|j��j �j |���5�j|j �ddd�y#1swYyxYw)Nzwith c�&���jd�Srfrgr(s�rriz&_Unparser.visit_With..�r�rrw�rqrbr�r�r{r�rVr�s` r� visit_Withz_Unparser.visit_With�s]��� � � �'�� ���0�$�-�-����L� �Z�Z�d�3�3�D�9�Z� :� �M�M�$�)�)� $�;� :� :�� �B�B c����jd��j�fd��j|j��j �j |���5�j|j �ddd�y#1swYyxYw)Nz async with c�&���jd�Srfrgr(s�rriz+_Unparser.visit_AsyncWith..�r�rrwr2r�s` r�visit_AsyncWithz_Unparser.visit_AsyncWith�s]��� � � �-� � ���0�$�-�-����L� �Z�Z�d�3�3�D�9�Z� :� �M�M�$�)�)� $�;� :� :�r4�� quote_types�escape_special_whitespacec������fd�}djt|����|}d�vr|D�cgc] }|tvs� |��}}|D�cgc] }|�vs�|�� }}|s+t���t �fd�|D��d�}�dd|gfS�rD|j �fd�� �|dd�dk(r!t |d�d k(sJ��d dd z�dz��|fScc}wcc}w) z�Helper for writing string literals, minimizing escapes. Returns the tuple (string literal to write, possible quote types). c����s|dvr|S|dk(s|j�s |jd�jd�S|S)Nz �\�unicode_escape�ascii)� isprintabler�r�)r�r:s �r� escape_charz2_Unparser._str_literal_helper..escape_char�sB���-��f�����D�y�� � ���x�x� 0�1�8�8��A�A��Hrr^r]c3�2�K�|]}�d|vs� |���y�wrerf)rg�q�strings �rrkz0_Unparser._str_literal_helper..�s�����C�[��F�1�I��N�!�[�s� �rr\r c���|d�dk(S)Nrr rf)rC�escaped_strings �rriz/_Unparser._str_literal_helper..�s���q��t�~�b�7I�/Ir)rr Nr=)rtr<� _MULTI_QUOTESrur<�sortrH) r�rDr9r:rA�possible_quotesrC�quoterFs ` ` @r�_str_literal_helperz_Unparser._str_literal_helper�s���  �����[�&�!9�:��%�� �>� !�*9�P�/�Q�Q�-�=O�q�/�O�P�&5�Q�o���.�9P�1�o��Q���&�\�F��C�[�C�V�A�Y�O�E��!�B�<�%��(� (� � � � �%I� � J��q�!�!�$��r�(:�:��?�1�-�.�!�3�3�3�!/���!4�t�!;�n�R�>P�!P����.�.��#Q��Qs� C �C � C�C�r9c�h�|j||��\}}|d}|j|�|�|���y)zKWrite string literal value with a best effort attempt to avoid backslashes.rLrN)rKrh)r�rDr9� quote_types r�_write_str_avoiding_backslashesz)_Unparser._write_str_avoiding_backslashes�s>��"�6�6�v�;�6�W��� � ��^� � � � �j�\�&��*��6�7rc��|jd�g}|jD]\}|j�5}|j|�ddd�|j dj �t |t�f��^g}tt�}d}|D]�\}}|r8|j||d��\}} t| �j|�rd}nN| }n8d|vr|D� cgc] } | tvs� | ��}} |sJ�|D� cgc] } | |vs�| �� } } | r| }|j |���|rodg}|j�|D]W\}}|r?td|z�}d } |j!| �sJt|���|t#| �d }|j |��Ydj |�}|d } |j| �|�| ���y#1swY��{xYwcc} wcc} w) Nr`r^FTr8r]rRrQz'"r r)rhrJrv�_write_fstring_innerrprtrr+r?� _ALL_QUOTESrKr:� isdisjointrGr�rur�rH) r�r%� fstring_partsr-rt�new_fstring_partsr9�fallback_to_repr� is_constant�new_quote_typesrC�expected_prefixrNs r�visit_JoinedStrz_Unparser.visit_JoinedStr�s��� � � �3��� ��[�[�E�����F��)�)�%�0�!� � � ������*�U�H�"=�>� �!����;�'� � ��"/� �E�;��)-�)A�)A�� +�.2�*B�*�&��� ��'�2�2�;�?�'+�$��-� ��5�=�.9�"P�k��Q�-�=O�1�k�K�"P�&�&�;�.9�"L�k��Q�e�^�1�k��"L�"�"1�K� � $� $�U� +�'#0�* �!�'�K� � #� #� %�&3�"��{�� ��u��-�E�&+�O� �+�+�O�<�I�d�5�k�I�<�!�#�o�"6�r�:�E�!�(�(��/� '4����)�*�� ��^� � � � �j�\�%��� �5�6�[!���,#Q��#Ms#�F>� G �*G �8 G�G�>G c�0�t|t�r%|jD]}|j||���yt|t�r�t|j t �r�|j jdd�jdd�}|rH|jdd�}|jdd �}|jd d �}|jd d �}|j|�yt|t�r|j|�ytd|����)N��is_format_spec�{z{{�}z}}r=z\\rPz\'rQz\"r]z\nz"Unexpected node inside JoinedStr, ) r� JoinedStrrJrQr+r-rS�replacerh�FormattedValue�visit_FormattedValuer)r�r%r]r-s rrQz_Unparser._write_fstring_inner�s��� �d�I� &������)�)�%��)�O�%� ��h� '�J�t�z�z�3�,G��J�J�&�&�s�D�1�9�9�#�t�D�E��� � �d�F�3��� � �c�5�1��� � �c�5�1��� � �d�E�2�� �J�J�u� � ��n� -� � %� %�d� +��A�$��J�K� Krc�����fd�}�jdd�5||j�}|jd�r�jd��j|�|jdk7r'�jdt |j����|j r.�jd��j|j d� �ddd�y#1swYyxYw) Nc���t���}|jtjj �|�|j |�Sr*)r,r�r9r@r<r�)�inner�unparserr�s �r� unparse_innerz5_Unparser.visit_FormattedValue..unparse_inners>���!�t�D�z�|�H� � #� #�K�$4�$4�$9�$9�$;�U� C��>�>�%�(� (rr^r_r~r �!rzTr\)rr-r�rh� conversion�chr� format_specrQ)r�r%rh�exprs` rrcz_Unparser.visit_FormattedValues���� )� �\�\�#�s� #� ����,�D����s�#�� � �3�� �J�J�t� ����"�$�� � �Q�s�4�?�?�3�4�5�6����� � �3���)�)�$�*:�*:�4�)�P�$� #� #�s �B6C�C!c�:�|j|j�yr*)rhrDr�s r� visit_Namez_Unparser.visit_Name!s�� � � �4�7�7�rc��|j�|jdk(r|jd�|j|jt ��y)N�urL)rq�kindrhrOr-rGr�s rr�z_Unparser._write_docstring$s9�� � � � � �9�9�� � �J�J�s�O� �,�,�T�Z�Z�]�,�Src �\�t|ttf�rN|jt |�j dt �j ddt �dt �d���y|jr"t|t�r|j|�y|jt |��y)N�inf�nanra�-rb) rr/r0rhrura�_INFSTRrUrSrOr+s r�_write_constantz_Unparser._write_constant*s�� �e�e�W�-� .� �J�J��U� �����(����!�G�9�A�g�Y�a� 8�9� � � $� $��E�3�)?� � 0� 0�� 7� �J�J�t�E�{� #rc�f�|j}t|t�r8|jdd�5|j |j |�ddd�y|dur|j d�y|jdk(r|j d�|j |j�y#1swYyxYw)Nrarb.�...rq)r-rrrrlrxrhrr)r�r%r-s rr�z_Unparser.visit_Constant8s���� � �� �e�U� #����c�3�'����� 4� 4�e�<�(�'� �c�\� �J�J�u� ��y�y�C��� � �3�� � � ���� ,�(�'�s �B'�'B0c����jdd�5�j�fd��j|j�ddd�y#1swYyxYw)Nrcrlc�&���jd�Srfrgr(s�rriz&_Unparser.visit_List..Frjr)rrbr�r=r�s` r� visit_Listz_Unparser.visit_ListDs6��� �\�\�#�s� #� �O�O�4�d�m�m�T�Y�Y� O�$� #� #�� �+A�Ac���|jdd�5|j|j�|jD]}|j|�� ddd�y#1swYyxYw)Nrcrl�rr��elt� generators�r�r%�gens r�visit_ListCompz_Unparser.visit_ListCompH�F�� �\�\�#�s� #� �M�M�$�(�(� #������ � �c�"�'�$� #� #�� �>A�A$c���|jdd�5|j|j�|jD]}|j|�� ddd�y#1swYyxYw)Nrarbr�r�s r�visit_GeneratorExpz_Unparser.visit_GeneratorExpNr�r�c���|jdd�5|j|j�|jD]}|j|�� ddd�y#1swYyxYw)Nr^r_r�r�s r� visit_SetCompz_Unparser.visit_SetCompTr�r�c�&�|jdd�5|j|j�|jd�|j|j�|j D]}|j|�� ddd�y#1swYyxYw)Nr^r_r#)rr�rrhr-r�r�s r�visit_DictCompz_Unparser.visit_DictCompZsb�� �\�\�#�s� #� �M�M�$�(�(� #� �J�J�t� � �M�M�$�*�*� %������ � �c�"�'� $� #� #�s �A*B�Bc�2�|jr|jd�n|jd�|jtj|j �|j |j �|jd�|jtjj�|jg|j���|j |j�|jD]$}|jd�|j |��&y)Nz async for z for r*� if ) �is_asyncrhr�r9r>r�r�r@r<r]�ifs)r�r%� if_clauses r�visit_comprehensionz_Unparser.visit_comprehensionbs��� �=�=� �J�J�}� %� �J�J�w� � ���K�-�-�t�{�{�;� � � �d�k�k�"� � � �6������K�,�,�1�1�3�T�Y�Y�J����J� � � �d�i�i� ����I� �J�J�v� � �M�M�)� $�"rc�.�|jtj|�5|jtjj �|j |j �|j|j �|jd�|j|j �|jd�|jtj|j�|j|j�ddd�y#1swYyxYw)Nr�z else ) r�r9r@r�r<rVr�r�rhr�r�s r� visit_IfExpz_Unparser.visit_IfExpps��� � � ��!1�!1�4� 8� � � � � 0� 0� 5� 5� 7����D�I�I� N� �M�M�$�)�)� $� �J�J�v� � �M�M�$�)�)� $� �J�J�x� � � � � � 0� 0�$�+�+� >� �M�M�$�+�+� &�9� 8� 8�s �C!D � Dc����|jrF�jdd�5�j�fd��j|j�ddd�y�j d�y#1swYyxYw)Nr^r_c�&���jd�Srfrgr(s�rriz%_Unparser.visit_Set..}rrz{*()})r=rrbr�rhr�s` r� visit_Setz_Unparser.visit_SetzsP��� �9�9����c�3�'���� 8�$�-�-����S�(�'� �J�J�w� � (�'�s �+A&�&A/c ������fd����fd�}�jdd�5�j�fd�|t|j|j��ddd�y#1swYyxYw)Nc�l���j|��jd��j|�yr�r�rh)�k�vr�s �r�write_key_value_pairz2_Unparser.visit_Dict..write_key_value_pair�s'��� �M�M�!� � �J�J�t� � �M�M�!� rc���|\}}|�C�jd��jtj|��j |�y�||�yr)rhr�r9rEr�)r�r�r�r�r�s ��r� write_itemz(_Unparser.visit_Dict..write_item�sK����D�A�q��y�� � �4� ��#�#�K�$4�$4�a�8�� � �a� �$�Q��*rr^r_c�&���jd�Srfrgr(s�rriz&_Unparser.visit_Dict..�r�r)rrbrLrIrJ)r�r%r�r�s` @r� visit_Dictz_Unparser.visit_Dict�sK��� � +��\�\�#�s� #� �O�O�(�*�c�$�)�)�T�[�[�6Q� �$� #� #�s �5A�A'c��|jddt|j�dk(xs"|j|�tj kD�5|j |j|j�ddd�y#1swYyxYw)Nrarbr)r�rHr=r�r9r>rlr�r�s r� visit_Tuplez_Unparser.visit_Tuple�sg�� �_�_� � � �� � �N�a� � P�4�#6�#6�t�#<�{�?P�?P�#P� � �O�O�D�M�M�4�9�9� 5�  � � �s �'A>�>B�~�not�+rv)�Invert�Notr5r6)r�r�r�rvc��|j|jjj}|j|}|j ||�5|j |�|tjur|j d�|j||j�|j|j�ddd�y#1swYyxYw�Nr~) �unopr4rrrs�unop_precedencer�rhr9rLr�r7r�)r�r%�operator�operator_precedences r� visit_UnaryOpz_Unparser.visit_UnaryOp�s����9�9�T�W�W�.�.�7�7�8��"�2�2�8�<�� � � �!4�d� ;� �J�J�x� �#�+�*<�*<�<�� � �3�� � � � 3�T�\�\� B� �M�M�$�,�,� '�<� ;� ;�s �A,C�C rr��/�%�<<�>>�|�^�&�//r) rNrO�Mult�MatMult�Div�Mod�LShift�RShift�BitOr�BitXor�BitAnd�FloorDiv�Pow) r�rvrr�r�r�r�r�r�r�r�r�r)rc�6�|j|jjj}|j|}|j ||�5||j vr|j�}|}n|}|j�}|j||j�|j|j�|jd|�d��|j||j�|j|j�ddd�y#1swYyxYwr�) r�r4rrrs�binop_precedencer�� binop_rassocr<r�rPr�rhrQ)r�r%r�r��left_precedence�right_precedences r� visit_BinOpz_Unparser.visit_BinOp�s����:�:�d�g�g�/�/�8�8�9��"�3�3�H�=�� � � �!4�d� ;��4�,�,�,�"5�":�":�"<��#6� �"5��#6�#;�#;�#=� � � � ����� ;� �M�M�$�)�)� $� �J�J��8�*�A�� '� � � � 0�$�*�*� =� �M�M�$�*�*� %�<� ;� ;�s �B7D�Dz==z!=�z>=�iszis not�inznot in) �Eq�NotEq�Lt�LtE�Gt�GtE�Is�IsNot�In�NotInc��|jtj|�5|jtjj �|j g|j ���|j|j �t|j|j �D]N\}}|jd|j|jjzdz�|j|��P ddd�y#1swYyxYwr�)r�r9rDr�r<rP� comparatorsr�rL�opsrh�cmpopsrrrs)r�r%�ors r� visit_Comparez_Unparser.visit_Compare�s��� � � ����$� 7� �D� � � ��� 4� 4� 6�� � � U�D�DT�DT� U� �M�M�$�)�)� $��D�H�H�d�&6�&6�7���1�� � �3����Q�[�[�-A�-A�!B�B�S�H�I�� � �a� �8�8� 7� 7�s �CC<�<D�and�or)�And�Or)r�r�c�*�����j|jjj}�j|���fd�}�j �|�5d|�d���j ��fd�||j�ddd�y#1swYyxYw)Nc�l���j���j�|��j|�yr*)r<r�r�)r%r�r�s ��r�increasing_level_traversez9_Unparser.visit_BoolOp..increasing_level_traverses/���"5�":�":�"<� � � � � 3�T� :� �M�M�$� rr~c�&���j��Sr*rg)rr�s��rriz(_Unparser.visit_BoolOp.. s ���D�J�J�q�Mr)�boolopsr4rrrs�boolop_precedencer�rbrJ)r�r%r�r�r�rs` @@r� visit_BoolOpz_Unparser.visit_BoolOp�sy����<�<���� 1� 1� :� :�;��"�4�4�X�>�� � � � �!4�d� ;��H�:�Q��A� �O�O�1�3L�d�k�k� Z�<� ;� ;�s �(B � Bc��|jtj|j�|j |j�t |jt �r5t |jjt�r|jd�|jd�|j|j�y)Nr~r�) r�r9rOr-r�rr+r.rhr�r�s r�visit_Attributez_Unparser.visit_Attribute su�� ���K�,�,�d�j�j�9� � � �d�j�j�!� �d�j�j�(� +� �4�:�:�;K�;K�S�0Q� �J�J�s�O� � � �3�� � � �4�9�9�rc���|jtj|j�|j |j�|j dd�5d}|j D])}|r|jd�nd}|j |��+|jD])}|r|jd�nd}|j |��+ ddd�y#1swYyxYw)NrarbFr_T) r�r9rOrBr�rrErhrF)r�r%rrs r� visit_Callz_Unparser.visit_Calls��� ���K�,�,�d�i�i�8� � � �d�i�i� � �\�\�#�s� #��E��Y�Y����J�J�t�$� �E�� � �a� � � �]�]����J�J�t�$� �E�� � �a� � #�$� #� #�s �A3C�Cc��d�}|jtj|j�|j |j�|j dd�5||j �r1|j|j|j j�n|j |j �ddd�y#1swYyxYw)Nc�>�t|t�xr |jSr*)rr;r=)� slice_values r�is_non_empty_tuplez5_Unparser.visit_Subscript..is_non_empty_tuple+s���;��.�%��$�$� rrcrl) r�r9rOr-r�rrrlr=)r�r%r�s r�visit_Subscriptz_Unparser.visit_Subscript*s��� � ���K�,�,�d�j�j�9� � � �d�j�j�!� �\�\�#�s� #�!�$�*�*�-����� � �t�z�z���?�� � �d�j�j�)� $� #� #�s �AC�C c��|jd�|jtj|j�|j |j�yr)rhr�r9rEr-r�r�s r� visit_Starredz_Unparser.visit_Starred:s7�� � � �3�� ���K�,�,�d�j�j�9� � � �d�j�j�!rc�&�|jd�y)Nrzrgr�s r�visit_Ellipsisz_Unparser.visit_Ellipsis?s�� � � �5�rc�4�|jr|j|j�|jd�|jr|j|j�|jr-|jd�|j|j�yy)Nrz)�lowerr�rh�upper�stepr�s r� visit_Slicez_Unparser.visit_SliceBsb�� �:�:� �M�M�$�*�*� %� � � �3�� �:�:� �M�M�$�*�*� %� �9�9� �J�J�s�O� �M�M�$�)�)� $� rc���|jd�|j|j�|j�5|jD]}|j|�� ddd�y#1swYyxYw)Nzmatch )rqr��subjectr{�cases)r�r%�cases r� visit_Matchz_Unparser.visit_MatchLsK�� � � �(�� � � �d�l�l�#� �Z�Z�\�� � ��� � �d�#�#��\�\�s �#A*�*A3c��|j|j�|jr-|jd�|j|j�yyr)rh�argr�r�r�s r� visit_argz_Unparser.visit_argSs:�� � � �4�8�8�� �?�?� �J�J�t� � �M�M�$�/�/� *� rc�l�d}|j|jz}dgt|�t|j�z z|jz}t t ||�d�D]\}}|\}}|rd}n|j d�|j|�|r"|j d�|j|�|t|j�k(s�o|j d���|js |jr�|rd}n|j d�|j d�|jrq|j |jj�|jjr6|j d�|j|jj�|jrot |j|j�D]L\}}|j d�|j|�|s�+|j d�|j|��N|jr�|rd}n|j d�|j d |jjz�|jjr7|j d�|j|jj�yyy) NTr\Fr_r`z, /rr#r)� posonlyargsrErH�defaultsr�rLrhr��vararg� kwonlyargsrr�� kw_defaults�kwarg) r�r%r��all_argsrr�elements�a�ds r�visit_argumentsz_Unparser.visit_argumentsYs�����#�#�d�i�i�/���6�S��]�S����-?�?�@�4�=�=�P��(��X�x�)@�!�D�O�E�8��D�A�q����� � �4� � �M�M�!� ��� � �3��� � �a� ���D�,�,�-�-�� � �5�!� E� �;�;�$�/�/����� � �4� � �J�J�s�O��{�{�� � �4�;�;�?�?�+��;�;�)�)��J�J�t�$��M�M�$�+�+�"8�"8�9� �?�?��D�O�O�T�-=�-=�>���1�� � �4� �� � �a� ���J�J�s�O��M�M�!�$� ?� �:�:����� � �4� � �J�J�t�d�j�j�n�n�,� -��z�z�$�$�� � �4� �� � �d�j�j�3�3�4�%� rc���|j�|jd�n,|j|j�|jd�|j|j�y)Nrr`)rrhr�r-r�s r� visit_keywordz_Unparser.visit_keyword�sC�� �8�8� � �J�J�t� � �J�J�t�x�x� � �J�J�s�O� � � �d�j�j�!rc���|jtj|�5|jd�|j �5}|j |j �ddd�r|jdg|���|jd�|jtj|j�|j |j�ddd�y#1swY�}xYw#1swYyxYw)N�lambdar~r#) r�r9r@rhrvr�rEr�rV)r�r%rts r� visit_Lambdaz_Unparser.visit_Lambda�s��� � � ��!1�!1�4� 8� �J�J�x� �����F�� � �d�i�i�(�!���� � �3�(��(� �J�J�t� � � � � � 0� 0�$�)�)� <� �M�M�$�)�)� $�9� 8� ���9� 8�s$�"C'�C�A3C'�C$ � C'�'C0c��|j|j�|jr|jd|jz�yy�Nr�)rhrz�asnamer�s r� visit_aliasz_Unparser.visit_alias�s3�� � � �4�9�9�� �;�;� �J�J�v�� � �+� ,� rc��|j|j�|jr-|jd�|j|j�yyr)r�� context_expr� optional_varsrhr�s r�visit_withitemz_Unparser.visit_withitem�s@�� � � �d�'�'�(� � � � �J�J�v� � �M�M�$�,�,� -� rc�L�|jd�|j|j�|jr,|j d�|j|j�|j �5|j|j �ddd�y#1swYyxYw)Nzcase r�)rqr��pattern�guardrhr{rVr�s r�visit_match_casez_Unparser.visit_match_case�sd�� � � �'�� � � �d�l�l�#� �:�:� �J�J�v� � �M�M�$�*�*� %� �Z�Z�\� �M�M�$�)�)� $��\�\�s �5B�B#c�:�|j|j�yr*)r�r-r�s r�visit_MatchValuez_Unparser.visit_MatchValue�s�� � � �d�j�j�!rc�:�|j|j�yr*)rxr-r�s r�visit_MatchSingletonz_Unparser.visit_MatchSingleton�s�� ���T�Z�Z�(rc����jdd�5�j�fd��j|j�ddd�y#1swYyxYw)Nrcrlc�&���jd�Srfrgr(s�rriz/_Unparser.visit_MatchSequence..�r�r)rrbr��patternsr�s` r�visit_MatchSequencez_Unparser.visit_MatchSequence�s8��� �\�\�#�s� #� �O�O�(�$�-�-���� �$� #� #�r~c�L�|j}|�d}|jd|���y)N�_r)rzrh)r�r%rzs r�visit_MatchStarz_Unparser.visit_MatchStar�s'���y�y�� �<��D� � � �Q�t�f�:�rc �8���fd�}�jdd�5|j}�j�fd�|t||jd���|j }|�'|r�j d��j d|���ddd�y#1swYyxYw) Nc�v��|\}}�j|��jd��j|�yrr�)�pairr��pr�s �r�write_key_pattern_pairz<_Unparser.visit_MatchMapping..write_key_pattern_pair�s0����D�A�q� �M�M�!� � �J�J�t� � �M�M�!� rr^r_c�&���jd�Srfrgr(s�rriz._Unparser.visit_MatchMapping..�r�rT��strictr_r)rrIrbrLr&�restrh)r�r%r/rIr3s` r�visit_MatchMappingz_Unparser.visit_MatchMapping�s���� � �\�\�#�s� #��9�9�D� �O�O�(�&��D�$�-�-��5� � �9�9�D�����J�J�t�$�� � �R��v�;�'�$� #� #�s �A.B�Bc �����jtj|j��j |j��j dd�5|j }�j�fd��j|�|j}|rD�fd�}|r�jd��j�fd�|t||jd���ddd�y#1swYyxYw) Nrarbc�&���jd�Srfrgr(s�rriz,_Unparser.visit_MatchClass..�r�rc�Z��|\}}�j|�d���j|�y)Nr`)rhr�)r-r�rr�s �r�write_attr_patternz6_Unparser.visit_MatchClass..write_attr_pattern�s*���$(�M�D�'��J�J�$��q�z�*��M�M�'�*rr_c�&���jd�Srfrgr(s�rriz,_Unparser.visit_MatchClass..�s���D�J�J�t�,rTr1) r�r9rOrxr�rr&rb� kwd_attrsrhrL� kwd_patterns)r�r%r&�attrsr8s` r�visit_MatchClassz_Unparser.visit_MatchClass�s���� ���K�,�,�d�h�h�7� � � �d�h�h�� �\�\�#�s� #��}�}�H� �O�O�(�$�-�-�� ��N�N�E��+� ��J�J�t�$����,�&���t�0�0��>��$� #� #�s �A?C!�!C*c���|j}|j}|�|jd�y|�|j|j�y|jtj |�5|j tj|j�|j|j�|jd|j���ddd�y#1swYyxYw)Nr)r�) rzrrhr�r9r@r�rFr�)r�r%rzrs r� visit_MatchAsz_Unparser.visit_MatchAs�s����y�y���,�,�� �<� �J�J�s�O� �_� �J�J�t�y�y� !��$�$�[�%5�%5�t�<��#�#�K�O�O�T�\�\�B�� � �d�l�l�+�� � �T�$�)�)��-�.�=�<�<�s �+A$C�C!c�6���jtj|�5�jtjj �g|j ����j �fd��j|j �ddd�y#1swYyxYw)Nc�&���jd�S)Nz | rgr(s�rriz)_Unparser.visit_MatchOr..s���D�J�J�u�$5r)r�r9rFr�r<r&rbr�r�s` r� visit_MatchOrz_Unparser.visit_MatchOr�sb��� � � ����$� 7� �D� � � ��� 4� 4� 6� G���� G� �O�O�5�t�}�}�d�m�m� T�8� 7� 7�s �A$B�B)r^r*)F)�rsr�r�r�r�rbrlrnrqrhrrvr{rr�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�rr rr rrrr r"r&r(r%r-r/r3r7rRrKrOrZrQrcror�rxr�r}r�r�r�r�r�r�r�r�r�r�r9rCrLr�r�r�rJrKrIrFrGrHrMr�� frozensetr�r�r�r�r�rBrAr�r�r�r�r�r�r�r�r�rrrrrrrr!r#r'r*r4r=r?rB� __classcell__)rrs@rrTrT�s�����.3�"� �H�� 1� "��'��'��#� �� �����!� Q�=�1�� )�  �%�%�#�$�"� &�M�M�%�"� &�&� ���O�$�J�J�*�*�&� &� .�1�1� %�:�4+�1�:�"V� &� $�%�"�'�-� +�+�$+�%� %�&1�E�$/�LFQ�8� 27�hL�&Q�$�T� $� -�P�#� #� #� #� %�'� ��,6��%��c� B�D���� � � � � � � � � � �O� (�������������� �E�"� � � � � � � � � � � � � � � � � ������� �_�_� � � � � � ��������� �W�%�L�&�$���������� �F�!��4�(�G� +���{�~�~�F�� [� �!�$*� "� �%�$�+� 15�f"� %�-� .� %�"�)�� � (�(�. /�UrrTc�8�t�}|j|�Sr*)rTr�)�ast_objrgs r�unparserGs���{�H� �>�>�'� "�"r)r rrrrc��|tvr7t|xt�|<}ddl}|jd|��td��|St d|�d���)Nrr�r�r�zmodule 'ast' has no attribute 'rP)�_deprecated_globals�globalsr�r�r�ro)rzr-r�s r� __getattr__rK s`�� �"�"�"5�d�";�;�� �$��%������4�&�M�#<�W� � �� � �:�4�&��B� C�Crc�v�ddl}|jd��}|jd|jd��ddd � �|jd d d dd��|jdddd��|jdddd��|jddtdd��|j �}|j 5}|j�}ddd�t|j j|j|j� �}tt||j|j�!��y#1swY�lxYw)"Nrz python -m ast)�prog�infile�rbr �?rvz$the file to parse; defaults to stdin)r,�nargs�default�helpz-mz--mode�exec)rT�singler� func_typez(specify what kind of code must be parsed)rR�choicesrSz--no-type-commentsT� store_falsez)don't add information about type comments)rR�actionrSz-az--include-attributes� store_truez:include attributes such as line numbers and column offsets)rYrSz-iz--indentr z'indentation of nodes (number of spaces))r,rRrS)r )r}rY)�argparse�ArgumentParser� add_argument�FileTyper.� parse_argsrN�readrrzr�no_type_comments�printr�r}rY)r[�parserrErNr�trees r�mainres6��� � $� $�/� $� :�F� ����x�'8�'8�d�'8�'C�3� #�C��E� ����h�� G�G��I� ���,�d�=�H��J� ����4�\�.��/� ����j�s�A�F��H� � � � �D� ��������� � �����)�)�4�9�9�D�DY�DY� Z�D� �$�t��(?�(?�� � � T�U� ��s �3D/�/D8�__main__)z rT)TF)r\)Tr*)Xr��sys�re�_ast� contextlibrr�enumrrrrrXr�r�r�r�r�r�r�rr�r�r�r�r��objectr�r�r�r�r�r+r�r�r�r��propertyr�rr,r�rr rrrrrr.r/r0rS�bytes�boolr�r�r�rmrrr"r;r)r,r%�modr.� expr_contextr2r4r6ru� float_info� max_10_exprwr9�_SINGLE_QUOTESrGrRrTrGrJ�poprIrKrers)rzs0r�rvs���4 � ��2�,�,�5��t�5�,8$�v@��@�F�" �F�. � ��0�� � �3�4� � ��05�"�J �7(�&�7(�t8�k�8�xU� ����x��������)�Y�/�H�J��)�Y�/�H�J�1�4�1�62� �(�d���(�d���H����8�t�� 6�x�4� 6�� ��#�u�g� ��#�� �E�8��4��:�t�$� �t�C�y�l� � ��$����  �.���J���� �5� �U��� �7���I�z� ��%�C�%��E�� 3�u�3� �u�f�����,� �5�E�J�:�C�:�:�l�:�:�|�:�:�L�:� ��c�n�n�/�/�!�3�4� 4�� �g������>��� �/��/��/� �lU� �lU�\!#�D��C�� �'�)�-�-�� ��C��� D�V�0 �z���F���Qs�H<