B
    u9aò.  ã               @   s¼   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d dl	Z	dd„ Z
g Zdd„ Zdd„ Zdd	„ Zd
d„ Zdd„ Zddd„Zddd„ZG dd„ dƒZeƒ jZddd„ZdS )é    Nc               C   s   dS )Na'  <!--: spam
Content-Type: text/html

<body bgcolor="#f0f0f8"><font color="#f0f0f8" size="-5"> -->
<body bgcolor="#f0f0f8"><font color="#f0f0f8" size="-5"> --> -->
</font> </font> </font> </script> </object> </blockquote> </pre>
</table> </table> </table> </table> </table> </font> </font> </font>© r   r   r   ú/usr/lib/python3.7/cgitb.pyÚreset#   s    r   c             C   s   | rd|  d S dS d S )Nz<small>z</small>Ú r   )Útextr   r   r   Úsmall.   s    r   c             C   s   | rd|  d S dS d S )Nz<strong>z	</strong>r   r   )r   r   r   r   Ústrong4   s    r   c             C   s   | rd|  d S dS d S )Nz<font color="#909090">z</font>r   r   )r   r   r   r   Úgrey:   s    r	   c             C   s†   | |krd||  fS | |j kr,d|j |  fS d|j kr~|j d }t|ƒti ƒkrf| |kr~d||  fS nt|| ƒr~dt|| ƒfS d tfS )NÚlocalÚglobalÚ__builtins__Úbuiltin)Ú	f_globalsÚtypeÚhasattrÚgetattrÚ	__UNDEF__)ÚnameÚframeÚlocalsÚbuiltinsr   r   r   Úlookup@   s    



r   c             C   sÔ   g d d dt f\}}}}}x¶t | ¡D ]¨\}}	}
}}|tjkr>P |tjkr¦|	tjkr¦|dkr„|t k	r¤t||	t ƒ}| ||	 ||f¡ qÈt	|	||ƒ\}}| |	||f¡ n"|	dkrÀ||d 7 }|}nd\}}|	}q$W |S )Nr   Ú.)Nr   )
r   ÚtokenizeÚgenerate_tokensÚNEWLINEÚNAMEÚkeywordÚkwlistr   Úappendr   )Úreaderr   r   ÚvarsZ	lasttokenÚparentÚprefixÚvalueZttypeÚtokenÚstartÚendÚlineÚwherer   r   r   ÚscanvarsP   s"    
 r*   é   c       "         sš  | \}}}t |tƒr|j}dtj ¡ d  d tj }t t ¡ ¡}dt	j
 dtt	j
 t|ƒ¡ƒ dd|d | ¡ d	 }d
tdƒ d }g }	t ||¡}
xJ|
D ]@\}‰ }}}}ˆ rÚtj ˆ ¡‰ dˆ t	j
 ˆ ¡f }nd ‰ }t |¡\}}}}d}|dkr.dtt	j
 |¡ƒ tj||||dd„ d }i ‰|gf‡ ‡fdd„	}t|||ƒ}dd||f g}|d k	r|| }xŽ|D ]†}tddtt|ƒƒ  t|ƒ ƒd }|ˆkrÐd|t	j
 |¡f }| d| ¡ n&d|t	j
 |¡f }| dt|ƒ ¡ |d7 }qzW i g  }}x¤|D ]œ\}}} ||kr,qd||< | tk	r |dkrZd | t|ƒ }n*|d!krnt|ƒ}n|t| d"¡d# ƒ }| d$|t	j
 | ¡f ¡ n| |d% ¡ qW | dttd& |¡ƒƒ ¡ |	 d'd( |¡ ¡ q¢W d)tt	j
 t|ƒ¡ƒt	j
 t|ƒ¡f g}!xNt|ƒD ]B}|d d… d*kr6qt	j
 t ||ƒ¡} |! d+||| f ¡ qW |d |	¡ d |!¡ d,t	j
 d t! "|||¡¡¡  S )-NzPython r   z: z<body bgcolor="#f0f0f8">z<big><big>%s</big></big>z#ffffffz#6622aaz<br>z‹
<p>A problem occurred in a Python script.  Here is the sequence of
function calls leading up to the error, in the order they occurred.</p>z<tt>z&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;z&nbsp;</tt>z<a href="file://%s">%s</a>ú?r   zin c             S   s   dt j | ¡ S )Nú=)ÚpydocÚhtmlÚrepr)r$   r   r   r   Ú<lambda>   ó    zhtml.<locals>.<lambda>)Úformatvaluec          
      s4   dˆ| d < zt  ˆ | d ¡S | d  d7  < X d S )Né   r   )Ú	linecacheÚgetline)Úlnum)ÚfileÚ	highlightr   r   r    „   s     zhtml.<locals>.readerz+<tr><td bgcolor="#d8bbff">%s%s %s</td></tr>z<big>&nbsp;</big>z&nbsp;r+   z<tt>=&gt;%s%s</tt>z&<tr><td bgcolor="#ffccee">%s</td></tr>z<tt>&nbsp;&nbsp;%s%s</tt>z<tr><td>%s</td></tr>r4   )r   r   z<em>%s</em> r
   r   éÿÿÿÿz%s&nbsp;= %sz <em>undefined</em>z, zF
<table width="100%%" cellspacing=0 cellpadding=0 border=0>
%s</table>Ú
z	<p>%s: %sÚ_z
<br>%s%s&nbsp;=
%szî


<!-- The above is a description of an error in a Python program, formatted
     for a Web browser because the 'cgitb' module was enabled.  In case you
     are not reading this in a Web browser, here is the original traceback:

