Your IP : 18.119.142.113
���]
� @ s� d d l m Z d d l m Z d d l m Z d d l m Z m Z m Z m Z m
Z
m Z d d � Z Gd d � d e j
� Z d S)
� )�pytree)�token)�
fixer_base)�Assign�Attr�Name�is_tuple�is_list�symsc c s\ xU t | � D]G \ } } | j t j k r
| j d j d k r
| | | d f Vq
Wd S)N� �exceptr )� enumerate�typer
�
except_clause�children�value)Znodes�i�n� r �//opt/alt/python35/lib64/python3.5/fix_except.py�find_excepts s r c @ s( e Z d Z d Z d Z d d � Z d S)� FixExceptTa1
try_stmt< 'try' ':' (simple_stmt | suite)
cleanup=(except_clause ':' (simple_stmt | suite))+
tail=(['except' ':' (simple_stmt | suite)]
['else' ':' (simple_stmt | suite)]
['finally' ':' (simple_stmt | suite)]) >
c C s | j } d d � | d D� } d d � | d D� } x�t | � D]�\ } } t | j � d k rD | j d d � \ } } }
| j t d d d
�� |
j t j k r�t | j � d d
�} |
j
� } d | _ |
j | � | j
� } | j }
x- t |
� D] \ } } t
| t j � rPqWt |
� sCt |
� rdt | t | t d � � � } n t | | � } x. t |
d | � � D] } | j d
| � q�W| j | | � qD |
j d k rD d
|
_ qD Wd d � | j d d � D� | | } t j | j | � S)Nc S s g | ] } | j � � q Sr )�clone)�.0r r r r �
<listcomp>2 s z'FixExcept.transform.<locals>.<listcomp>�tailc S s g | ] } | j � � q Sr )r )r Zchr r r r 4 s �cleanup� � �as�prefix� � �argsr c S s g | ] } | j � � q Sr )r )r �cr r r r \ s � )r
r �lenr �replacer r r �NAME�new_namer r r
�
isinstancer ZNoder r r r �reversedZinsert_child)�selfZnode�resultsr
r Ztry_cleanupr Ze_suite�EZcomma�NZnew_N�targetZsuite_stmtsr ZstmtZassignZchildr r r r � transform/ s6
!
(zFixExcept.transformN)�__name__�
__module__�__qualname__Z
BM_compatibleZPATTERNr1 r r r r r $ s r N)r"