File: //opt/alt/python27/lib/python2.7/site-packages/nose/inspector.pyc
�
�fPc           @   s�   d  Z  d d l Z d d l Z d d l Z d d l Z d d l Z d d l Z y d d l m Z Wn! e	 k
 r� d d l m Z n Xe j
 e � Z d �  Z
 d d � Z d �  Z d d
 d	 �  �  YZ d S(   s�   Simple traceback introspection. Used to add additional information to
AssertionErrors in tests, so that failure messages may be more informative.
i����N(   t   StringIOc         C   s�  t  j d |  � x |  j r( |  j }  q W|  j } t |  � \ } } t | | � \ } } t t j d j	 | � � � } t
 | j | j � } x� | r:y+ x$ t
 j | j � D] } | | �  q� WWns t
 j k
 r5}	 t  j d |	 � | j d � | d 8} t t j d j	 | � � � } t
 | j | j � } q� n XPq� Wg  }
 | j r�| j j d � } d } xL | D]A }
 | | k r�|
 j d |
 � n |
 j d |
 � | d 7} qiWn  d j	 |
 � S(	   s�   Inspect a traceback and its frame, returning source for the expression
    where the exception was raised, with simple variable replacement performed
    and the line on which the exception was raised marked with '>>'
    s   inspect traceback %st    s   Tokenizer error: %si    i   s   
s   >>  s       (   t   logt   debugt   tb_nextt   tb_framet   tbsourcet   find_inspectable_linesR    t   textwrapt   dedentt   joint   Expandert   f_localst	   f_globalst   tokenizet   generate_tokenst   readlinet
   TokenErrort   popt   expanded_sourcet   splitt   append(   t   tbt   framet   linest   exc_linet
   inspect_linest	   mark_linet   srct   expt   tokt   et   paddedt	   exp_linest   ept   line(    (    s?   /opt/alt/python27/lib/python2.7/site-packages/nose/inspector.pyt   inspect_traceback   s<