ok

Mini Shell

Direktori : /lib/python2.7/site-packages/jinja2/
Upload File :
Current File : //lib/python2.7/site-packages/jinja2/debug.pyo

�
��Rc@sxdZddlZddlZddlmZddlmZmZddlm	Z	ddl
mZmZm
Z
yddlmZWnek
r�dZnXyddUWn-ek
r�d	Znek
r�d
ZnXdefd��YZd
�Zdefd��YZdd�Zdd�Zdd�Zd�Zd�ZdZedkrty
e�ZWnnX[ndS(sQ
    jinja2.debug
    ~~~~~~~~~~~~

    Implements the debug interface for Jinja.  This module does some pretty
    ugly stuff with the Python traceback system in order to achieve tracebacks
    with correct line numbers, locals and contents.

    :copyright: (c) 2010 by the Jinja Team.
    :license: BSD, see LICENSE for more details.
i����N(t
TracebackType(tmissingt
internal_code(tTemplateSyntaxError(t	iteritemstreraiset	code_type(ttproxysraise TypeError, 'foo'sraise __jinja_exception__[1]s4raise __jinja_exception__[0], __jinja_exception__[1]tTracebackFrameProxycBsGeZdZd�Zed��Zd�Zed��Zd�ZRS(sProxies a traceback frame.cCs||_d|_dS(N(ttbtNonet_tb_next(tselfR	((s0/usr/lib/python2.7/site-packages/jinja2/debug.pyt__init__'s	cCs|jS(N(R(R((s0/usr/lib/python2.7/site-packages/jinja2/debug.pyttb_next+scCsStdk	rFy#t|j|r'|jp*d�WqFtk
rBqFXn||_dS(N(ttb_set_nextR
R	t	ExceptionR(Rtnext((s0/usr/lib/python2.7/site-packages/jinja2/debug.pytset_next/s#
cCsd|jjjkS(Nt__jinja_template__(R	ttb_framet	f_globals(R((s0/usr/lib/python2.7/site-packages/jinja2/debug.pytis_jinja_frame:scCst|j|�S(N(tgetattrR	(Rtname((s0/usr/lib/python2.7/site-packages/jinja2/debug.pyt__getattr__>s(	t__name__t
__module__t__doc__R
tpropertyRRRR(((s0/usr/lib/python2.7/site-packages/jinja2/debug.pyR$s		cs8t|��tdkr�S�fd�}tt|�S(NcsV|dkrt�|d�S|dkr<�j||�nt�|�||�SdS(Nt__getattribute__Rit__setattr__(s__getattribute__s__getattr__(RR(t	operationtargstkwargs(tproxy(s0/usr/lib/python2.7/site-packages/jinja2/debug.pytoperation_handlerFs
(RRR
R(tframeR$((R#s0/usr/lib/python2.7/site-packages/jinja2/debug.pytmake_frame_proxyBs
tProcessedTracebackcBs\eZdZd�Zdd�Zed�Zed��Z	ed��Z
ed��ZRS(s?Holds a Jinja preprocessed traceback for printing or reraising.cCsh||_||_||_d}x3|jD](}|dk	rM|j|�n|}q+W|jd�dS(N(texc_typet	exc_valuetframesR
R(RR(R)R*tprev_tbR	((s0/usr/lib/python2.7/site-packages/jinja2/debug.pyR
Ss			
cCs;tj|j|j|jdd|�}dj|�j�S(s#Return a string with the traceback.itlimitt(t	tracebacktformat_exceptionR(R)R*tjointrstrip(RR,tlines((s0/usr/lib/python2.7/site-packages/jinja2/debug.pytrender_as_textascCs<ddlm}d||d|�|j�jdd�fS(s<Return a unicode string with the traceback as rendered HTML.i����(trender_tracebacku%s

<!--
%s
-->tfullsutf-8treplace(tjinja2.debugrendererR4R3tdecode(RR5R4((s0/usr/lib/python2.7/site-packages/jinja2/debug.pytrender_as_htmlgscCst|jt�S(s*`True` if this is a template syntax error.(t
isinstanceR)R(R((s0/usr/lib/python2.7/site-packages/jinja2/debug.pytis_template_syntax_erroroscCs|j|j|jdfS(s;Exception info tuple with a proxy around the frame objects.i(R(R)R*(R((s0/usr/lib/python2.7/site-packages/jinja2/debug.pytexc_infotscCs>|jd}t|�tk	r+|j}n|j|j|fS(s'Standard python exc_info for re-raisingi(R*ttypeRR	R(R)(RR	((s0/usr/lib/python2.7/site-packages/jinja2/debug.pytstandard_exc_infoys
N(RRRR
R
R3tFalseR9RR;R<R>(((s0/usr/lib/python2.7/site-packages/jinja2/debug.pyR'Ps	cCsI|\}}}t|t�r6t||�}d}nd}t||�S(s7Creates a processed traceback object from the exc_info.ii(R:Rttranslate_syntax_errorttranslate_exception(R<tsource_hintR(R)R	tinitial_skip((s0/usr/lib/python2.7/site-packages/jinja2/debug.pytmake_traceback�s	cCsU||_t|_|j|df}|j}|dkrBd}nt|||j�S(s4Rewrites a syntax error to please traceback systems.s	<unknown>N(tsourcetTruet
translatedt	__class__R
tfilenamet
fake_exc_infotlineno(terrorRER<RI((s0/usr/lib/python2.7/site-packages/jinja2/debug.pyR@�s				ic	Cs2|d}g}x,t|�D]}|dk	r|j}qqW|}x�|dk	r�|jjtkru|j}qHn|j}|jjjd�}|dk	r�|j|j	�}t
|d |f|j|�d}n|jt
|��|}qHW|st|d|d|d�nt|d|d|�S(s�If passed an exc_info it will automatically rewrite the exceptions
    all the way down to the correct line numbers and frames.
    iRiiN(trangeR
RRtf_codeRRtgettget_corresponding_linenot	tb_linenoRJRItappendR&RR'(	R<RCR	R*txt
initial_tbRttemplateRK((s0/usr/lib/python2.7/site-packages/jinja2/debug.pyRA�s*
		
cBs�|\}}}|dk	r�|jjj�}|jd�}|rQ|j�}ni}xFe|�D]8\}	}
|	jd�rd|
ek	rd|
||	d<qdqdW|j	dd�ni}i|d6|d6|d d6dd6}e
d|d	e|d
�}y�|dkrd}
nJ|jjj
}|dkr9d
}
n&|jd�rYd|d}
nd}
ed|j|j|j|j|j|j|j||
|j|jdd�}WnnXy|||fdUWn ej�}|dj}nX|d |fS(s!Helper for `translate_exception`.tcontexttl_it__jinja_exception__Rt__file__Rs
itexecRUtrootstop-level template codetblock_s
block "%s"iiN(((R
Rtf_localstcopyROtget_allRt
startswithRtpoptcompiletraise_helperRNtco_nameRt
co_nlocalstco_stacksizetco_flagstco_codet	co_conststco_namestco_varnamestco_firstlinenot	co_lnotabtsysR<R(R<RIRKR(R)R	treal_localstctxtlocalsRtvaluetglobalstcodetlocationtfunctiontnew_tb((s0/usr/lib/python2.7/site-packages/jinja2/debug.pyRJ�sP
			csgddl�ddlm�t�jd�r:�j}n	�j}d�jfd��Y}d|fd�j|�fg|_	tt
d	�r�d�jfd
��Y}d�j|�fd�j|�fd|fd�j|�fg|_	nd
|fd��Y�d�j��fd�j|�fd�jfd�jfg�_	���fd�}|S(s�This function implements a few ugly things so that we can patch the
    traceback objects.  The function returned allows resetting `tb_next` on
    any python traceback object.  Do not attempt to use this on non cpython
    interpreters
    i����N(RtPy_InitModule4_64t	_PyObjectcBseZRS((RR(((s0/usr/lib/python2.7/site-packages/jinja2/debug.pyRyst	ob_refcnttob_typet
getobjectscBseZRS((RR(((s0/usr/lib/python2.7/site-packages/jinja2/debug.pyRy$st_ob_nextt_ob_prevt
_TracebackcBseZRS((RR(((s0/usr/lib/python2.7/site-packages/jinja2/debug.pyR-sRRttb_lastiRQcs�t|��o'|dkp't|��s9td��n�jt|��}|jdk	r��jt|j��}|jd8_n|dkr��j���|_n6�jt|��}|jd7_�j|�|_dS(s0Set the tb_next attribute of a traceback object.s/tb_set_next arguments must be traceback objectsiN(	R:R
t	TypeErrortfrom_addresstidRRztPOINTERtpointer(R	Rtobjtold(RRtctypes(s0/usr/lib/python2.7/site-packages/jinja2/debug.pyR6s(R�ttypesRthasattrt	pythonapitc_int64tc_intt	StructureR�t_fields_Rn(t_Py_ssize_tRyR((RRR�s0/usr/lib/python2.7/site-packages/jinja2/debug.pyt_init_ugly_craps*			(RRnR.R�Rtjinja2.utilsRRtjinja2.exceptionsRtjinja2._compatRRRt__pypy__RtImportErrorR
tSyntaxErrorRcR�tobjectRR&R'RDR@RARJR�R(((s0/usr/lib/python2.7/site-packages/jinja2/debug.pyt<module>s>


	

	4,	E	@


Zerion Mini Shell 1.0