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/source.pyo

�
%q�]c@s#ddlmZddlmZddlZddlZddlZddlZddlm	Z	e
Zy ddlZddlm
ZWnek
r�dZdZnXdefd��YZdd	ejdd
�Zd�Zd�Zd
�Zdd�Zd�Zedd�Zed�ZdS(i����(t
generators(tbisect_rightN(t
ModuleType(t
PyCF_ONLY_ASTitSourcecBs�eZdZdZd�Zd�Zd�Zd�Zd�Zd�Z	dddd�Z
dd�Zed
�Z
ed�Zdd�Zed�Zd�Zddejddd�ZRS(sY a immutable object holding a source code fragment,
        possibly deindenting it.
    ic	Os<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(	tselftpartstkwargsRtdeRtpartt	partlinestx((s@/opt/alt/python27/lib/python2.7/site-packages/py/_code/source.pyt__init__s*

	%	cCsLy|j|jkSWn1tk
rGt|t�rCt|�|kStSXdS(N(RtAttributeErrorR
tstrtFalse(Rtother((s@/opt/alt/python27/lib/python2.7/site-packages/py/_code/source.pyt__eq__/s
cCsRt|t�r|j|S|jdkr8td��n|j|j|j�SdS(Nis!cannot slice a Source with a step(Ni(	R
tintRtsteptNonet
IndexErrort__getslice__tstarttstop(Rtkey((s@/opt/alt/python27/lib/python2.7/site-packages/py/_code/source.pyt__getitem__7s
cCs
t|j�S(N(tlenR(R((s@/opt/alt/python27/lib/python2.7/site-packages/py/_code/source.pyt__len__?scCs t�}|j||!|_|S(N(RR(RR'tendt	newsource((s@/opt/alt/python27/lib/python2.7/site-packages/py/_code/source.pyR&Bs	cCs�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+RRR(RR'R-tsource((s@/opt/alt/python27/lib/python2.7/site-packages/py/_code/source.pyRGs#'	tt icCs\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((s@/opt/alt/python27/lib/python2.7/site-packages/py/_code/source.pyt	putaroundTs	 cCs0t�}g|jD]}||^q|_|S(sl return a copy of the source object with
            all lines indented by the given indent-string.
        (RR(RR4R.R5((s@/opt/alt/python27/lib/python2.7/site-packages/py/_code/source.pyR4_s	#cCs#|j||�\}}|||!S(sc return Source statement which contains the
            given linenumber (counted from 0).
        (tgetstatementrange(Rtlinenot	assertionR'R-((s@/opt/alt/python27/lib/python2.7/site-packages/py/_code/source.pytgetstatementgscCsSd|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(RR8R9tastR'R-((s@/opt/alt/python27/lib/python2.7/site-packages/py/_code/source.pyR7ns"cCs#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.((s@/opt/alt/python27/lib/python2.7/site-packages/py/_code/source.pyRws		cCs�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.
        i����NcSst|dd�S(Ntasdtexec(tcompile(R((s@/opt/alt/python27/lib/python2.7/site-packages/py/_code/source.pyt<lambda>�R0s
(	tparsertImportErrortsuiteRRtKeyboardInterruptt	ExceptionRR	(RRRBtsyntax_checkerR/((s@/opt/alt/python27/lib/python2.7/site-packages/py/_code/source.pytisparseable�s

	

cCsdj|j�S(Ns
(tjoinR(R((s@/opt/alt/python27/lib/python2.7/site-packages/py/_code/source.pyt__str__�sR?cCs�|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
R1t^s*(code was compiled probably from here: %s)N(R
tpathtlocaltcheckR$tsyst	_getframetf_codetco_filenametf_linenot_compilecountert	__class__RIRtcpy_compiletSyntaxErrortexc_infoR8R=tappendttextt	_AST_FLAGtstdt	linecachetcache(Rtfilenametmodetflagtdont_inheritt	_genframetfnR8tbaseR/tcotextmsglinestnewexRR((s@/opt/alt/python27/lib/python2.7/site-packages/py/_code/source.pyR@�s8%

	

 s    s    N(t__name__t
__module__t__doc__RURR!R*R,R&RR6R4RR:R7R$RR	RHRJRt
compiler_flagR@(((s@/opt/alt/python27/lib/python2.7/site-packages/py/_code/source.pyRs$						
	
	R?cCsntdk	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.
    iRdN(	t_astR$R
tASTRWRPRQRR@(R/R`RatflagsRcRdtsRg((s@/opt/alt/python27/lib/python2.7/site-packages/py/_code/source.pytcompile_�scCs�ytjj|�}Wn�tk
r�y.tjjj|�pPtjjj|�}Wntk
rhdSX|r�tjj	|�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)
    R0i����(R0i����N(R
tcodetCodet	TypeErrorR]tinspectt
getsourcefiletgetfileRMRNR$t
findsourcetIOErrortfirstlineno(tobjRtRetfspathR8t_((s@/opt/alt/python27/lib/python2.7/site-packages/py/_code/source.pytgetfslineno�s$


		cCsxytjjj|�\}}Wn!tjjk
r;�ndSXt�}g|D]}|j�^qS|_	||fS(Ni����(Ni����(
R
R]RwRzRt_sysexR$RRR(R}tsourcelinesR8R/R5((s@/opt/alt/python27/lib/python2.7/site-packages/py/_code/source.pyRz�s	"cKsLtjj|�}ytj|�}Wntk
r>d}nXt||�S(Ns<"Buggy python version consider upgrading, cannot get source"(R
Rtt
getrawcodeRwRtIndentationErrorR(R}Rtstrsrc((s@/opt/alt/python27/lib/python2.7/site-packages/py/_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(Nicss0x|D]}|dVqWxtr+dVqWdS(Ns
R0(R	(RR5((s@/opt/alt/python27/lib/python2.7/site-packages/py/_code/source.pytreadline_generators

	cs
t��S(N(tnext((tit(s@/opt/alt/python27/lib/python2.7/site-packages/py/_code/source.pyRA#R0i(
R$t
expandtabstlstripR+Rttokenizetgenerate_tokenstisspaceRZtrangeR�t
TokenErrorR(
RR=R5RrtnewlinesR�Rtslinetelineti((R�s@/opt/alt/python27/lib/python2.7/site-packages/py/_code/source.pyR
s8
	
	:
c
Csddl}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(Ni����it	finalbodytorelsei(R�R�(
R<twalkR
Rotstmtt
ExceptHandlerRZR8tgetattrR$tsortRR+(
R8tnodeR<tlRtnametvaltinsert_indexR'R-((s@/opt/alt/python27/lib/python2.7/site-packages/py/_code/source.pytget_statement_startend27s $
*
	
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
R/R?iiicss|]}|dVqdS(s
N((t.0R((s@/opt/alt/python27/lib/python2.7/site-packages/py/_code/source.pys	<genexpr>fscs
t��S(N(R�((R�(s@/opt/alt/python27/lib/python2.7/site-packages/py/_code/source.pyRAhR0t#(ii(R$RRPtversion_infoR@t
ValueErrortgetstatementrange_oldR�R+RRwtBlockFinderR�tstartedR�R�t
tokeneatert
EndOfBlockR�tlastRFR�t
startswith(
R8R/R9tastnodetcontentR'R-tblock_finderttokR5((R�s@/opt/alt/python27/lib/python2.7/site-packages/py/_code/source.pyR;Ns:


	
c	CsWddlm}x-t|dd�D]}|r�|j|}d|krod|krod|krotd��nd|kr�d|kr�q#q�n|j||d	!}|jd
d�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_commandtsuperRRslikely a subclasstasserttraiseiis
def xxx():s
 s%no valid source range around line %d N(tcodeopR�R�RR%tinsertRIRXt
OverflowErrorR�R+RH(	R8R/R9R�R'R5ttrylinest	trysourceR-((s@/opt/alt/python27/lib/python2.7/site-packages/py/_code/source.pyR�ys(
$	$
(t
__future__RtbisectRRPRwR�R
ttypesRR@RWRoRR\RCR$tobjectRRnRsR�RzRRR�RR;R�(((s@/opt/alt/python27/lib/python2.7/site-packages/py/_code/source.pyt<module>s,

�				*	+