AlkantarClanX12

Your IP : 18.117.141.69


Current Path : /opt/alt/python27/lib/python2.7/site-packages/raven/utils/
Upload File :
Current File : //opt/alt/python27/lib/python2.7/site-packages/raven/utils/stacks.pyc

�
��Yc@`s�dZddlmZmZddlZddlZddlZddlZddlZddl	m
Z
ddlmZej
d�Zddd�Zdd�Zd	�Zd
�Zdd�Ze
dd
�Zdd�Zdd�Ze
edd�ZdS(s�
raven.utils.stacks
~~~~~~~~~~~~~~~~~~~~~~~~~~

:copyright: (c) 2010-2012 by the Sentry Team, see AUTHORS for more details.
:license: BSD, see LICENSE for more details.
i(tabsolute_importtdivisionN(t	transform(t	iteritemsscoding[:=]\s*([-\w.]+)cC`s�d}|dk	rrt|d�rry|j|�}Wnttfk
rSd}nX|dk	rr|j�}qrn|dkr�ytj|�}Wq�ttfk
r�dSXn|s�dSt	d||�}t
|d|t|��}ymg|||!D]}|jd�^q�}	||jd�}
g||d|!D]}|jd�^q:}Wnt
k
rjdSXt|	�t|
�t|�fS(	s�
    Returns context_lines before and after lineno from file.
    Returns (pre_context_lineno, pre_context, context_line, post_context).
    t
get_sourceiis
N(NNN(NNN(NNN(tNonethasattrRtImportErrortIOErrort
splitlinest	linecachetgetlinestOSErrortmaxtmintlentstript
IndexErrortslim_string(tfilenametlinenot
context_linestloadertmodule_nametsourcetlower_boundtupper_boundtlinetpre_contexttcontext_linetpost_context((sC/opt/alt/python27/lib/python2.7/site-packages/raven/utils/stacks.pytget_lines_from_files8
&.
		cC`s%y||SWntk
r |SXdS(s�
    f_locals is not guaranteed to have .get(), but it will always
    support __getitem__. Even if it doesn't, we return ``default``.
    N(t	Exception(tf_localstkeytdefault((sC/opt/alt/python27/lib/python2.7/site-packages/raven/utils/stacks.pyt_getitem_from_frameUs
c`s_t�d�r�j}n't�d�r6�j}nt���t�fd�|�D��S(su
    Given something that closely resembles a dictionary, we attempt
    to coerce it into a propery dictionary.
    titerkeystkeysc3`s|]}|�|fVqdS(N((t.0tk(tdictish(sC/opt/alt/python27/lib/python2.7/site-packages/raven/utils/stacks.pys	<genexpr>ls(RR%R&t
ValueErrortdict(R)tm((R)sC/opt/alt/python27/lib/python2.7/site-packages/raven/utils/stacks.pytto_dict`scc`sjxc|ret|d�ret|jdi�}t|d�sY|jt|dd�fVn|j}qWdS(s�
    Given a traceback object, it will iterate over all
    frames that do not contain the ``__traceback_hide__``
    local variable.
    ttb_frameR!t__traceback_hide__t	tb_linenoN(RtgetattrR.R$Rttb_next(ttbR!((sC/opt/alt/python27/lib/python2.7/site-packages/raven/utils/stacks.pytiter_traceback_framesos
cc`sp|stj�d}nxPd�|D�D]>\}}t|di�}t|d�r]q*n||fVq*WdS(s�
    Given an optional list of frames (defaults to current stack),
    iterates over all frames that do not contain the ``__traceback_hide__``
    local variable.
    ics`s#|]}|d|dfVqdS(iiN((R'tf((sC/opt/alt/python27/lib/python2.7/site-packages/raven/utils/stacks.pys	<genexpr>�sR!R/N(tinspecttstackR1R$(tframestframeRR!((sC/opt/alt/python27/lib/python2.7/site-packages/raven/utils/stacks.pytiter_stack_frames�sic	C`s�t|dd�}|sdSt|t�sSyt|�}WqStk
rOdSXni}d}x_t|�D]Q\}}||�}tt|��}|||krl|||<||7}qlqlW|S(NR!i(	R1Rt
isinstanceR+R-R RRtrepr(	R9ttransformertmax_var_sizeR!tf_varstf_sizeR(tvtv_size((sC/opt/alt/python27/lib/python2.7/site-packages/raven/utils/stacks.pytget_frame_locals�s"

icC`s�d}g}g}xD|D]<}|d7}|jd�rH|j|�q|j|�qW||kri|S||}t|�}t||d�}|r�t|d�}	x�||	|	!D]@}|jdd�|jdd�|jdd�|d8}q�WnKxH|D]@}|jdd�|jdd�|jdd�|d8}qW|sS|S||}
t|
d�}	xF||	|	!D]6}|jdd�|jdd�|jdd�q|W|S(	s~
    Removes various excess metadata from middle frames which go beyond
    ``frame_allowance``.

    Returns ``frames``.
    iitin_appitvarsRRN(tgettappendRR
tinttpopR(R8tframe_allowancet
frames_lent
app_framest
system_framesR9t	remainingt	app_counttsystem_allowancethalf_maxt
app_allowance((sC/opt/alt/python27/lib/python2.7/site-packages/raven/utils/stacks.pytslim_frame_data�sD




icC`s4|s
|St|�|kr,||d dS|| S(Nis...(R(tvaluetlength((sC/opt/alt/python27/lib/python2.7/site-packages/raven/utils/stacks.pyR�s
cC`s�t}g}xV|D]N}t|ttf�r=|\}}n|}|j}t|di�}	t|	d�rsqnt|di�}
t|dd�}|r�|jj	}|jj
}
nd}d}
t|
d�}t|
d�}|r�|d8}n|dk	r+|r+t||d||�\}}}nd\}}}yYtj
|jd	d�d
j}|j|jtjd�d
d�djtj�}Wntk
r�|}nX|s�|}ni|d
6|d6|p�dd6|
p�dd6|dd6}|r#t|d|�}|r#||d<q#n|dk	rT|ji|d6|d6|d6�n|j|�qWit|d|�d6}|S(s
    Given a list of frames, returns a list of stack information
    dictionary objects that are JSON-ready.

    We have to be careful here as certain implementations of the
    _Frame class do not contain the necessary data to lookup all
    of the information we want.
    R!R/t	f_globalstf_codet
__loader__t__name__iit.iii����tabs_pathRtmodules	<unknown>tfunctionRR=RERRRRJR8N(NNN(tTrueR;tlistttupletf_linenoR1R$RRWtco_filenametco_nameRtsystmodulestsplitt__file__trsplittostseptlstripR RCtupdateRGRS(R8R=tcapture_localsRJR/tresultt
frame_infoR9RR!RVRWR[R]RRRRRt
base_filenameRtframe_resultR?t	stackinfo((sC/opt/alt/python27/lib/python2.7/site-packages/raven/utils/stacks.pytget_stack_info�sf

	
$ 3

	

	(t__doc__t
__future__RRR6R
treRiRdtraven.utils.serializerRtraven.utils.compatRtcompilet
_coding_reRRR$R-R4R:RCRSRR^Rs(((sC/opt/alt/python27/lib/python2.7/site-packages/raven/utils/stacks.pyt<module>s&=		4