U if @sbddlmZddlmZddlmZddlmZmZmZm Z m Z m Z ddZ Gdddej Zd S) )pytree)token) fixer_base)AssignAttrNameis_tupleis_listsymsccsDt|D]6\}}|jtjkr|jdjdkr|||dfVqdS)Nexceptr) enumeratetyper except_clausechildrenvalue)Znodesinr=/opt/alt/python38/lib64/python3.8/lib2to3/fixes/fix_except.py find_exceptss rc@seZdZdZdZddZdS) 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)]) > cCsx|j}dd|dD}dd|dD}t|D]\}}t|jdkr2|jdd\}} } | tdd d | jtjkr8t| d d } | } d | _ | | | } |j} t | D]\}}t |tjrqqt| st| rt| t| td }n t| | }t| d|D]}|d |q|||q2| j d kr2d | _ q2dd|jddD||}t|j|S)NcSsg|] }|qSrclone).0rrrr 2sz'FixExcept.transform..tailcSsg|] }|qSrr)rZchrrrr4sZcleanupas )prefixargsr cSsg|] }|qSrr)rcrrrr\s)r rlenrreplacerrrNAMEnew_namerr!r isinstancerZNoderr rrreversedZ insert_child)selfZnodeZresultsr rZ try_cleanuprZe_suiteEZcommaNZnew_NtargetZ suite_stmtsrZstmtZassignZchildrrrr transform/s6     zFixExcept.transformN)__name__ __module__ __qualname__Z BM_compatibleZPATTERNr0rrrrr$srN)r"rZpgen2rrZ fixer_utilrrrrr r rZBaseFixrrrrrs