Your IP : 216.73.216.213


Current Path : /opt/alt/python27/lib/python2.7/site-packages/py/_code/
Upload File :
Current File : //opt/alt/python27/lib/python2.7/site-packages/py/_code/_assertionnew.pyo

�
%q�]c@s$dZddlZddlZddlZddlmZmZejjd�r�ej	dXkr�dYZ
dZZed1�e
D��Z
ed2�eD��Zd3�Zd4�Znd5�Zd6�Zd7efd8��YZed9�Zdd:�Zd;�Zid<ej6d=ej6d>ej6d?ej6d@ej6dAej6dBej6dCej6dDej 6dEej!6dFej"6dGej#6dHej$6dIej%6dJej&6dKej'6dLej(6dMej)6dNej*6dOej+6dPej,6dQej-6Z.idRej/6dSej06dTej16dUej26Z3dVej4fdW��YZ5dS([s�
Find intermediate evalutation results in assert statements through builtin AST.
This should replace _assertionold.py eventually.
i����N(t_format_explanationtBuiltinAssertionErrortjavaiitBoolOptBinOptUnaryOptLambdatIfExptDicttListComptGeneratorExptYieldtComparetCalltReprtNumtStrt	Attributet	SubscripttNametListtTupletFunctionDeftClassDeftReturntDeletetAssignt	AugAssigntPrinttFortWhiletIftWithtRaiset	TryExceptt
TryFinallytAsserttImportt
ImportFromtExectGlobaltExprtPasstBreaktContinueccs|]}tt|�VqdS(N(tgetattrtast(t.0tname((sG/opt/alt/python27/lib/python2.7/site-packages/py/_code/_assertionnew.pys	<genexpr>sccs|]}tt|�VqdS(N(R-R.(R/R0((sG/opt/alt/python27/lib/python2.7/site-packages/py/_code/_assertionnew.pys	<genexpr>scCs
|jtkS(N(t	__class__t_expr_nodes(tnode((sG/opt/alt/python27/lib/python2.7/site-packages/py/_code/_assertionnew.pyt_is_ast_exprscCs
|jtkS(N(R1t_stmt_nodes(R3((sG/opt/alt/python27/lib/python2.7/site-packages/py/_code/_assertionnew.pyt_is_ast_stmtscCst|tj�S(N(t
isinstanceR.texpr(R3((sG/opt/alt/python27/lib/python2.7/site-packages/py/_code/_assertionnew.pyR4scCst|tj�S(N(R7R.tstmt(R3((sG/opt/alt/python27/lib/python2.7/site-packages/py/_code/_assertionnew.pyR6 stFailurecBseZdZdd�ZRS(s#Error found while interpreting AST.tcCstj�|_||_dS(N(tsystexc_infotcausetexplanation(tselfR?((sG/opt/alt/python27/lib/python2.7/site-packages/py/_code/_assertionnew.pyt__init__'s(t__name__t
__module__t__doc__RA(((sG/opt/alt/python27/lib/python2.7/site-packages/py/_code/_assertionnew.pyR:$scCsetj|�}t|�}y|j|�Wn(tk
rVtj�d}t|�SX|radSdS(Nis�(assertion failed, but when it was re-run for printing intermediate values, it did not fail.  Suggestions: compute assert expression before the assert or use --no-assert)(R.tparsetDebugInterpretertvisitR:R<R=t
getfailure(tsourcetframetshould_failtmodtvisitortfailure((sG/opt/alt/python27/lib/python2.7/site-packages/py/_code/_assertionnew.pyt	interpret,s
cCs7|dkr*tjjtjd��}nt||�S(Ni(tNonetpytcodetFrameR<t	_getframeRO(toffending_lineRJ((sG/opt/alt/python27/lib/python2.7/site-packages/py/_code/_assertionnew.pytrun9scCs�t|j�}|jd}t|�rs|j�}|sJ|jd�n|dcd|f7<dj|�}nd|jdj|f}|jd�r�|d}n|S(	NiR;is << %ss
s%s: %ssAssertionError: assert i(	RR?R>tstrt
splitlinestappendtjoinRBt
startswith(RNR?tvaluetlinesttext((sG/opt/alt/python27/lib/python2.7/site-packages/py/_code/_assertionnew.pyRH>s

t|t^t&s<<s>>t+t-t*t/s//t%s==s!=t<s<=t>s>=s**tissis nottinsnot insnot %ss~%ss-%ss+%sRFcBs�eZdZd�Zd�Zdd�Zd�Zd�Zd�Zd�Z	d	�Z
d
�Zd�Zd�Z
d
�Zd�Zd�Zd�ZRS(s;Interpret AST nodes to gleam useful debugging information. cCs
||_dS(N(RJ(R@RJ((sG/opt/alt/python27/lib/python2.7/site-packages/py/_code/_assertionnew.pyRAqscCs�t|�rytj|�}|j|�}y|jj|�}Wntk
r\t��nX|jj|�}||fSt	|�r�tj
|g�}|j|d�}y|jj|�Wntk
r�t��nXdSt
d|f��dS(Ntexecscan't handle %s(NN(R4R.t
Expressiont_compileRJtevalt	ExceptionR:treprR6tModuletexec_RPtAssertionError(R@R3RLtcotresultR?((sG/opt/alt/python27/lib/python2.7/site-packages/py/_code/_assertionnew.pyt
generic_visitts$




RncCst|d|�S(Ns<assertion interpretation>(tcompile(R@RItmode((sG/opt/alt/python27/lib/python2.7/site-packages/py/_code/_assertionnew.pyRm�scCs|j|j�S(N(RGR\(R@R8((sG/opt/alt/python27/lib/python2.7/site-packages/py/_code/_assertionnew.pyt
visit_Expr�scCs%x|jD]}|j|�q
WdS(N(tbodyRG(R@RLR9((sG/opt/alt/python27/lib/python2.7/site-packages/py/_code/_assertionnew.pytvisit_Module�scCs�|j|�\}}d|jf}|j|�}y|jj|�}Wntk
rct}nX|sw|j|fS||fS(Ns%r in locals() is not globals()(RvtidRmRJRnRotFalse(R@R0R?RuRIRttlocal((sG/opt/alt/python27/lib/python2.7/site-packages/py/_code/_assertionnew.pyt
visit_Name�s


cCsP|j}|j|�\}}x�t|j|j�D]�\}}|j|�\}}t|j}	d||	|f}
d|	f}|j|�}y"|jj	|d|d|�}
Wnt
k
r�t|
��nXy|
s�PnWntk
r��nPnX||}}q4Wt
jj}|rF||	||�}|rF|}
qFn|
|
fS(Ns%s %s %ss#__exprinfo_left %s __exprinfo_rightt__exprinfo_leftt__exprinfo_right(tleftRGtziptopstcomparatorstoperator_mapR1RmRJRnRoR:tKeyboardInterruptRQRRt_reprcompare(R@tcompR�tleft_explanationtleft_resulttoptnext_optnext_explanationtnext_resultt	op_symbolR?RIRtRutrcomptres((sG/opt/alt/python27/lib/python2.7/site-packages/py/_code/_assertionnew.pyt
visit_Compare�s8	"
	




cCs�t|jtj�}g}xC|jD]8}|j|�\}}|j|�||kr%Pq%q%W|rmdppd}d|j|�d}||fS(Ns or s and t(t)(R7R�R.tOrtvaluesRGRYRZ(R@tbooloptis_ortexplanationstoperandR?RuR0((sG/opt/alt/python27/lib/python2.7/site-packages/py/_code/_assertionnew.pytvisit_BoolOp�s
cCs�t|jj}|j|j�\}}||f}|j|d�}y|jj|d|�}Wntk
r�t	|��nX||fS(Nt__exprinfo_expr(R�(
t	unary_mapR�R1RGR�RmRJRnRoR:(R@tunarytpatterntoperand_explanationtoperand_resultR?RtRu((sG/opt/alt/python27/lib/python2.7/site-packages/py/_code/_assertionnew.pyt
visit_UnaryOp�s

cCs�|j|j�\}}|j|j�\}}t|jj}d|||f}d|f}|j|�}	y"|jj|	d|d|�}
Wnt	k
r�t
|��nX||
fS(Ns
(%s %s %s)s#__exprinfo_left %s __exprinfo_rightR�R�(RGR�trightR�R�R1RmRJRnRoR:(R@tbinopR�R�tright_explanationtright_resulttsymbolR?RIRtRu((sG/opt/alt/python27/lib/python2.7/site-packages/py/_code/_assertionnew.pytvisit_BinOp�s	



cCs|j|j�\}}g}i|d6}g}x]|jD]R}|j|�\}}	dt|�f}
|	||
<|j|
�|j|�q;Wx{|jD]p}|j|j�\}}	dt|�f}
|	||
<d|j}|j||
f�|j||f�q�W|jrk|j|j�\}}	d}
|	||
<|jd|
f�|jd|f�n|j	r�|j|j	�\}}	d}
|	||
<|jd|
f�|jd|f�ndj
|�}
d	||
f}dj
|�}d
|f}|j|�}y|jj
||�}Wntk
rIt|��nXd}|jj|�}||||f}||fS(Nt__exprinfo_funcs
__exprinfo_%ss%s=%%st__exprinfo_stars*%st__exprinfo_kwdss**%ss, s%s(%s)s__exprinfo_func(%s)s
%s
{%s = %s
}(RGtfunctargstlenRYtkeywordsR\targtstarargstkwargsRZRmRJRnRoR:Rp(R@tcalltfunc_explanationR�targ_explanationstnst	argumentsR�targ_explanationt
arg_resulttarg_nametkeywordtkeyword_sourcetargs_explainedR?R�RIRtRuR�trep((sG/opt/alt/python27/lib/python2.7/site-packages/py/_code/_assertionnew.pyt
visit_Call�sT




	
	


cCsXd}||j|jf}|j|�}y|jj|�SWntk
rStSXdS(Ns*%r not in globals() and %r not in locals()(R|RmRJRnRoR}(R@R0R�RIRt((sG/opt/alt/python27/lib/python2.7/site-packages/py/_code/_assertionnew.pyt_is_builtin_names
cCsrt|jtj�s"|j|�S|j|j�\}}d||jf}d|jf}|j|�}y|j	j
|d|�}Wntk
r�t|��nXd|j	j
|�|j	j
|�||jf}d}||jf}|j|�}y|j	j
|d|�}Wntk
r3t}nX|rh|j	j
|�}	d}
|
|	|	|f}n||fS(Ns%s.%ss__exprinfo_expr.%sR�s%s
{%s = %s.%s
}s.%r in getattr(__exprinfo_expr, '__dict__', {})s
%s
{%s = %s
}(R7tctxR.tLoadRvRGR\tattrRmRJRnRoR:RptTrue(R@R�tsource_explanationt
source_resultR?RIRtRut
from_instanceR�R�((sG/opt/alt/python27/lib/python2.7/site-packages/py/_code/_assertionnew.pytvisit_Attributes2



cCs�|j|j�\}}|jd�rF|jd�rF|dd!}nd|f}|s�y
t�Wq�tk
r�t|��q�Xn||fS(NsFalse
{False =s
ii����s	assert %s(RGttestR[tendswithRRoR:(R@tassrtttest_explanationttest_resultR?((sG/opt/alt/python27/lib/python2.7/site-packages/py/_code/_assertionnew.pytvisit_Assert8s


c	Cs�|j|j�\}}d|f}tjdtj�d|jjd|jj�}tj|j|d|jd|j�}tj	|g�}|j
|d�}y|jj|d|�Wnt
k
r�t|��nX||fS(Ns... = %sR�tlinenot
col_offsetRk(RGR\R.RR�R�R�RttargetsRqRmRJRrRoR:(	R@tassigntvalue_explanationtvalue_resultR?R0t
new_assignRLRt((sG/opt/alt/python27/lib/python2.7/site-packages/py/_code/_assertionnew.pytvisit_AssignEs

(RBRCRDRARvRmRyR{RR�R�R�R�R�R�R�R�R�(((sG/opt/alt/python27/lib/python2.7/site-packages/py/_code/_assertionnew.pyRFns 										,				
(iii(RRRRRRR	R
RRR
RRRRRRRR(RRRRRRRRRRR R!R"R#R$R%R&R'R(R)R*R+R,(6RDR<R.RQtpy._code.assertionRRtplatformR[tversion_infot_exprst_stmtstsetR2R5R4R6RoR:R}RORPRVRHtBitOrtBitXortBitAndtLShifttRShifttAddtSubtMulttDivtFloorDivtModtEqtNotEqtLttLtEtGttGtEtPowtIstIsNottIntNotInR�tNottInverttUSubtUAddR�tNodeVisitorRF(((sG/opt/alt/python27/lib/python2.7/site-packages/py/_code/_assertionnew.pyt<module>sh!