ok

Mini Shell

Direktori : /opt/alt/python37/lib/python3.7/site-packages/raven/utils/__pycache__/
Upload File :
Current File : //opt/alt/python37/lib/python3.7/site-packages/raven/utils/__pycache__/stacks.cpython-37.pyc

B

��Y9'�@s�dZddlmZmZddlZddlZddlZddlZddlZddl	m
Z
ddlmZe�
d�Zddd�Zdd	d
�Zdd�Zd
d�Zddd�Ze
dfdd�Zd dd�Zd!dd�Ze
ddfdd�ZdS)"z�
raven.utils.stacks
~~~~~~~~~~~~~~~~~~~~~~~~~~

:copyright: (c) 2010-2012 by the Sentry Team, see AUTHORS for more details.
:license: BSD, see LICENSE for more details.
�)�absolute_import�divisionN)�	transform)�	iteritemszcoding[:=]\s*([-\w.]+)c	Csd}|dk	rRt|d�rRy|�|�}Wnttfk
r@d}YnX|dk	rR|��}|dkr�yt�|�}Wnttfk
r�dSX|s�dStd||�}t	|d|t
|��}yBdd�|||�D�}||�d�}	d	d�||d|�D�}
Wntk
�rdSXt
|�t
|	�t
|
�fS)
z�
    Returns context_lines before and after lineno from file.
    Returns (pre_context_lineno, pre_context, context_line, post_context).
    N�
get_source)NNNr�cSsg|]}|�d��qS)z
)�strip)�.0�line�r�C/opt/alt/python37/lib/python3.7/site-packages/raven/utils/stacks.py�
<listcomp>Bsz'get_lines_from_file.<locals>.<listcomp>z
cSsg|]}|�d��qS)z
)r)r	r
rrrr
Gs)�hasattrr�ImportError�IOError�
splitlines�	linecache�getlines�OSError�max�min�lenr�
IndexError�slim_string)�filename�linenoZ
context_lines�loader�module_name�sourceZlower_boundZupper_bound�pre_context�context_line�post_contextrrr�get_lines_from_files8
r"cCs"y||Stk
r|SXdS)z�
    f_locals is not guaranteed to have .get(), but it will always
    support __getitem__. Even if it doesn't, we return ``default``.
    N)�	Exception)�f_locals�key�defaultrrr�_getitem_from_frameUsr'csDt�d�r�j}nt�d�r$�j}nt���t�fdd�|�D��S)zu
    Given something that closely resembles a dictionary, we attempt
    to coerce it into a propery dictionary.
    �iterkeys�keysc3s|]}|�|fVqdS)Nr)r	�k)�dictishrr�	<genexpr>lszto_dict.<locals>.<genexpr>)rr(r)�
ValueError�dict)r+�mr)r+r�to_dict`s

r0ccsJxD|rDt|d�rDt|jdi�}t|d�s<|jt|dd�fV|j}qWdS)z�
    Given a traceback object, it will iterate over all
    frames that do not contain the ``__traceback_hide__``
    local variable.
    �tb_framer$�__traceback_hide__�	tb_linenoN)r�getattrr1r'�tb_next)�tbr$rrr�iter_traceback_framesos

r7ccsV|st��dd�}x<dd�|D�D]*\}}t|di�}t|d�rDq$||fVq$WdS)z�
    Given an optional list of frames (defaults to current stack),
    iterates over all frames that do not contain the ``__traceback_hide__``
    local variable.
    rNcss|]}|d|dfVqdS)r�Nr)r	�frrrr,�sz$iter_stack_frames.<locals>.<genexpr>r$r2)�inspect�stackr4r')�frames�framerr$rrr�iter_stack_frames�s
r>ic	Cs�t|dd�}|sdSt|t�s@yt|�}Wntk
r>dSXi}d}xDt|�D]8\}}||�}tt|��}|||krR|||<||7}qRW|S)Nr$r)r4�
isinstancer.r0r#rr�repr)	r=�transformerZmax_var_sizer$�f_varsZf_sizer*�vZv_sizerrr�get_frame_locals�s"
rD�cCs\d}g}g}x4|D],}|d7}|�d�r4|�|�q|�|�qW||krN|S||}t|�}t||d�}|r�t|d�}	x~||	|	�D]0}|�dd�|�dd�|�dd�|d8}q�Wn:x8|D]0}|�dd�|�dd�|�dd�|d8}q�W|�s|S||}
t|
d�}	x<||	|	�D]*}|�dd�|�dd�|�dd��q*W|S)	z~
    Removes various excess metadata from middle frames which go beyond
    ``frame_allowance``.

    Returns ``frames``.
    rrZin_appr8�varsNrr!)�get�appendrr�int�pop)r<�frame_allowanceZ
frames_lenZ
app_framesZ
system_framesr=Z	remainingZ	app_countZsystem_allowanceZhalf_maxZ
app_allowancerrr�slim_frame_data�sD


rL�cCs4|s|St|�|kr(|d|d�dS|d|�S)N�z...)r)�value�lengthrrrr�s
rTc	Cs�d}g}�x�|D�]�}t|ttf�r.|\}}n
|}|j}t|di�}	t|	d�rPqt|di�}
t|dd�}|r~|jj}|jj}
nd}d}
t|
d�}t|
d�}|r�|d	8}|dk	r�|r�t	||d
||�\}}}n
d\}}}yBt
j|�dd	�d
j
}|�|�tjd�d
d	�d�tj�}Wntk
�r0|}YnX|�s<|}|||�pHd|
�pPd|d	d�}|�r|t||d�}|�r|||d<|dk	�r�|�|||d��|�|�qWdt||d�i}|S)a
    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.
    Tr$r2�	f_globals�f_codeN�
__loader__�__name__r�)NNN�.rr8���z	<unknown>)�abs_pathr�module�functionr)rArF)rr r!r<)rK)r?�list�tuple�f_linenor4r'rR�co_filename�co_namer"�sys�modules�split�__file__�rsplit�os�sep�lstripr#rD�updaterHrL)r<rA�capture_localsrKr2�resultZ
frame_infor=rr$rQrRrXrZrrrr r!�
base_filenamerZframe_resultrBZ	stackinforrr�get_stack_info�sb






&


rl)NN)N)N)rE)rM)�__doc__Z
__future__rrr:r�rerer`Zraven.utils.serializerrZraven.utils.compatr�compileZ
_coding_rer"r'r0r7r>rDrLrrlrrrr�<module>s&

=


4


Zerion Mini Shell 1.0