o
    IAf@/                     @   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.10/cgitb.pyreset#   s   r   c                 C      | rd|  d S dS )Nz<small>z</small> r   textr   r   r   small.      r	   c                 C   r   )Nz<strong>z	</strong>r   r   r   r   r   r   strong4   r
   r   c                 C   r   )Nz<font color="#909090">z</font>r   r   r   r   r   r   grey:   r
   r   c                 C   s   	 | |v rd||  fS | |j v rd|j |  fS d|j v rC|j d }t|ti u r7| |v r3d||  fS d tfS t|| rCd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\}}}}}t| D ]V\}}	}
}}|tjkr! |S |tjkrU|	tjvrU|dkrD|t urCt||	t }|||	 ||f n"t	|	||\}}||	||f n|	dkrb||d 7 }|}nd\}}|	}q|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||}
|
D ] \} }}}} rltj  d t	j
 f }nd  }t|\}}}}d}|dkrdtt	j
| }|dkr|tj||||dd d7 }i |gf fdd	}t|||}dd||f g}|d ur|| }|D ]A}tddtt|  t| d }|v rd|t	j
|f }|d|  nd|t	j
|f }|dt|  |d7 }qi g }}|D ]O\}}} ||v rq	d||< | turP|d v r,d!| t| }n|d"kr6t|}n|t|d#d$  }|d%|t	j
| f  q	||d&  q	|dttd'|  |	d(d)|  qPd*tt	j
t|t	j
t|f g}!t|D ]!}|d d d+krqt	j
t ||} |!d,||| f  q|d|	 d|! d-t	j
dt!"|||  S ).NPython r   : 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   in <module>c                 S      dt j|  S N=)pydochtmlreprr'   r   r   r   <lambda>       zhtml.<locals>.<lambda>Zformatvaluec              
      B   d| d < zt  | d W | d  d7  < S | d  d7  < w N   r   	linecachegetlinelnumfileZ	highlightr   r   r#         $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>r@   )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ctimer7   r8   headingr   escapestrr	   inspectgetinnerframesospathabspathgetargvaluesformatargvaluesr-   lenZ	preformatr"   r   r   r9   joindirr   	tracebackformat_exception)"einfocontextetypeevalueetbpyverdateheadindentframesrecordsr   rE   funclinesindexlinkargsvarargsvarkwr   callr#   r$   rowsir+   numdonedumpr   r,   r'   	exceptionr   rF   r   r8   e   s   


$





	r8   c               	      sx  	 | \}}}t |tr|j}dtj d  d tj }tt }dt	|||f d }g }t
||}	|	D ]\}
 }}}} rHtj pId t
|
\}}}}d}|dkrod| }|d	kro|t
j||||d
d d7 }i |gf fdd	}t||
|}d |f g}|d ur|| }|D ]}d| }|||   |d7 }qi g }}|D ]=\}}}||v rqd||< |tur|dkrd| }n|dkr||dd  }|d|tj|f  q||d  q|d| |dd|  q8dt	|t	|f g}t|D ]}tjt||}|dd||f  q|d| d| ddt|||  S )Nr/   r   r0   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.
r1   r   r2   r3   c                 S   r4   r5   )r7   r   r9   r:   r   r   r   r;      r<   ztext.<locals>.<lambda>r=   c              
      r>   r?   rA   rD   rF   r   r   r#      rH   ztext.<locals>.readerz %s %sz%5d r@   r   zglobal r   r   rI   z%s = %sz
 undefinedrJ   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
)rL   r   rM   rN   rO   rP   rQ   rR   rS   rV   rW   rX   rY   rZ   r[   r\   r]   r-   r"   rstripr   r7   r   r9   r_   r`   r   ra   rb   ) rc   rd   re   rf   rg   rh   ri   rj   rl   rm   r   rE   rn   ro   rp   rr   rs   rt   r   ru   r#   r$   rv   rw   r+   rx   ry   rz   r   r,   r'   r{   r   rF   r   r      s^   




r   c                   @   s.   e Zd Z	 		dddZdd Zdd	d
ZdS )Hookr@   Nr.   r8   c                 C   s(   || _ || _|| _|ptj| _|| _d S N)displaylogdirrd   rN   stdoutrG   format)selfr   r   rd   rG   r   r   r   r   __init__  s
   
zHook.__init__c                 C   s   |  |||f d S r~   )handle)r   re   rf   rg   r   r   r   __call__  s   zHook.__call__c           
      C   s  |pt  }| jdkr| jt  | jdkrtpt}d}z||| j}W n   d	t
j| }d}Y | jrS|rJtj|}| jd| d  n| j|d  n| jd | jd urd	d
g| jdk }tj|| jd\}}z!t|d}|| W d    n1 sw   Y  d| }	W n   d| }	Y | jdkr| jd|	  n| j|	d  z| j  W d S    Y d S )Nr8   Fr   Tz<pre>z</pre>
rJ   z*<p>A problem occurred in a Python script.
z.txtz.html)suffixr`   wz*%s contains the description of this error.z*Tried to save traceback to %s, but failed.z
<p>%s</p>
)rN   exc_infor   rG   writer   r8   r   rd   r_   ra   rb   r   r7   rU   r   tempfilemkstemprY   fdopenflush)
r   info	formatterZplaindocr   fdrZ   rG   msgr   r   r   r     s@   



zHook.handle)r@   Nr.   Nr8   r~   )rM   
__module____qualname__r   r   r   r   r   r   r   r}     s    
r}   r@   c                 C   s   	 t | |||dt_d S )Nr   r   rd   r   )r}   rN   
excepthookr   r   r   r   enable:  s   r   )r.   )r@   Nr.   r8   )rW   r    rB   rY   r7   rN   r   rR   r   ra   r   r   r	   r   r   r   r-   r8   r   r}   r   handlerr   r   r   r   r   <module>   s.    


[B7