a
    Rh@/                     @   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   -/opt/python-3.9.24/usr/lib/python3.9/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   | |v rd||  fS | |j v r,d|j |  fS d|j v r~|j d }t|ti u rf| |v 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\}}}}}t| D ]\}}	}
}}|tjkr> q|tjkr|	tjvr|dkr|t urt||	t }|||	 ||f qt	|	||\}}||	||f n"|	dkr||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 ]F\} }}}} rtj  d t	j
 f }nd  }t|\}}}}d}|dkr8dtt	j
| }|dkr8|tj||||dd d7 }i |gf fdd	}t|||}dd||f g}|d ur
|| }|D ]}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 ]\}}} ||v r0qd||< | tur|d v r^d!| t| }n*|d"krrt|}n|t|d#d$  }|d%|t	j
| f  n||d&  q|dttd'|  |	d(d)|  qd*tt	j
t|t	j
t|f g}!t|D ]B}|d d d+kr4qt	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   s   dt j|  S N=)pydochtmlreprr%   r   r   r   <lambda>       zhtml.<locals>.<lambda>Zformatvaluec              
      sF   d| d < z"t  | d W | d  d7  < S | d  d7  < 0 d S N   r   	linecachegetlinelnumfileZ	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>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ctimer4   r5   headingr	   escapestrr   inspectgetinnerframesospathabspathgetargvaluesformatargvaluesr+   lenZ	preformatr    r
   r   r6   joindirr   	tracebackformat_exception)"einfocontextetypeevalueetbpyverdateheadindentframesrecordsr   rA   funclinesindexlinkargsvarargsvarkwr   callr!   r"   rowsir)   numdonedumpr   r*   r%   	exceptionr   rB   r   r5   e   s    




$





	r5   c               	      s  | \}}}t |tr|j}dtj d  d tj }tt }dt	|||f d }g }t
||}	|	D ]\}
 }}}} rtj pd t
|
\}}}}d}|dkrd| }|d	kr|t
j||||d
d d7 }i |gf fdd	}t||
|}d |f g}|d urP|| }|D ](}d| }|||   |d7 }q&i g  }}|D ]\}}}||v rvq^d||< |tur|dkrd| }n|dkr||dd  }|d|tj|f  n||d  q^|d| |dd|  qndt	|t	|f g}t|D ],}tjt||}|dd||f  q*|d| d| ddt|||  S )Nr-   r   r.   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   r0   r1   c                 S   s   dt j|  S r2   )r4   r   r6   r7   r   r   r   r8      r9   ztext.<locals>.<lambda>r:   c              
      sF   d| d < z"t  | d W | d  d7  < S | d  d7  < 0 d S r;   r=   r@   rB   r   r   r!      s
    ztext.<locals>.readerz %s %sz%5d r<   r   zglobal r   r   rD   z%s = %sz
 undefinedrE   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
)rG   r   rH   rI   rJ   rK   rL   rM   rN   rQ   rR   rS   rT   rU   rV   rW   rX   r+   r    rstripr   r4   r   r6   rZ   r[   r   r\   r]   ) r^   r_   r`   ra   rb   rc   rd   re   rg   rh   r   rA   ri   rj   rk   rm   rn   ro   r   rp   r!   r"   rq   rr   r)   rs   rt   ru   r   r*   r%   rv   r   rB   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,   r5   c                 C   s(   || _ || _|| _|ptj| _|| _d S N)displaylogdirr_   rI   stdoutrC   format)selfrz   r{   r_   rC   r}   r   r   r   __init__  s
    zHook.__init__c                 C   s   |  |||f d S ry   )handle)r~   r`   ra   rb   r   r   r   __call__  s    zHook.__call__c           
      C   s  |p
t  }| jdkr$| jt  | jdkr2tp4t}d}z||| j}W n    d	t
j| }d}Y n0 | jr|rtj|}| jd| d  q| j|d  n| jd | jd urpd	d
g| jdk }tj|| jd\}}zDt|d}|| W d    n1 s0    Y  d| }	W n   d| }	Y n0 | jdkr`| jd|	  n| j|	d  z| j  W n   Y n0 d S )Nr5   Fr   Tz<pre>z</pre>
rE   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>
)rI   exc_infor}   rC   writer   r5   r   r_   rZ   r\   r]   rz   r4   rP   r{   tempfilemkstemprT   fdopenflush)
r~   info	formatterZplaindocr   fdrU   rC   msgr   r   r   r     s>    

*zHook.handle)r<   Nr,   Nr5   )N)rH   
__module____qualname__r   r   r   r   r   r   r   rx     s
     
rx   r<   c                 C   s   t | |||dt_d S )Nrz   r{   r_   r}   )rx   rI   
excepthookr   r   r   r   enable:  s    r   )r,   )r,   )r<   Nr,   r5   )rR   r   r>   rT   r4   rI   r   rM   r   r\   r   r   r   r	   r
   r   r+   r5   r   rx   r   handlerr   r   r   r   r   <module>   s*   

[
B7