Your IP : 216.73.216.213


Current Path : /opt/alt/python35/lib/python3.5/site-packages/joblib/__pycache__/
Upload File :
Current File : //opt/alt/python35/lib/python3.5/site-packages/joblib/__pycache__/format_stack.cpython-35.opt-1.pyc



ש�WK;�@s1dZddlZddlZddlZddlZddlZddlZddlZddlZddl	Z	y
ej
Z
Wnek
r�ejZ
YnXdZdd�Z
e
dd�Zd	d
�Zdd�Zd
ddd�Zddd�Zdd�Zdddd�Zdddddd�ZdS)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� �cCs�ytjj|�SWn�tk
r+�Yn�yt|�SWn�tk
rS�YnwyLt|dd�}|r{t|�St|dd�}|r�dt|�SWn tk
r��YndSYnXYnXYnXdS)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*



rcCsd||�S)Nz=%sr)rrrrr�eq_reprGsrcCsJg}t�}x4|D],}||kr|j|�|j|�qW|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)ZelemsZuniqueZ
unique_setZnnrrr�uniq_stableLs	

rc	Csvg}xi|D]a\}}}}}}|jjdd�}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)	�recordsZ
fixed_records�frame�filename�line_no�	func_name�lines�index�	better_fnrrr�fix_frame_records_filenamesbsr#�cCs�d	\}}}ttj||��}||d�}y1|dd}|dksc|jd�rg|SWntk
r|YnXtj|�}	x�t|	�D]�\}
\}}}
}
|d|d}t|d�}||}t	j
|�||�}|dkrdg||}t|�|kr@|dg|t|�7}t||
�}|||<|d|||<|||<t
|�||
<q�W||d�S)
N���rr$z<ipython console>z<string>�
)r%r&r')r#�inspectZgetinnerframes�endswith�
IndexError�	traceback�
extract_tb�	enumerate�max�	linecache�getlines�len�list�tuple)�etb�context�	tb_offset�LNUM_POS�	LINES_POS�	INDEX_POSrZ	rec_checkZrnameZaux�i�file�lnum�_�
maybeStart�start�endr �bufrrr�_fixed_getframesws2
%


rCcCsd}g}||}x�|D]�}||kr�|tt|��}|dkrfd|dd}	n0|dkr{d}	n|dkr�d}	nd	}	|	t|�}
nd
||f}
d|
|f}|j|�|r�||kr�|j|d�|d}qW|S)
N���-z-> r%z> r$�>�z%*sz%s %sr()r2rr)r=r!r �lvalsZ
numbers_width�resr;�lineZpadZmarkerZnumrrr�_format_traceback_lines�s*

		
rLc*sg}tjj}x�|D]�\}}}}}}y|rF||�pId}Wntk
raYnX|jd�r�|dd�d}|}	tj|�\}
}}}
|dkr�d}nUy,d|tj|
|||
dt�f}Wn&t	k
rt
d�d	|}YnXg���fd
d��d�_||gtj
d
d�}y%xt|�D]}�|�q_WWn\tttfk
r�YnBtjk
r�}zd||f}t
|�WYdd}~XnXt��}g}x�|D]�}|jdd�d}||jjkr�||
j�krYytt||
��}Wq_d}Yq_Xnd}|}|jd||f�q�W|r�dtdtj|�f}nd}ddd|	|f}|dkr�|j|�q|jd|djt||||��f�qW|S)N�?z.pycr&z.pyrHzin %s%sZformatvaluez+
Joblib's exception reporting continues...
z'in %s(***failed resolving arguments***)cs�|dkr@y�dd7<d�_dSWntk
r?YnX|tjkr�|tjkr��jr��d|7<d�_q��j|�n|tjkr�t�dS)a�Stateful tokeneater which builds dotted names.

            The list of names it appends to (from the enclosing scope) can
            contain repeated composite names.  This is unavoidable, since
            there is no way to disambiguate partial dotted structures until
            the full list is known.  The caller is responsible for pruning
            the final list of duplicates before using it.�.r$TNF���rO)�	name_contr+�tokenize�NAME�keyword�kwlistr�NEWLINE)�
token_type�tokenr@rArK)�names�
tokeneaterrrrY�s
	
	z"format_records.<locals>.tokeneaterFcSs%|||d�}|dd7<|S)Nrr$r)r<r=�getlinerKrrr�
linereadersz"format_records.<locals>.linereaderz�An unexpected error occurred while tokenizing input file %s
The following traceback may be corrupted or invalid
The error message is: %s
rNr$rZ	undefinedz%s = %sz%s%sz
%sz	%s
%s %s
�K���)�os�path�abspath�OSErrorr*r)ZgetargvaluesZformatargvaluesr�KeyError�printrPr0rZ�generate_tokensr+�UnicodeDecodeError�SyntaxErrorrQ�
TokenErrorr�split�f_code�co_varnames�keysr�evalr�INDENT�joinrL)r�framesr`rr<r=�funcr r!�link�argsZvarargsZvarkw�localsZcallr[rW�msgZ_mZunique_namesrIZ	name_fullZ	name_baserr
�levelr)rXrYr�format_records�sn
	

#	

 !rvr'cCs�y
|j}Wntk
r!YnXdtjj�ddtj}tjtj��}dtj	�}d|ddt
t|��t
|�||ddt
t|��t
|�|f}yt|||�}	Wn�t
d�d	SYnXytt||f�\}
}Wn@ttj�d
d�}}tt||f�\}
}YnXd|
|fg}t|	�}
d
|dj|
�d	j|d�fS)a Return a nice text document describing the traceback.

        Parameters
        -----------
        etype, evalue, etb: as returned by sys.exc_info
        context: number of lines of the source file to plot
        tb_offset: the number of stack frame not to use (0 = use all)

    zPython rz: zPID: %iz
%s%s%s
%s%s%srr\z@
Unfortunately, your original traceback can not be constructed.
rHNr%z%s: %sz%s
%s
%sr()r�AttributeError�sys�versionrh�
executable�timeZctimer^�getpidr2rrCrc�map�exc_inforvrn)�etypeZevaluer5r6r7ZpyverZdate�pid�headrZ	etype_strZ
evalue_strZ	exceptionrorrr�
format_excKs2

"$'

	 r�TcCs�d
\}}}tjtj��}t�}x|t|�D]n\}	\}
}}}
}}|
jjdd�}t|t�r�|}|j	d�r�|dd�d}|r�t
jj|�dkr�|
dkr�P|d
|d}t
|d�}||}tj|�||�}|dkr2dg||}t|�|kr_|dg|t|�7}t||	�}|||<|d
|||<|||<|jt|��q:Wdjt|||d���S)Nr%r&r'rz.pycz.pyziplib.py�
safe_execfile�runcoder$rr()r%r&r'r])r�r�rO)r)ZgetouterframesZcurrentframer3r.rrrrr*r^r_�basenamer/r0r1r2rr4rnrv)r6Zstack_startZ	stack_endZignore_ipythonr8r9r:r�outputr;rrrrr r!r"r?r@rArBrrr�format_outer_frames|s8	(


r�z        )�__doc__r)rSr0r^rrxr{rQr,rdrwrmrrrr#rCrLrvr�r�rrrr�<module>s0


$�1