%s
-->
)#Ú
isinstancer   Ú__name__ÚsysÚversionÚsplitÚ
executableÚtimeÚctimer.   r/   Úheadingr   ÚescapeÚstrr   ÚinspectÚgetinnerframesÚosÚpathÚabspathÚgetargvaluesÚformatargvaluesr*   ÚlenZ	preformatr   r	   r   r0   ÚjoinÚdirr   Ú	tracebackÚformat_exception)"ÚeinfoÚcontextÚetypeÚevalueÚetbÚpyverÚdateÚheadÚindentÚframesÚrecordsr   r7   ÚfuncÚlinesÚindexÚlinkÚargsÚvarargsÚvarkwr   Úcallr    r!   ÚrowsÚir(   ÚnumÚdoneÚdumpr   r)   r$   Ú	exceptionr   )r8   r9   r   r/   e   s|    

0


$


 



 	r/   c           	      sŽ  | \}}}t |tƒr|j}dtj ¡ d  d tj }t t ¡ ¡}dt	|ƒ||f d }g }t
 ||¡}	x |	D ]–\}
‰ }}}}ˆ r”tj ˆ ¡p–d‰ t
 |
¡\}}}}d}|dkrÖd| t
j||||d	d
„ d }i ‰|gf‡ ‡fdd„	}t||
|ƒ}dˆ |f g}|d k	rL|| }x0|D ](}d| }| || ¡  ¡ |d7 }q W i g  }}xŽ|D ]†\}}}||krtq\d||< |tk	rÒ|dkršd| }n|dkr¶|| d¡d  }| d|tj |¡f ¡ n| |d ¡ q\W | d |¡¡ | dd |¡ ¡ qrW dt	|ƒt	|ƒf g}x8t|ƒD ],}tj t||ƒ¡}| dd||f ¡ q.W |d |¡ d |¡ dd t |||¡¡  S )NzPython r   z: z	%s
%s
%s
z…
A problem occurred in a Python script.  Here is the sequence of
function calls leading up to the error, in the order they occurred.
r,   r   zin c             S   s   dt j | ¡ S )Nr-   )r.   r   r0   )r$   r   r   r   r1   Ô   r2   ztext.<locals>.<lambda>)r3   c          
      s4   dˆ| d < zt  ˆ | d ¡S | d  d7  < X d S )Nr4   r   )r5   r6   )r7   )r8   r9   r   r   r    ×   s     ztext.<locals>.readerz %s %sz%5d r4   r   zglobal r
   r   r:   z%s = %sz
 undefinedr;   z
%s
z%s: %sz

%s%s = %sz    zc

The above is a description of an error in a Python program.  Here is
the original traceback:

%s
)r=   r   r>   r?   r@   rA   rB   rC   rD   rG   rH   rI   rJ   rK   rL   rM   rN   r*   r   Úrstripr   r.   r   r0   rP   rQ   r   rR   rS   ) rT   rU   rV   rW   rX   rY   rZ   r[   r]   r^   r   r7   r_   r`   ra   rc   rd   re   r   rf   r    r!   rg   rh   r(   ri   rj   rk   r   r)   r$   rl   r   )r8   r9   r   r   ¿   s^    





 

 

 r   c               @   s(   e Zd Zddd„Zdd„ Zdd	d
„ZdS )ÚHookr4   Nr+   r/   c             C   s(   || _ || _|| _|ptj| _|| _d S )N)ÚdisplayÚlogdirrU   r?   Ústdoutr8   Úformat)Úselfro   rp   rU   r8   rr   r   r   r   Ú__init__  s
    zHook.__init__c             C   s   |   |||f¡ d S )N)Úhandle)rs   rV   rW   rX   r   r   r   Ú__call__  s    zHook.__call__c       
   	   C   sz  |p
t  ¡ }| jdkr$| j tƒ ¡ | jdkr2tp4t}d}y||| jƒ}W n    d 	t
j|Ž ¡}d}Y nX | jrª|r˜tj |¡}| j d| d ¡ q¶| j |d ¡ n| j d¡ | jd k	rZd	d
g| jdk }tj|| jd\}}y.t |d¡}| |¡ W d Q R X d| }	W n   d| }	Y nX | jdkrJ| j d|	 ¡ n| j |	d ¡ y| j ¡  W n   Y nX d S )Nr/   Fr   Tz<pre>z</pre>
r;   z*<p>A problem occurred in a Python script.
z.txtz.html)ÚsuffixrQ   Úwz*%s contains the description of this error.z*Tried to save traceback to %s, but failed.z
<p>%s</p>
)r?   Úexc_inforr   r8   Úwriter   r/   r   rU   rP   rR   rS   ro   r.   rF   rp   ÚtempfileZmkstemprJ   ÚfdopenÚflush)
rs   ÚinfoÚ	formatterZplainÚdocrw   ÚfdrK   r8   Úmsgr   r   r   ru     s@    

 zHook.handle)r4   Nr+   Nr/   )N)r>   Ú
__module__Ú__qualname__rt   rv   ru   r   r   r   r   rn      s    
rn   r4   c             C   s   t | |||dt_d S )N)ro   rp   rU   rr   )rn   r?   Ú
excepthook)ro   rp   rU   rr   r   r   r   Úenable8  s    r†   )r+   )r+   )r4   Nr+   r/   )rH   r   r5   rJ   r.   r?   r{   rC   r   rR   r   r   r   r   r	   r   r*   r/   r   rn   ru   Zhandlerr†   r   r   r   r   Ú<module>   s*   

Z
A7