ÿØÿà JFIF      ÿÛ „ 	 ( %!1!%)+//.383,7(-.+



-%%-////---/-.+/--+------/------/--0+--/-/-----.-----ÿÀ  ¥2" ÿÄ               ÿÄ J  	     ! 1AQ"aq2‘#BR‚¡ÁÑ3br’¢±Âð$CSƒ²á4c“%DsÓñÿÄ              ÿÄ *        !1AQa‘"2q3±ð#b¡ÿÚ   ? ¼QxJQaÍuò¸Zö Úü8,ÐÚú
"SSn<rçù–´âE—^ªBÖ9À\†¸ÔÁT­ÃÛ5
ëd´³Í#Ý;Þ38œî ¶H£M:wÎ3…³…âpÔF&‚FK¸9„â4àGEõªfÿ ‘ñ(ßw­pŽF|È¥ù®häðÍÑ¶¹‘[ÒinÙW¶ùñY˜Q{›K"išÒ[Ú8žë\F¹@-?v"ÔU”,ìöžkÿ {I‡£šÍ?e
ríV
..............................................................................................................................................................................
.............................................................................                                                  
                                                                                                                                                                                     ÿØÿà JFIF      ÿÛ „ 	 ( %!1!%)+//.383,7(-.+



-%%-////---/-.+/--+------/------/--0+--/-/-----.-----ÿÀ  ¥2" ÿÄ               ÿÄ J  	     ! 1AQ"aq2‘#BR‚¡ÁÑ3br’¢±Âð$CSƒ²á4c“%DsÓñÿÄ              ÿÄ *        !1AQa‘"2q3±ð#b¡ÿÚ   ? ¼QxJQaÍuò¸Zö Úü8,ÐÚú
"SSn<rçù–´âE—^ªBÖ9À\†¸ÔÁT­ÃÛ5
ëd´³Í#Ý;Þ38œî ¶H£M:wÎ3…³…âpÔF&‚FK¸9„â4àGEõªfÿ ‘ñ(ßw­pŽF|È¥ù®häðÍÑ¶¹‘[ÒinÙW¶ùñY˜Q{›K"išÒ[Ú8žë\F¹@-?v"ÔU”,ìöžkÿ {I‡£šÍ?e
ríV
..............................................................................................................................................................................
.............................................................................                                                  
                                                                                                                                                                                     
