
    VeIi0                         d Z ddlmZ ddlmZ ddlmZ ddlmZ  G d de          Z	d	 Z
d
 Zd Zd Zd Zd Zd Zd Zd Zd Zd Z G d de          Z G d de          ZddddZdS )z0Variants of ObjectProxy for different use cases.    )Callable)
ModuleType   )BaseObjectProxy)synchronizedc                   >     e Zd ZdZed             Z fdZd Z xZS )ObjectProxya  A generic object proxy which forwards special methods as needed.
    For backwards compatibility this class adds support for `__iter__()`. If
    you don't need backward compatibility for `__iter__()` support then it is
    preferable to use `BaseObjectProxy` directly. If you want automatic
    support for special dunder methods for callables, iterators, and async,
    then use `AutoObjectProxy`.c                     t           S N)r	   selfs    R/var/www/html/MCyber-Diagnostic/venv/lib/python3.11/site-packages/wrapt/proxies.py__object_proxy__zObjectProxy.__object_proxy__   s        c                 F    t                                          |           S r   )super__new__)clsargskwargs	__class__s      r   r   zObjectProxy.__new__   s    wws###r   c                 *    t          | j                  S r   iter__wrapped__r   s    r   __iter__zObjectProxy.__iter__   s    D$%%%r   )	__name__
__module____qualname____doc__propertyr   r   r   __classcell__r   s   @r   r	   r	      sl        # #   X$ $ $ $ $& & & & & & &r   r	   c                  2    d } ||  \  }}  |j         | i |S )Nc                 
    | |fS r    )r   r   s     r   _unpack_selfz&__wrapper_call__.<locals>._unpack_self%   s    Tzr   )r   )r   r   r'   r   s       r   __wrapper_call__r(   $   s;       t$JD$4T,V,,,r   c                 *    t          | j                  S r   r   r   s    r   __wrapper_iter__r*   -   s     !!!r   c                 4    | j                                         S r   )r   __next__r   s    r   __wrapper_next__r-   1   s    $$&&&r   c                 4    | j                                         S r   )r   	__aiter__r   s    r   __wrapper_aiter__r0   5   s    %%'''r   c                 D   K   | j                                          d {V S r   )r   	__anext__r   s    r   __wrapper_anext__r3   9   s-      !++---------r   c                 4    | j                                         S r   )r   __length_hint__r   s    r   __wrapper_length_hint__r6   =   s    ++---r   c              #   D   K   | j                                         E d {V S r   )r   	__await__r   s    r   __wrapper_await__r9   A   s-      '11333333334r   c                 8    | j                             ||          S r   )r   __get__)r   instanceowners      r   __wrapper_get__r>   E       ##He444r   c                 8    | j                             ||          S r   )r   __set__)r   r<   values      r   __wrapper_set__rC   I   r?   r   c                 6    | j                             |          S r   )r   
__delete__)r   r<   s     r   __wrapper_delete__rF   M   s    &&x000r   c                 8    | j                             ||          S r   )r   __set_name__)r   r=   names      r   __wrapper_set_name__rJ   Q   s    ((555r   c                   (     e Zd ZdZ fdZd Z xZS )AutoObjectProxya  An object proxy which can automatically adjust to the wrapped object
    and add special dunder methods as needed. Note that this creates a new
    class for each instance, so it has much higher memory overhead than using
    `BaseObjectProxy` directly. If you know what special dunder methods you need
    then it is preferable to use `BaseObjectProxy` directly and add them to a
    subclass as needed. If you only need `__iter__()` support for backwards
    compatibility then use `ObjectProxy` instead.
    c                    i }t          |          }t          t          |                     }t          |          rd|vr
t          |d<   d|v rd|vr
t          |d<   d|v rd|vr
t
          |d<   d|v rd|vr
