Your IP : 216.73.216.213


Current Path : /opt/alt/python37/lib64/python3.7/site-packages/twisted/python/__pycache__/
Upload File :
Current File : //opt/alt/python37/lib64/python3.7/site-packages/twisted/python/__pycache__/monkey.cpython-37.pyc

B

:��]��@s$ddlmZmZGdd�de�ZdS)�)�division�absolute_importc@s@eZdZdZdd�Zdd�Zdd�Zdd	�Zd
d�Zdd
�Z	dS)�
MonkeyPatcherzn
    Cover up attributes with new objects. Neat for monkey-patching things for
    unit-testing purposes.
    cGs(g|_g|_x|D]}|j|�qWdS)N)�_patchesToApply�
_originals�addPatch)�selfZpatches�patch�r
�H/opt/alt/python37/lib64/python3.7/site-packages/twisted/python/monkey.py�__init__s
zMonkeyPatcher.__init__cCs|j�|||f�dS)z�
        Add a patch so that the attribute C{name} on C{obj} will be assigned to
        C{value} when C{patch} is called or during C{runWithPatches}.

        You can restore the original values with a call to restore().
        N)r�append)r�obj�name�valuer
r
rrszMonkeyPatcher.addPatchcCs.x(|jD]\}}}||f||fkrdSqWdS)zc
        Has the C{name} attribute of C{obj} already been patched by this
        patcher?
        TF)r)rrr�o�n�vr
r
r�_alreadyPatched#szMonkeyPatcher._alreadyPatchedcCsJxD|jD]:\}}}|�||�s6|j�||t||�f�t|||�qWdS)z�
        Apply all of the patches that have been specified with L{addPatch}.
        Reverse this operation using L{restore}.
        N)rrrr
�getattr�setattr)rrrrr
r
rr	.szMonkeyPatcher.patchcCs,x&|jr&|j��\}}}t|||�qWdS)zE
        Restore all original values to any patched objects.
        N)r�popr)rrrrr
r
r�restore9szMonkeyPatcher.restorecOs"|��z
|||�S|��XdS)z�
        Apply each patch already specified. Then run the function f with the
        given args and kwargs. Restore everything when done.
        N)r	r)r�f�args�kwr
r
r�runWithPatchesBs
zMonkeyPatcher.runWithPatchesN)
�__name__�
__module__�__qualname__�__doc__rrrr	rrr
r
r
rr	s

	rN)�
__future__rr�objectrr
r
r
r�<module>s