
    gi                     p   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                    dej        z  e           !eez   D ]'Z de z  Z!e                    e! e"ee!                     (eD ]*Z e                    de z   e"ede z            d           +e                    ded           e                    dej#                   ej$        e_%         G d de          Z& G d de&          Z'd Z(dS )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                   >     e Zd Z fdZ fdZed             Z xZS )ProxyMetaClassc                 l   t          t          |                               | |||          }t          |                    dd                    |_        |D ]1}t          |d          r|j                            |j                   2|                                D ]\  }}t          |||           |S )N__notproxied__ )
superr,   __new__setpopr.   hasattrupdateitemssetattr)	mcsnamebasesdctnewclsbasekeyval	__class__s	           b/var/www/development/aibuddy-work/election-extract/venv/lib/python3.11/site-packages/proxytypes.pyr1   zProxyMetaClass.__new__M   s    ~s++33CucJJ #CGG,<b$A$A B B 	B 	BDt-.. B%,,T-@AAA		 	& 	&HCFC%%%%    c                    | j         d         j        dk    s|dk    rn*t          |          r]t          |dd          r| j                            |           t          |t          t          f          s| 	                    |          }nt          |t                    rt          |j        dd          r| j                            |           |j        r| 	                    |j                  n|j        }|j        r| 	                    |j                  n|j        }t          | 	                    |j                  ||          }t          t          |                               ||           d S )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   sS    =$44	8I8Ie__ 	Du.66 -"&&t,,,elK%@AA -e,,x(( 	Duz#3U;; -"&&t,,,05
J3==,,,
D05
J3==,,,
DS]]5:66dC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|R 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   sw    d$455J'...9vd4T444V44T+Z8888T+Z8888s   A Ar   )r]   r^   s   ` rA   rL   zProxyMetaClass._no_proxyl   s5     
v	9 	9 	9 	9 
	9 rB   )rF   
__module____qualname__r1   rQ   rJ   rL   __classcell__r@   s   @rA   r,   r,   L   sl        	 	 	 	 	< < < < <(   \    rB   r,   rD   r/   c                   b    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dS )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                     || _         d S Nre   )rY   subjects     rA   __init__zProxy.__init__   s    "rB   c                 ^    |t          |           j        v rdS t          | d          du rdS dS )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::,,,5&''4//5trB   c                     t                               | |          rt          | j        |          S t	          | |          S rh   )rd   rn   rH   rf   rW   rm   s     rA   __getattribute__zProxy.__getattribute__   s=    tT** 	34+T222D$rB   c                     t                               | |          rt          | j        ||           t	          | ||           d S rh   )rd   rn   r7   rf   rX   )rY   rS   r?   s      rA   rQ   zProxy.__setattr__   sG    tT** 	1D$dC000T4rB   c                     t                               | |          rt          | j        |           t                              | |           d S rh   )rd   rn   delattrrf   object__delattr__rm   s     rA   ru   zProxy.__delattr__   sI    tT** 	,D$d+++4&&&&&rB   c                      | j         |i |S rh   re   )rY   rZ   kws      rA   __call__zProxy.__call__   s    t,,,,rB   r   c                 b    t                    fd            }t          | ||           dS )z
        Add a method `name` to the class, which returns the value of `func`,
        called with the proxied value inserted at `arg_pos`

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

    c                     || _         d S rh   callback)rY   r   s     rA   rj   zCallbackProxy.__init__   s     rB   c                 *    |                                  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      sH         
! ! !   X  rB   r   c                   R     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                     	 | j         S # t          $ r Y nw xY wt          t          |           j        | _         | j         S rh   )cacheAttributeErrorr0   r   rf   )rY   r@   s    rA   rf   zLazyProxy.__subject__   sN    	: 	 	 	D	 9d++7
zs   
 
c                     || _         d S rh   )r   )rY   rT   s     rA   rf   zLazyProxy.__subject__   s    


rB   )rF   r_   r`   r   rM   rf   setterra   rb   s   @rA   r   r      sm         
     X       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      se   
         	@     			  1 1 1 1 1T 1 1 1l ^L"b11
<$ <$ <$ <$ <$J <$ <$ <$~  9 9D	DM148888
)
) D DBBJ	WWXz%B%BCCCC  V VB	R8b=)I)ISTUUUU   ]FA  6 6 6   [(. 1 1 1N     E          *    rB   