
    mi                     Z   d Z ddlZddlmZ g dZg dZeeee	e
eeeeeeeegZej*                  Zej.                  Z G d de      Z edd	i       Z G d
 de      ZeD ]!  Zej=                  dej>                  z  e       # eez   D ]   Z de z  Z!ej=                  e! e"ee!             " eD ]#  Z ej=                  de z   e"ede z        d       % ej=                  ded       ej=                  dejF                         ejH                  e_%         G d de      Z& G d de&      Z'd Z(y)z]
Based on the implementation here by Phillip J. Eby:
https://pypi.python.org/pypi/ProxyTypes
    Nwraps)posnegabsinverteqneltgtlegegetitemsetitemdelitemcontainsiaddisubimul	ifloordivitruedivimodipowilshiftirshiftiandiorixor)addsubmulfloordivtruedivmodpowandorxorlshiftrshiftc                   8     e Zd Z fdZ fdZed        Z xZS )ProxyMetaClassc                 0   t         t        |   | |||      }t        |j	                  dd            |_        |D ]4  }t        |d      s|j
                  j                  |j
                         6 |j                         D ]  \  }}t        |||        |S )N__notproxied__ )
superr,   __new__setpopr.   hasattrupdateitemssetattr)	mcsnamebasesdctnewclsbasekeyval	__class__s	           F/mnt/e/genesis-system/.venv/lib/python3.12/site-packages/proxytypes.pyr1   zProxyMetaClass.__new__M   s    ~s3CucJ #CGG,<b$A B 	BDt-.%%,,T-@-@A	B 		 	&HCFC%	&    c                    | j                   d   j                  dk(  s|dk(  rn)t        |      rPt        |dd      r| j                  j                  |       t        |t        t        f      s| j                  |      }nt        |t              rt        |j                  dd      r| j                  j                  |       |j                  r| j                  |j                        n|j                  }|j                  r| j                  |j                        n|j                  }t        | j                  |j                        ||      }t        t        | C  ||       y )Nr   
_ProxyBaser1   r.   F)	__bases____name__callablegetattrr.   r   
isinstancestaticmethodclassmethod	_no_proxypropertyfgetfsetfdelr0   r,   __setattr__)clsattrvaluerO   rP   r@   s        rA   rQ   zProxyMetaClass.__setattr__X   s    ==$$4	8Ie_u.6""&&t,elK%@Ae,x(uzz#3U;""&&t,05

3==,

D05

3==,

DS]]5::6dCEnc.tU;rB   c                 .     t                fd       }|S )zz
        Returns a wrapped version of `method`, such that proxying is turned off
        during the method call.

        c                     t        | d      }t        | dd       	  | g|i |t        | d|       S # t        | d|       w xY w)Nr.   T)_oga_osa)selfargskwargs
notproxiedmethods       rA   wrapperz)ProxyMetaClass._no_proxy.<locals>.wrappert   sO    d$45J'.9d4T4V4T+Z8T+Z8s	   5 Ar   )r]   r^   s   ` rA   rL   zProxyMetaClass._no_proxyl   s"     
v	9 
	9 rB   )rF   
__module____qualname__r1   rQ   rJ   rL   __classcell__r@   s   @rA   r,   r,   L   s!    	<(  rB   r,   rD   r/   c                   T    e Zd ZdZdZd Zed        Zd Zd Z	d Z
d Zedd	       Zy
)Proxyz
    Proxy for any python object. Base class for other proxies.

    :attr:`__subject__` is the only non-proxied attribute, and contains the
        proxied object

    __subject__c                     || _         y Nre   )rY   subjects     rA   __init__zProxy.__init__   s
    "rB   c                 R    |t        |       j                  v ryt        | d      du ryy)zt
        Determines whether `attr` should be looked up on the proxied object, or
        the proxy itself.

        Fr.   T)typer.   rW   rY   rS   s     rA   _should_proxyzProxy._should_proxy   s/     4:,,,&'4/rB   c                 r    t         j                  | |      rt        | j                  |      S t	        | |      S rh   )rd   rn   rH   rf   rW   rm   s     rA   __getattribute__zProxy.__getattribute__   s2    tT*4++T22D$rB   c                 x    t         j                  | |      rt        | j                  ||       t	        | ||       y rh   )rd   rn   r7   rf   rX   )rY   rS   r?   s      rA   rQ   zProxy.__setattr__   s0    tT*D$$dC0T4rB   c                     t         j                  | |      rt        | j                  |       t        j                  | |       y rh   )rd   rn   delattrrf   object__delattr__rm   s     rA   ru   zProxy.__delattr__   s2    tT*D$$d+4&rB   c                 &     | j                   |i |S rh   re   )rY   rZ   kws      rA   __call__zProxy.__call__   s    t,,,rB   c                 J    t              fd       }t        | ||       y)z
        Add a method `name` to the class, which returns the value of `func`,
        called with the proxied value inserted at `arg_pos`

        c                 f    t        |      }|j                  | j                          |i |}|S rh   )listinsertrf   )rY   rZ   r[   resultarg_posfuncs       rA   proxiedz%Proxy.add_proxy_meth.<locals>.proxied   s4    :DKK!1!124*6*FMrB   N)r   r7   )rR   r9   r   r~   r   s     `` rA   add_proxy_methzProxy.add_proxy_meth   s)     
t	 
	 	T7#rB   N)r   )rF   r_   r`   __doc__r.   rj   rJ   rn   rp   rQ   ru   rx   rK   r   r/   rB   rA   rd   rd      sO     &N# 
 
 

'
- $ $rB   rd   z__%s__z__r%s__   )r~   __rdivmod__	__index__c                   &    e Zd ZdZd Zed        Zy)CallbackProxyzG
    Proxy for a callback result. Callback is called on each use.

    c                     || _         y rh   callback)rY   r   s     rA   rj   zCallbackProxy.__init__   s	     rB   c                 "    | j                         S rh   r   )rY   s    rA   rf   zCallbackProxy.__subject__   s    }}rB   N)rF   r_   r`   r   rj   rM   rf   r/   rB   rA   r   r      s     
!  rB   r   c                   P     e Zd ZdZe fd       Zej                  d        Z xZS )	LazyProxyzD
    Proxy for a callback result, that is cached on first use.

    c                 z    	 | j                   S # t        $ r Y nw xY wt        t        |   | _         | j                   S rh   )cacheAttributeErrorr0   r   rf   )rY   r@   s    rA   rf   zLazyProxy.__subject__   s>    	:: 		 9d7
zzs    	c                     || _         y rh   )r   )rY   rT   s     rA   rf   zLazyProxy.__subject__   s	    
rB   )rF   r_   r`   r   rM   rf   setterra   rb   s   @rA   r   r      s6    
    rB   r   c                     d| _         | S )z>
    Decorator to add methods to the __notproxied__ list

    T)r.   )r   s    rA   r\   r\      s    
 DKrB   ))r   operator	functoolsr   	OPERATORSREFLECTED_OPERATORSdivmodroundreprstrhashlenr   complexboolintfloatiterbytesMAGIC_FUNCSrt   rp   rW   rQ   rX   rl   r,   rD   rd   r   r   rF   op
magic_methrH   index__bool____nonzero__r   r   r\   r/   rB   rA   <module>r      s  
  	@   			  1T 1l L"b1
<$J <$~  9D	DMM1489 )
) DBBJ	WXz%BCD
  VB	R8b=)ISTUV
   ]FA  6   [(.. 1NN E  *rB   