ðÕYf ã@s�dZddlmZddlmZddlmZddlmZmZm Z m Z m Z m Z dd„Z Gdd „d ejƒZd S) aªFixer for except statements with named exceptions. The following cases will be converted: - "except E, T:" where T is a name: except E as T: - "except E, T:" where T is not a name, tuple or list: except E as t: T = t This is done because the target of an "except" clause must be a name. - "except E, T:" where T is a tuple or list literal: except E as t: T = t.args é)Úpytree)Útoken)Ú fixer_base)ÚAssignÚAttrÚNameÚis_tupleÚis_listÚsymsccs\xUt|ƒD]G\}}|jtjkr |jdjdkr |||dfVq WdS)NéÚexceptr)Ú enumerateÚtyper Ú except_clauseÚchildrenÚvalue)ZnodesÚiÚn©rú=/opt/alt/python35/lib64/python3.5/lib2to3/fixes/fix_except.pyÚ find_exceptssrc@s(eZdZdZdZdd„ZdS)Ú 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)]) > cCs|j}dd„|dDƒ}dd„|dDƒ}x™t|ƒD]‹\}}t|jƒdkrD|jdd…\}} } | jtdd d ƒƒ| jtjkr·t|j ƒd d ƒ} | j ƒ} d | _ | j| ƒ| j ƒ} |j} x-t | ƒD]\}}t |tjƒrPqWt| ƒsCt| ƒrdt| t| td ƒƒƒ}nt| | ƒ}x.t| d|…ƒD]}|jd |ƒqŠW|j||ƒqD| j d krDd | _ qDWdd„|jdd…Dƒ||}tj|j|ƒS)NcSsg|]}|jƒ‘qSr)Úclone)Ú.0rrrrú 2s z'FixExcept.transform..ÚtailcSsg|]}|jƒ‘qSr)r)rZchrrrr4s ZcleanupééÚasÚprefixú ÚÚargsr cSsg|]}|jƒ‘qSr)r)rÚcrrrr\s é)r rÚlenrÚreplacerrrÚNAMEÚnew_namerrr Ú isinstancerZNoderr rrÚreversedZ insert_child)ÚselfZnodeZresultsr rZ try_cleanuprZe_suiteÚEZcommaÚNZnew_NÚtargetZ suite_stmtsrZstmtZassignZchildrrrrÚ transform/s6      ! (zFixExcept.transformN)Ú__name__Ú __module__Ú __qualname__Z BM_compatibleZPATTERNr/rrrrr$s rN)Ú__doc__r!rZpgen2rrZ fixer_utilrrrrr r rZBaseFixrrrrrÚs .