Yc           @`  s   d  Z  d d l m Z m Z d d l Z d d l Z d d l Z d d l Z d d l Z d d l	 m
 Z
 d d l m Z e j d  Z d d d  Z d d  Z d	   Z d
   Z d d  Z e
 d d  Z d d  Z d d  Z e
 e d d  Z d S(   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    (   t   absolute_importt   divisionN(   t	   transform(   t	   iteritemss   coding[:=]\s*([-\w.]+)c         C`  s  d } | d k	 rr t | d  rr y | j |  } Wn t t f k
 rS d } n X| d k	 rr | j   } qr n  | d k r y t j |   } Wq t t f k
 r d SXn  | s d St	 d | |  } t
 | d | t |   } ym g  | | | !D] } | j d  ^ q }	 | | j d  }
 g  | | d | !D] } | j d  ^ q:} Wn t k
 rjd SXt |	  t |
  t |  f S(	   s   
    Returns context_lines before and after lineno from file.
    Returns (pre_context_lineno, pre_context, context_line, post_context).
    t
   get_sourcei    i   s   
N(   NNN(   NNN(   NNN(   t   Nonet   hasattrR   t   ImportErrort   IOErrort
   splitlinest	   linecachet   getlinest   OSErrort   maxt   mint   lent   stript
   IndexErrort   slim_string(   t   filenamet   linenot   context_linest   loadert   module_namet   sourcet   lower_boundt   upper_boundt   linet   pre_contextt   context_linet   post_context(    (    sC   /opt/alt/python27/lib/python2.7/site-packages/raven/utils/stacks.pyt   get_lines_from_file   s8    
&.		c         C`  s%   y |  | SWn t  k
 r  | SXd S(   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(   t   f_localst   keyt   default(    (    sC   /opt/alt/python27/lib/python2.7/site-packages/raven/utils/stacks.pyt   _getitem_from_frameU   s    c         `  s_   t    d  r   j } n' t    d  r6   j } n t     t   f d   |   D  S(   su   
    Given something that closely resembles a dictionary, we attempt
    to coerce it into a propery dictionary.
    t   iterkeyst   keysc         3`  s   |  ] } |   | f Vq d  S(   N(    (   t   .0t   k(   t   dictish(    sC   /opt/alt/python27/lib/python2.7/site-packages/raven/utils/stacks.pys	   <genexpr>l   s    (   R   R%   R&   t
   ValueErrort   dict(   R)   t   m(    (   R)   sC   /opt/alt/python27/lib/python2.7/site-packages/raven/utils/stacks.pyt   to_dict`   s    c         c`  sj   xc |  re t  |  d  re t |  j d i   } t | d  sY |  j t |  d d  f Vn  |  j }  q Wd S(   s   
    Given a traceback object, it will iterate over all
    frames that do not contain the ``__traceback_hide__``
    local variable.
    t   tb_frameR!   t   __traceback_hide__t	   tb_linenoN(   R   t   getattrR.   R$   R   t   tb_next(   t   tbR!   (    (    sC   /opt/alt/python27/lib/python2.7/site-packages/raven/utils/stacks.pyt   iter_traceback_frameso   s
    c         c`  sp   |  s t  j   d }  n  xP d   |  D D]> \ } } t | d i   } t | d  r] q* n  | | f Vq* Wd S(   s   
    Given an optional list of frames (defaults to current stack),
    iterates over all frames that do not contain the ``__traceback_hide__``
    local variable.
    i   c         s`  s#   |  ] } | d  | d f Vq d S(   i    i   N(    (   R'   t   f(    (    sC   /opt/alt/python27/lib/python2.7/site-packages/raven/utils/stacks.pys	   <genexpr>   s    R!   R/   N(   t   inspectt   stackR1   R$   (   t   framest   frameR   R!   (    (    sC   /opt/alt/python27/lib/python2.7/site-packages/raven/utils/stacks.pyt   iter_stack_frames   s    i   c   	      C`  s   t  |  d d   } | s d  St | t  sS y t |  } WqS t k
 rO d  SXn  i  } d } x_ t |  D]Q \ } } | |  } t t |   } | | | k  rl | | | <| | 7} ql ql W| S(   NR!   i    (	   R1   R   t
   isinstanceR+   R-   R    R   R   t   repr(	   R9   t   transformert   max_var_sizeR!   t   f_varst   f_sizeR(   t   vt   v_size(    (    sC   /opt/alt/python27/lib/python2.7/site-packages/raven/utils/stacks.pyt   get_frame_locals   s"    
i   c         C`  s  d } g  } g  } xD |  D]< } | d 7} | j  d  rH | j |  q | j |  q W| | k ri |  S| | } t |  } t | | d  } | r t | d  }	 x | |	 |	 !D]@ } | j d d  | j d d  | j d d  | d 8} q WnK xH | D]@ } | j d d  | j d d  | j d d  | d 8} qW| sS|  S| | }
 t |
 d  }	 xF | |	 |	 !D]6 } | j d d  | j d d  | j d d  q|W|  S(	   s~   
    Removes various excess metadata from middle frames which go beyond
    ``frame_allowance``.

    Returns ``frames``.
    i    i   t   in_appi   t   varsR   R   N(   t   gett   appendR   R   t   intt   popR   (   R8   t   frame_allowancet
   frames_lent
   app_framest   system_framesR9   t	   remainingt	   app_countt   system_allowancet   half_maxt   app_allowance(    (    sC   /opt/alt/python27/lib/python2.7/site-packages/raven/utils/stacks.pyt   slim_frame_data   sD    


i   c         C`  s4   |  s
 |  St  |   | k r, |  | d  d S|  |  S(   Ni   s   ...(   R   (   t   valuet   length(    (    sC   /opt/alt/python27/lib/python2.7/site-packages/raven/utils/stacks.pyR      s
    c         C`  s  t  } g  } xV|  D]N} t | t t f  r= | \ } } n | } | j } t | d i   }	 t |	 d  rs q n  t | d i   }
 t | d d  } | r | j j	 } | j j
 } n d } d } t |
 d  } t |
 d  } | r | d 8} n  | d k	 r+| r+t | | d | |  \ } } } n d \ } } } yY t j | j d	 d  d
 j } | j | j t j d  d
 d  d j t j  } Wn t k
 r| } n X| s| } n  i | d 6| d 6| pd d 6| pd d 6| d d 6} | r#t | d | } | r#| | d <q#n  | d k	 rT| j i | d 6| d 6| d 6 n  | j |  q Wi t | d | d 6} | 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_globalst   f_codet
   __loader__t   __name__i   i   t   .i    i   it   abs_pathR   t   modules	   <unknown>t   functionR   R=   RE   R   R   R   RJ   R8   N(   NNN(   t   TrueR;   t   listt   tuplet   f_linenoR1   R$   R   RW   t   co_filenamet   co_nameR   t   syst   modulest   splitt   __file__t   rsplitt   ost   sept   lstripR    RC   t   updateRG   RS   (   R8   R=   t   capture_localsRJ   R/   t   resultt
   frame_infoR9   R   R!   RV   RW   R[   R]   R   R   R   R   R   t   base_filenameR   t   frame_resultR?   t	   stackinfo(    (    sC   /opt/alt/python27/lib/python2.7/site-packages/raven/utils/stacks.pyt   get_stack_info   sf    
	$ 3
		(   t   __doc__t
   __future__R    R   R6   R
   t   reRi   Rd   t   raven.utils.serializerR   t   raven.utils.compatR   t   compilet
   _coding_reR   R   R$   R-   R4   R:   RC   RS   R   R^   Rs   (    (    (    sC   /opt/alt/python27/lib/python2.7/site-packages/raven/utils/stacks.pyt   <module>   s&   =		4