Your IP : 216.73.216.213


Current Path : /proc/242857/root/opt/alt/python27/lib/python2.7/site-packages/_pytest/_code/
Upload File :
Current File : //proc/242857/root/opt/alt/python27/lib/python2.7/site-packages/_pytest/_code/source.pyo

�
�mYc@`s%ddlmZmZmZmZddlmZddlZddlZddl	Z	ddl
Z
eZy ddl
Z
ddl
mZWnek
r�dZdZ
nXdefd��YZddejdd�Zd	�Zd
�Zd�Zdd�Zd
�Zedd�Zed�ZdS(i(tabsolute_importtdivisiont
generatorstprint_function(tbisect_rightN(t
PyCF_ONLY_ASTtSourcecB`s�eZdZdZd�Zd�ZdZd�Zd�Z	d�Z
dddd
�Zdd�Ze
d�Ze
d
�Zdd�Zed�Zd�Zddejddd�ZRS(sY a immutable object holding a source code fragment,
        possibly deindenting it.
    ic	O`s<g|_}|jdt�}|jdt�}x|D]�}|sMg}nt|t�rh|j}n�t|ttf�r�g|D]}|jd�^q�}npt|tj	j
�r�|jd�}|rx+|r�|dj�r�Pn|j
�q�Wqnt|d|�j}|r't|�}n|j|�q8WdS(Ntdeindenttrstrips
i����(tlinestgettTruet
isinstanceRttupletlistRtpytbuiltint_basestringtsplittstriptpopt	getsourceRtextend(	tselftpartstkwargsR	tdeRtpartt	partlinestx((sE/opt/alt/python27/lib/python2.7/site-packages/_pytest/_code/source.pyt__init__s*

	%	cC`sLy|j|jkSWn1tk
rGt|t�rCt|�|kStSXdS(N(R	tAttributeErrorRtstrtFalse(Rtother((sE/opt/alt/python27/lib/python2.7/site-packages/_pytest/_code/source.pyt__eq__.s
cC`sbt|t�r|j|S|jdkr8td��nt�}|j|j|j!|_|SdS(Nis!cannot slice a Source with a step(Ni(	RtintR	tsteptNonet
IndexErrorRtstarttstop(Rtkeyt	newsource((sE/opt/alt/python27/lib/python2.7/site-packages/_pytest/_code/source.pyt__getitem__8s	cC`s
t|j�S(N(tlenR	(R((sE/opt/alt/python27/lib/python2.7/site-packages/_pytest/_code/source.pyt__len__BscC`s�dt|�}}x.||krC|j|j�rC|d7}qWx2||krx|j|dj�rx|d8}qGWt�}|j||!|j(|S(s] return new source object with trailing
            and leading blank lines removed.
        ii(R-R	RR(RR(tendtsource((sE/opt/alt/python27/lib/python2.7/site-packages/_pytest/_code/source.pyREs#'	tt icC`s\t|�}t|�}t�}g|jD]}||^q+}|j||j|_|S(se return a copy of the source object with
            'before' and 'after' wrapped around it.
        (RR	(RtbeforetaftertindentR+tlineR	((sE/opt/alt/python27/lib/python2.7/site-packages/_pytest/_code/source.pyt	putaroundRs	 cC`s0t�}g|jD]}||^q|_|S(sl return a copy of the source object with
            all lines indented by the given indent-string.
        (RR	(RR5R+R6((sE/opt/alt/python27/lib/python2.7/site-packages/_pytest/_code/source.pyR5]s	#cC`s#|j||�\}}|||!S(sc return Source statement which contains the
            given linenumber (counted from 0).
        (tgetstatementrange(Rtlinenot	assertionR(R/((sE/opt/alt/python27/lib/python2.7/site-packages/_pytest/_code/source.pytgetstatementescC`sSd|kot|�kns1td��nt||�\}}}||fS(s{ return (start, end) tuple which spans the minimal
            statement region which containing the given lineno.
        islineno out of range(R-R'tgetstatementrange_ast(RR9R:tastR(R/((sE/opt/alt/python27/lib/python2.7/site-packages/_pytest/_code/source.pyR8ls"cC`s#t�}t|j|�|j(|S(s: return a new source object deindented by offset.
            If offset is None then guess an indentation offset from
            the first non-blank line.  Subsequent lines which have a
            lower indentation offset will be copied verbatim as
            they are assumed to be part of multilines.
        (RRR	(RtoffsetR+((sE/opt/alt/python27/lib/python2.7/site-packages/_pytest/_code/source.pyRus		cC`s�yddl}Wntk
r,d�}n
X|j}|rQt|j��}nt|�}y||d�Wn%tk
r��ntk
r�tSXtSdS(sb return True if source is parseable, heuristically
            deindenting it by default.
        iNcS`st|dd�S(Ntasdtexec(tcompile(R((sE/opt/alt/python27/lib/python2.7/site-packages/_pytest/_code/source.pyt<lambda>�R1s
(	tparsertImportErrortsuiteR RtKeyboardInterruptt	ExceptionR!R(RRRCtsyntax_checkerR0((sE/opt/alt/python27/lib/python2.7/site-packages/_pytest/_code/source.pytisparseable�s

	

cC`sdj|j�S(Ns
(tjoinR	(R((sE/opt/alt/python27/lib/python2.7/site-packages/_pytest/_code/source.pyt__str__�sR@cC`s�|s%tjj|�jdd�r�|dkrCtjd�}n|jj|j	}}d|j
}|jj
d7_
|s�|d||f}q�|d|||f}ndj|j
�d}	yt|	|||�}
Wn�tk
r�tj�d}|j
|j }|jr2|jd|jd	�n|jd
|�tdj|��}
|j|
_|j|
_|j|
_|
�nRX|t@r�|
Sg|j
D]}|d^q�}dd||ftjjj|<|
SdS(s� return compiled code object. if filename is None
            invent an artificial filename which displays
            the source/line position of the caller frame.
        tfileiis<%d-codegen s%s:%d>s	%r %s:%d>s
R2t^s*(code was compiled probably from here: %s)N(RtpathtlocaltcheckR&tsyst	_getframetf_codetco_filenametf_linenot_compilecountert	__class__RJR	tcpy_compiletSyntaxErrortexc_infoR9R>tappendttextt	_AST_FLAGtstdt	linecachetcache(Rtfilenametmodetflagtdont_inheritt	_genframetfnR9tbaseR0tcotextmsglinestnewexRR	((sE/opt/alt/python27/lib/python2.7/site-packages/_pytest/_code/source.pyRA�s8%

	

 Ns    s    (t__name__t
__module__t__doc__RVRR#R&t__hash__R,R.RR7R5R!R;R8RRRIRKRt
compiler_flagRA(((sE/opt/alt/python27/lib/python2.7/site-packages/_pytest/_code/source.pyRs$			
		
	
	R@cC`sntdk	r4t|tj�r4t|||||�Stjd�}t|�}|j|||d|�}|S(s� compile the given source to a raw code object,
        and maintain an internal cache which allows later
        retrieval of the source code for the code object
        and any recursively created code objects.
    iReN(	t_astR&RtASTRXRQRRRRA(R0RaRbtflagsRdRetsRh((sE/opt/alt/python27/lib/python2.7/site-packages/_pytest/_code/source.pytcompile_�scC`s�ddl}y|jj|�}Wn�tk
r�y.tjjj|�p\tjjj|�}Wntk
rtdSX|r�tj	j
|�p�d}d}|r�yt|�\}}Wq�t
k
r�q�Xq�nX|j	}|j}||fS(sx Return source location (path, lineno) for the given object.
    If the source cannot be determined return ("", -1)
    iNR1i����(R1i����(t
_pytest._codet_codetCodet	TypeErrorRR^tinspectt
getsourcefiletgetfileRNROR&t
findsourcetIOErrortfirstlineno(tobjt_pytesttcodeRftfspathR9t_((sE/opt/alt/python27/lib/python2.7/site-packages/_pytest/_code/source.pytgetfslineno�s&


		cC`sxytjjj|�\}}Wn!tjjk
r;�ndSXt�}g|D]}|j�^qS|_	||fS(Ni����(Ni����(
RR^RzR}Rt_sysexR&RRR	(R�tsourcelinesR9R0R6((sE/opt/alt/python27/lib/python2.7/site-packages/_pytest/_code/source.pyR}�s	"cK`sXddl}|jj|�}ytj|�}Wntk
rJd}nXt||�S(Nis<"Buggy python version consider upgrading, cannot get source"(RvRwt
getrawcodeRzRtIndentationErrorR(R�RR�tstrsrc((sE/opt/alt/python27/lib/python2.7/site-packages/_pytest/_code/source.pyRs

c
`s�|dkr^xO|D]>}|j�}|j�}|rt|�t|�}PqqWd}n|dkrtt|�Sg}d�}||��y�x�tj�fd��D]�\}}\}}\}}}|t|�kr�Pn|t|�krA||dj�}|j�r1|| j�r1||}n|j|�nx(t	||�D]}	|j||	�qQWq�WWnt
tjfk
r�nX|j|t|��|S(Nics`s0x|D]}|dVqWxtr+dVqWdS(Ns
R1(R(R	R6((sE/opt/alt/python27/lib/python2.7/site-packages/_pytest/_code/source.pytreadline_generators

	c`s
t��S(N(tnext((tit(sE/opt/alt/python27/lib/python2.7/site-packages/_pytest/_code/source.pyRB&R1i(
R&t
expandtabstlstripR-Rttokenizetgenerate_tokenstisspaceR[trangeR�t
TokenErrorR(
R	R>R6RttnewlinesR�R�tslinetelineti((R�sE/opt/alt/python27/lib/python2.7/site-packages/_pytest/_code/source.pyRs8
	
	:
c
C`sddl}g}x�|j|�D]�}t|tj�sLt|tj�r"|j|jd�xHdD]=}t||d�}|rg|j|djdd�qgqgWq"q"W|j
�t||�}||d}|t|�kr�d}	n
||}	||	fS(Niit	finalbodytorelse(R�R�(
R=twalkRRqtstmtt
ExceptHandlerR[R9tgetattrR&tsortRR-(
R9tnodeR=tlRtnametvaltinsert_indexR(R/((sE/opt/alt/python27/lib/python2.7/site-packages/_pytest/_code/source.pytget_statement_startend2:s $
*
	
c
`s�|dkr�t|�}tjdkr4|d7}nyt|ddd�}Wq�tk
r�t|||�\}}d||fSXnt||�\}}|dkr�t|j	�}n||dkrzt
j�}|j	|dj�|_
d	�|j	||!D��y4x-tj�fd
��D]}|j|�q%WWqzt
jtfk
rf|j|}qztk
rvqzXnxE|r�|j	|dj�}	|	jd�s�|	r�|d8}q}Pq}W|||fS(
Niis
R0R@iiics`s|]}|dVqdS(s
N((t.0R((sE/opt/alt/python27/lib/python2.7/site-packages/_pytest/_code/source.pys	<genexpr>isc`s
t��S(N(R�((R�(sE/opt/alt/python27/lib/python2.7/site-packages/_pytest/_code/source.pyRBkR1t#(ii(R&R RQtversion_infoRAt
ValueErrortgetstatementrange_oldR�R-R	RztBlockFinderR�tstartedR�R�t
tokeneatert
EndOfBlockR�tlastRGR�t
startswith(
R9R0R:tastnodetcontentR(R/tblock_finderttokR6((R�sE/opt/alt/python27/lib/python2.7/site-packages/_pytest/_code/source.pyR<Qs:


	
c	C`sWddlm}x-t|dd�D]}|r�|j|}d|krod|krod|krotd��nd|kr�d	|kr�q#q�n|j||d
!}|jdd�dj|�}y||�Wnttt	fk
r�q#nXxHt|d
t
|�d
�D])}|||!}|j�r||fSqWq#Wtd
|f��dS(s� return (start, end) tuple which spans the minimal
        statement region which containing the given lineno.
        raise an IndexError if no such statementrange can be found.
    i(tcompile_commandi����tsuperRRslikely a subclasstasserttraiseis
def xxx():s
 s%no valid source range around line %d N(tcodeopR�R�R	R'tinsertRJRYt
OverflowErrorR�R-RI(	R9R0R:R�R(R6ttrylinest	trysourceR/((sE/opt/alt/python27/lib/python2.7/site-packages/_pytest/_code/source.pyR�|s(
$	$
(t
__future__RRRRtbisectRRQRzR�RRARXRqRR]RDR&tobjectRRpRuR�R}RRR�R!R<R�(((sE/opt/alt/python27/lib/python2.7/site-packages/_pytest/_code/source.pyt<module>s*"

�			+	+