Viewing File: /opt/alt/python35/lib64/python3.5/lib2to3/fixes/__pycache__/fix_except.cpython-35.opt-1.pyc



Yf
@sdZddlmZddlmZddlmZddlmZmZm	Z	m
Z
mZmZddZ
Gdd	d	ejZd
S)aFixer 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)AssignAttrNameis_tupleis_listsymsccs\xUt|D]G\}}|jtjkr
|jdjdkr
|||dfVq
WdS)Nexceptr)	enumeratetyper

except_clausechildrenvalue)Znodesinr=/opt/alt/python35/lib64/python3.5/lib2to3/fixes/fix_except.pyfind_exceptssrc@s(eZdZdZdZddZdS)	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}xt|D]\}}t|jdkrD|jdd\}}	}
|	jtdd	d
|
jtjkrt|j	d	d
}|
j
}d|_|
j||j
}|j}
x-t|
D]\}}t
|tjrPqWt|
sCt|
rdt|t|td}nt||}x.t|
d|D]}|jd
|qW|j||qD|
jdkrDd
|
_qDWdd|jddD||}tj|j|S)NcSsg|]}|jqSr)clone).0rrrr
<listcomp>2s	z'FixExcept.transform.<locals>.<listcomp>tailcSsg|]}|jqSr)r)rZchrrrr4s	Zcleanupasprefix argsrcSsg|]}|jqSr)r)rcrrrr\s	)r
rlenrreplacerrrNAMEnew_namerrr

isinstancerZNoderr	rrreversedZinsert_child)selfZnodeZresultsr
rZtry_cleanuprZe_suiteEZcommaNZnew_NtargetZsuite_stmtsrZstmtZassignZchildrrrr	transform/s6		
	!
(zFixExcept.transformN)__name__
__module____qualname__Z
BM_compatibleZPATTERNr/rrrrr$srN)__doc__r!rZpgen2rrZ
fixer_utilrrrrr	r
rZBaseFixrrrrr<module>s.
Back to Directory File Manager