Sindbad~EG File Manager
3
�uGh@ � @ sb d Z ddlmZmZ ddlmZ ddlmZmZm Z m
Z
mZmZ ddl
mZ G dd� dej�ZdS ) a� Fixer for 'raise E, V'
From Armin Ronacher's ``python-modernize``.
raise -> raise
raise E -> raise E
raise E, 5 -> raise E(5)
raise E, 5, T -> raise E(5).with_traceback(T)
raise E, None, T -> raise E.with_traceback(T)
raise (((E, E'), E''), E'''), 5 -> raise E(5)
raise "foo", V, T -> warns about string exceptions
raise E, (V1, V2) -> raise E(V1, V2)
raise E, (V1, V2), T -> raise E(V1, V2).with_traceback(T)
CAVEATS:
1) "raise E, V, T" cannot be translated safely in general. If V
is not a tuple or a (number, string, None) literal, then:
raise E, V, T -> from future.utils import raise_
raise_(E, V, T)
� )�pytree�
fixer_base)�token)�Name�Call�is_tuple�Comma�Attr�ArgList)�touch_import_topc @ s e Zd ZdZdZdd� ZdS )�FixRaiseTzB
raise_stmt< 'raise' exc=any [',' val=any [',' tb=any]] >
c
C s� | j }|d j� }|jtjkr2d}| j||� d S t|�rbx t|�rZ|jd jd j� }q<W d|_d|krx|d j� }nd }d|k�rF|d j� }t|�r�dd � |jdd� D �}t ||�}n�|jtj
tjfkr�d
|_t ||g�}nb|jtjkr�|jdkr�nJt
dd
|� d
|_|t� |g}|d k �r2|t� |g7 }t td
�||jd�S |d k �rrd
|_t|td��t|g�g } n|g} tj|jtd�g| |jd�S )N�excz+Python 3 does not support string exceptions� r � �tb�valc S s g | ]}|j � �qS � )�clone)�.0�cr r �B/root/tmp/pip-build-gzoz1_uw/future/libfuturize/fixes/fix_raise.py�
<listcomp>I s z&FixRaise.transform.<locals>.<listcomp>� �Nonezfuture.utilsZraise_)�prefix�with_traceback�raise���)�symsr �typer �STRINGZcannot_convertr �childrenr r �NUMBER�NAME�valuer r r r r
r �NodeZ
raise_stmt)
�self�node�resultsr r
�msgr r �argsZexc_listr r r � transform* sH
zFixRaise.transformN)�__name__�
__module__�__qualname__Z
BM_compatibleZPATTERNr+ r r r r r # s r N)�__doc__Zlib2to3r r Z
lib2to3.pgen2r Zlib2to3.fixer_utilr r r r r r
Zlibfuturize.fixer_utilr ZBaseFixr r r r r �<module> s
Sindbad File Manager Version 1.0, Coded By Sindbad EG ~ The Terrorists