t          |d<   d|v rd|vr
t          |d<   d|v rd|vr
t          |d<   d|v rd|vr
t          |d<   d|v rd|vr
t          |d<   d	|v rd	|vr
t          |d	<   d
|v rd
|vr
t          |d
<   d|v rd|vr
t          |d<   | j        }| t          u rt           j        }t#          t          |                               t'          || f|                    S )zInjects special dunder methods into a dynamically created subclass
        as needed based on the wrapped object.
        __call__r   r,   r/   r2   r5   r8   r;   rA   rE   rH   )dirsetcallabler(   r*   r-   r0   r3   r6   r9   r>   rC   rF   rJ   r   rL   r   r   r   type)r   wrapped	namespacewrapped_attrsclass_attrsrI   r   s         r   r   zAutoObjectProxy.__new___   s   
 	G#c((mmG 	5;!>!>$4Ij!&&:[+H+H$4Ij!&&:[+H+H$4Ij!-''K{,J,J%6Ik"-''K{,J,J%6Ik"--2C;2V2V+BI'( -''K{,J,J%6Ik"%%);*F*F#2Ii %%);*F*F#2Ii =((\-L-L&8Il#]**~[/P/P(<In%|/!!"+D_c**224sfi3P3PQQQr   c                    t          |           }t          t          |                    }t          | j                  rd|vrt
          |_        n(t          |dd          t
          u rt          |d           t          | j        d          rd|vrt          |_        n(t          |dd          t          u rt          |d           t          | j        d          rd|vrt          |_        n(t          |dd          t          u rt          |d           t          | j        d          rd|vrt          |_        n(t          |dd          t          u rt          |d           t          | j        d          rd|vrt           |_        n(t          |dd          t           u rt          |d           t          | j        d          rd|vrt$          |_        n(t          |dd          t$          u rt          |d           t          | j        d          rd|vrt(          |_        n(t          |dd          t(          u rt          |d           t          | j        d	          rd	|vrt,          |_        n(t          |d	d          t,          u rt          |d	           t          | j        d
          rd
|vrt0          |_        n(t          |d
d          t0          u rt          |d
           t          | j        d          rd|vrt4          |_        n(t          |dd          t4          u rt          |d           t          | j        d          rd|vrt8          |_        dS dS t          |dd          t8          u rt          |d           dS dS )zAdjusts special dunder methods on the class as needed based on the
        wrapped object, when `__wrapped__` is changed.
        rO   Nr   r,   r/   r2   r5   r8   r;   rA   rE   rH   )rS   rQ   rP   rR   r   r(   rO   getattrdelattrhasattrr*   r   r-   r,   r0   r/   r3   r2   r6   r5   r9   r8   r>   r;   rC   rA   rF   rE   rJ   rH   )r   r   rW   s      r   __wrapped_setattr_fixups__z*AutoObjectProxy.__wrapped_setattr_fixups__   s   
 4jj#c((mmD$%% 	%,,/S*d++/???C$$$4#Z00 	%,,/S*d++/???C$$$4#Z00 	%,,/S*d++/???C$$$4#[11 	&+-- 1S+t,,0AAAC%%%4#[11 	&+-- 1S+t,,0AAAC%%%4#%677 	, 33&=#S+T226MMMC*+++4#[11 	&+-- 1S+t,,0AAAC%%%4#Y// 	$++-S)T**o==C###4#Y// 	$++-S)T**o==C###4#\22 	';..!3S,--1CCCC&&&4#^44 	)[00#7    10S.$//3GGGC((((( HGr   )r   r   r   r    r   r\   r"   r#   s   @r   rL   rL   U   s^         4R 4R 4R 4R 4RlH) H) H) H) H) H) H)r   rL   c                   L     e Zd ZdZd
dd fdZd
dd fdZdZd Zd	 Z xZ	S )LazyObjectProxyzhAn object proxy which can generate/create the wrapped object on demand
    when it is first needed.
    N.	interfacec                   |du rt          d          }i }t          |          }t          t          |                     }d|v rd|vr
t          |d<   d|v rd|vr
t          |d<   d|v rd|vr
t
          |d<   d|v rd|vr
t          |d<   d|v rd|vr
t          |d<   d|v rd|vr
t          |d<   d	|v rd	|vr
t          |d	<   d
|v rd
|vr
t          |d
<   d|v rd|vr
t          |d<   d|v rd|vr
t          |d<   d|v rd|vr
t          |d<   | j        }t          t           |                               t          || f|                    S )rN   .NrO   r   r,   r/   r2   r5   r8   r;   rA   rE   rH   )rS   rP   rQ   r(   r*   r-   r0   r3   r6   r9   r>   rC   rF   rJ   r   r   rL   r   )r   callbackr`   rU   interface_attrsrW   rI   r   s          r   r   zLazyObjectProxy.__new__   s   
 T

I	i..#c((mm((Z{-J-J$4Ij!((Z{-J-J$4Ij!((Z{-J-J$4Ij!/))k.L.L%6Ik"/))k.L.L%6Ik" 00!44+BI'( /))k.L.L%6Ik"''I[,H,H#2Ii ''I[,H,H#2Ii ?**|;/N/N&8Il#_,,{1R1R(<In%|_c**224sfi3P3PQQQr   c                \    ||| _         t                                          d           dS )a  Initialize the object proxy with wrapped object as `None` but due
        to presence of special `__wrapped_factory__` attribute addded first,
        this will actually trigger the deferred creation of the wrapped object
        when first needed.
        N)__wrapped_factory__r   __init__)r   rb   r`   r   s      r   rf   zLazyObjectProxy.__init__  s1     '/D$r   Fc                     d S r   r&   r   s    r   re   z#LazyObjectProxy.__wrapped_factory__,  s    tr   c                     t          t          |                     5  | j        r| j        cddd           S |                                 | _        d| _        | j        cddd           S # 1 swxY w Y   dS )z2Gets the wrapped object, creating it if necessary.NT)r   rS   __wrapped_initialized__r   re   r   s    r   __wrapped_get__zLazyObjectProxy.__wrapped_get__/  s     $t**%% 	$ 	$ + ('	$ 	$ 	$ 	$ 	$ 	$ 	$ 	$  $7799D+/D(#	$ 	$ 	$ 	$ 	$ 	$ 	$ 	$ 	$ 	$ 	$ 	$ 	$ 	$ 	$ 	$ 	$ 	$s   A+&A++A/2A/r   )
r   r   r   r    r   rf   ri   re   rj   r"   r#   s   @r   r^   r^      s         7R 7R 7R 7R 7R 7R 7R 7Rr
3 
 
 
 
 
 
 
 $  $ $ $ $ $ $ $r   r^   N.r_   c                f     |du rt           }n|du rt          } fd}t          ||          S )aN  Lazily imports the module `name`, returning a `LazyObjectProxy` which
    will import the module when it is first needed. When `name is a dotted name,
    then the full dotted name is imported and the last module is taken as the
    target. If `attribute` is provided then it is used to retrieve an attribute
    from the module.
    N.c                  P    t          dg          } t          |           S | S )N )fromlist)
__import__rY   )module	attributerI   s    r   _importzlazy_import.<locals>._importW  s2    DB4000 69---r   r_   )r   r   r^   )rI   rq   r`   rr   s   ``  r   lazy_importrs   H  s`      I"I      7i8888r   r   )r    collections.abcr   typesr   	__wrapt__r   
decoratorsr   r	   r(   r*   r-   r0   r3   r6   r9   r>   rC   rF   rJ   rL   r^   rs   r&   r   r   <module>rx      s   6 6 $ $ $ $ $ $       & & & & & & $ $ $ $ $ $& & & & &/ & & &.- - -" " "' ' '( ( (. . .. . .5 5 55 5 55 5 51 1 16 6 6H) H) H) H) H)o H) H) H)Ve$ e$ e$ e$ e$o e$ e$ e$P93 9 9 9 9 9 9 9r   