Current File : //snap/core22/current/usr/lib/python3.10/lib2to3/fixes/__pycache__/fix_print.cpython-310.pyc |
o
��bc � @ sl d Z ddlmZ ddlmZ ddlmZ ddlmZ ddlmZm Z m
Z
mZ e�d�Z
G dd � d ej�Zd
S )a Fixer for print.
Change:
'print' into 'print()'
'print ...' into 'print(...)'
'print ... ,' into 'print(..., end=" ")'
'print >>x, ...' into 'print(..., file=x)'
No changes are applied if print_function is imported from __future__
� )�patcomp)�pytree)�token)�
fixer_base)�Name�Call�Comma�Stringz"atom< '(' [atom|STRING|NAME] ')' >c @ s$ e Zd ZdZdZdd� Zdd� ZdS )�FixPrintTzP
simple_stmt< any* bare='print' any* > | print_stmt
c
C s� |sJ �|� d�}|r|�ttd�g |jd�� d S |jd td�ks%J �|jdd � }t|�dkr;t�|d �r;d S d } }}|rR|d t � krR|d d� }d}|rs|d t
�tj
d�krst|�d ksgJ �|d �� }|d
d � }dd� |D �}|r�d
|d _|d us�|d us�|d ur�|d ur�| �|dtt|��� |d ur�| �|dtt|��� |d ur�| �|d|� ttd�|�} |j| _| S )N�bare�print)�prefix� � ���� z>>r � c S s g | ]}|� � �qS � )�clone)�.0�argr r �./usr/lib/python3.10/lib2to3/fixes/fix_print.py�
<listcomp>? s z&FixPrint.transform.<locals>.<listcomp>� �sep�end�file)�get�replacer r r
�children�len�parend_expr�matchr r �Leafr �
RIGHTSHIFTr � add_kwargr �repr)
�self�node�results�
bare_print�argsr r r �l_args�n_stmtr r r � transform% s@
�
zFixPrint.transformc C sN d|_ t�| jjt|�t�tjd�|f�}|r |� t
� � d|_ |� |� d S )Nr �=r )r
r �Node�syms�argumentr r# r �EQUAL�appendr )r'