Your IP : 216.73.216.85
ש�WK; � @ s1 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 d d l Z d d l Z d d l Z y
e j
Z
Wn e k
r� e j Z
Yn Xd Z d d � Z
e
d d � Z d d
� Z d d � Z d
d d d � Z d d d � Z d d � Z d d d d � Z d d d d d d � Z d S)a"
Represent an exception with a lot of information.
Provides 2 useful functions:
format_exc: format an exception into a complete traceback, with full
debugging instruction.
format_outer_frames: format the current position in the stack call.
Adapted from IPython's VerboseTB.
� N� � c C s� y t j j | � SWn� t k
r+ � Yn� y t | � SWn� t k
rS � Ynw yL t | d d � } | r{ t | � St | d d � } | r� d t | � SWn t k
r� � Yn d SYn XYn XYn Xd S)z(Hopefully pretty robust repr equivalent.�__name__N� __class__z%s instancezUNRECOVERABLE REPR FAILURE)�pydoc�text�repr�KeyboardInterrupt�getattr� safe_repr)�value�name�klass� r �D/opt/alt/python35/lib/python3.5/site-packages/joblib/format_stack.pyr * s*
r c C s d | | � S)Nz=%sr )r r r r r �eq_reprG s r c C sJ g } t � } x4 | D], } | | k r | j | � | j | � q W| S)a� uniq_stable(elems) -> list
Return from an iterable, a list of all the unique elements in the input,
but maintaining the order in which they first appear.
A naive solution to this problem which just makes a dictionary with the
elements as keys fails to respect the stability condition, since
dictionaries are unsorted by nature.
Note: All elements in the input must be hashable.
)�set�append�add)�elems�unique�
unique_set�nnr r r �uniq_stableL s
r c C sv g } xi | D]a \ } } } } } } | j j d d � } t | t � rO | } | j | | | | | | f � q
W| S)z�Try to fix the filenames in each record from inspect.getinnerframes().
Particularly, modules loaded from within zip files have useless filenames
attached to their code object, and inspect.getinnerframes() just uses it.
�__file__N)� f_globals�get�
isinstance�strr ) �records�
fixed_records�frame�filename�line_no� func_name�lines�index� better_fnr r r �fix_frame_records_filenamesb s r( � c C s� d \ } } } t t j | | � � } | | d � } y1 | d d } | d k sc | j d � rg | SWn t k
r| Yn Xt j | � } t | � t | � k s� t � x� t | � D]� \ }
\ } } }
}
| d | d } t
| d � } | | } t j | � | | � } | d k r1d g | | } t | � | k r^| d g | t | � 7} t
| |
� } | | | <| d | | | <| | | <t | � | |
<q� W| | d � S)
N� � � r r) z<ipython console>z<string>�
)r* r+ r, )r( �inspect�getinnerframes�endswith�
IndexError� traceback�
extract_tb�len�AssertionError� enumerate�max� linecache�getlines�list�tuple)�etb�context� tb_offset�LNUM_POS� LINES_POS� INDEX_POSr � rec_check�rname�aux�i�file�lnum�_�
maybeStart�start�endr% �bufr r r �_fixed_getframesw s4
%
rM c C s d } g } | | } x� | D]� } | | k r� | t t | � � } | d k rf d | d d } n0 | d k r{ d } n | d k r� d } n d } | t | � }
n d
| | f }
d |
| f } | j | � | r� | | k r� | j | d � | d } q W| S)
N� � �-z-> r* z> r) �>� z%*sz%s %sr- )r4 r r )rG r&