HEX
Server: Apache
System: Linux scp1.abinfocom.com 5.4.0-216-generic #236-Ubuntu SMP Fri Apr 11 19:53:21 UTC 2025 x86_64
User: confeduphaar (1010)
PHP: 8.1.33
Disabled: exec,passthru,shell_exec,system
Upload Files
File: //usr/lib/python3/dist-packages/twisted/python/__pycache__/rebuild.cpython-38.pyc
U


W[4$�@s�dZddlZddlZddlZddlZddlmZzddlmZWnek
rTYnXddl	m
Z
mZddlm
Z
e��add�ZGd	d
�d
e�ZiZdd�Zd
d�ZGdd�de�Zdd�Zdd�Zddd�ZdS)z&
*Real* reloading support for Python.
�N)�reload)�InstanceType)�log�reflect)�_PY3cCs ttdd�}|dkrdS||kS)a�
    Compare to types.ClassType in a py2/3-compatible way

    Python 2 used comparison to types.ClassType to check for old-style
    classes Python 3 has no concept of old-style classes, so if
    ClassType doesn't exist, it can't be an old-style class - return
    False in that case.

    Note that the type() of new-style classes is NOT ClassType, and
    so this should return False for new-style classes in python 2
    as well.
    Z	ClassTypeNF)�getattr�types)�tZ
_ClassType�r
�8/usr/lib/python3/dist-packages/twisted/python/rebuild.py�_isClassTypes
rc@s,eZdZdZeZdd�Zdd�Zdd�ZdS)	�	Sensitivez�
    A utility mixin that's sensitive to rebuilds.

    This is a mixin for classes (usually those which represent collections of
    callbacks) to make sure that their code is up-to-date before running.
    cCs|jtk}|S�N)�lastRebuild)�selfZynr
r
r�needRebuildUpdate=s
zSensitive.needRebuildUpdatecCst��|_dSr)�timer�rr
r
r�rebuildUpToDateBszSensitive.rebuildUpToDatecCs�t|�}|tjkrt|�S|tjkrL|jdkr<t|j|j�St|j|j�Sn:t	sh|t
krht|dd�|St|�rxt|�St
�d�|SdS)z�
        Get the latest version of an object.

        This can handle just about anything callable; instances, functions,
        methods, and classes.
        NZnothingzwarning returning anObject!)�typer�FunctionType�latestFunction�
MethodType�__self__rZim_class�__name__rrr�latestClassr�msg)rZanObjectr	r
r
r�latestVersionOfFs



zSensitive.latestVersionOfN)r�
__module__�__qualname__�__doc__rrrrr
r
r
rr
3s
r
cCs,t|j�}t�|�}|dkr |St||j�S)z/
    Get the latest version of a function.
    N)�id�__globals__�
_modDictIDMap�getrr)ZoldFuncZdictID�moduler
r
rras


rcCs�t�|j�}t||j�}dd�|jD�}zt|�|_|WStk
r�|jdkrZ|YSt|�}t	|�rvt|dt�}||jt|�t
|j��YSXdS)z,
    Get the latest version of a class.
    cSsg|]}t|��qSr
)r)�.0�baser
r
r�
<listcomp>uszlatestClass.<locals>.<listcomp>)Z__builtin__�builtinsZ
__metaclass__N)rZnamedModulerrr�	__bases__�tuple�	TypeErrorrr�dict�__dict__)ZoldClassr%ZnewClassZnewBasesZctorr
r
rros

�rc@seZdZdZdS)�RebuildErrorzT
    Exception raised when trying to rebuild a class whereas it's not possible.
    N)rrrr r
r
r
rr/�sr/cCst|j�|_dS)z,
    Updates an instance to be current.
    N)r�	__class__rr
r
r�updateInstance�sr1cCs@|dkrtd��t|�t�d�t�|j�|��t||�}|S)z<
    A getattr method to cause a class to be refreshed.
    �__del__zWithout this, Python segfaults.z#(rebuilding stale {} instance ({})))	�AttributeErrorr1rr�formatr�qualr0r)r�name�resultr
r
r�__injectedgetattr__�s
�
r8�c
Cs�t��at|d�r |js td��|r:t�d�t|j	���ddl
m}d|_|j
}|tt|�<i}i}i}i}|r�t�d�t|j	���|��D]�\}}	tt|	��r�|	j|j	kr�d||	<|r�tj�d	�tj��q�t|	�tjk�r|	j|j
k�rPd||	<|�rPtj�d
�tj��q�t|	t�r�|	j|j	kr�d||	<|r�tj�d�tj��q�|�|�|�|�|j}
|��}|��}|��}|�r�t�d�t�d
�t|j	���t|�t� �|�r�t�d�t|j	���|D]j}t!||j	�|k�rt�d�t"�#|���n:|�r$tj�d�tj��d|_$|j
�%�t&|_'|j	|_�q�|�rTddl(}|D]^}
t!||
j	�}||
k�r�t�d�t"�#|
���n*|�)|
�D]}t!|dd�|
k�r�||_*�q��qX|�r�t�d�t�d�t|j	���d}t+j,��D�]`\}}|d}||k�s�|dk�r�q�t|d��s&�q�t|d��r6�q�d}|j
��D]�\}}	zt-|	�Wnt.k
�rtY�qDYnX|
|	��r�tt|	���r�|�r�tj�d	�tj��t/|	�}n$|�r�tj�d
�tj��t0|	�}d}t1|||�n.tt|	���rD|	j$D]}|
|��r�t/|	��q��qD|�r�|�s�|ddk�r�tj�d�tj���q�d|_|�r|t�d�t�d�t|j	���|S)zO
    Reload a module and do as much as possible to replace its references.
    �ALLOW_TWISTED_REBUILDzI am not allowed to be rebuilt.zRebuilding {}...r)�
componentsTz  (scanning {}): r9�c�f�o�z  (reload   {})z  (cleaning {}): z)WARNING: class {} not replaced by reload!�xr
Nz-WARNING: new-class {} not replaced by reload!r0z  (fixing   {}): �__file__Z
__bundle__�
�.Fz   Rebuilt {}.)2rr�hasattrr:�RuntimeErrorrrr4�strr�twisted.pythonr;ZALLOW_DUPLICATESr.r#r!�itemsrrrZlogfile�write�flushrrr"�
isinstance�update�__contains__�keysr�	linecache�
clearcacherrr5r*�clearr8�__getattr__�gcZ
get_referrersr0�sys�modules�hash�	Exceptionrr�setattr)r%ZdoLogr;�dZ
newclasses�classesZ	functions�values�k�vZ
fromOldModuleZclazzrSZnclassZga�rZmodcountZmk�modZchangedZnvr'r
r
r�rebuild�s�




�


�







r`)r9)r rTrrrO�imprr�ImportErrorrGrrZtwisted.python.compatrrr�objectr
r#rrrWr/r1r8r`r
r
r
r�<module>s*,