o
     e                     @   s0   G d d de ZG dd dZG dd dZdS )c                   @   s   e Zd ZdS )EventsExceptionN)__name__
__module____qualname__ r   r   H/var/www/html/venv/lib/python3.10/site-packages/drf_api_logger/events.pyr      s    r   c                   @   s>   e Zd ZdZdddZdd Zdd ZeZd	d
 Zdd Z	dS )Eventsa{  
    Encapsulates the core to event subscription and event firing, and feels
    like a "natural" part of the language.
    The class Events is there mainly for 3 reasons:
        - Events (Slots) are added automatically, so there is no need to
        declare/create them separately. This is great for prototyping. (Note
        that `__events__` is optional and should primarily help detect
        misspelled event names.)
        - To provide (and encapsulate) some level of introspection.
        - To "steel the name" and hereby remove unneeded redundancy in a call
        like:
            xxx.OnChange = event('OnChange')
    Nc                 C   s:   |d urzt | W n   tdt| || _d S d S )Nztype object %s is not iterable)iterAttributeErrortype
__events__)selfeventsr   r   r   __init__   s   
zEvents.__init__c                 C   sz   | drtd| jj|f t| dr || jvrtd| nt| jdr2|| jjvr2td| t| | j|< }|S )N__z&type object '%s' has no attribute '%s'r   zEvent '%s' is not declared)	
startswithr	   	__class__r   hasattrr   r   
_EventSlot__dict__)r   nameevr   r   r   __getattr__    s   



zEvents.__getattr__c                 C   s   d| j j| j jtt| f S )Nz<%s.%s object at %s>)r   r   r   hexidr   r   r   r   __repr__0   s   
zEvents.__repr__c                 C   s   t | j S N)lenr   itemsr   r   r   r   __len__7   s   zEvents.__len__c                 C   s   | j  fdd}| S )Nc                 s   s$    | D ]\}}t |tr|V  qd S r   )
isinstancer   )	dictitemsattrvalr   r   r   gen;   s   
zEvents.__iter__.<locals>.gen)r   r   r   r$   r   r   r   __iter__:   s   zEvents.__iter__r   )
r   r   r   __doc__r   r   r   __str__r   r&   r   r   r   r   r      s    
r   c                   @   sL   e Zd Zdd Zdd Zdd Zdd Zd	d
 Zdd Zdd Z	dd Z
dS )r   c                 C   s   g | _ || _d S r   )targetsr   )r   r   r   r   r   r   D   s   
z_EventSlot.__init__c                 C   s
   d| j  S )Nz
event '%s')r   r   r   r   r   r   H      
z_EventSlot.__repr__c                 O   s"   t | jD ]	}||i | qd S r   )tupler)   )r   akwfr   r   r   __call__K   s   z_EventSlot.__call__c                 C   s   | j | | S r   )r)   appendr   r.   r   r   r   __iadd__O   s   z_EventSlot.__iadd__c                 C   s$   || j v r| j | || j v s| S r   )r)   remover1   r   r   r   __isub__S   s   

z_EventSlot.__isub__c                 C   s
   t | jS r   )r   r)   r   r   r   r   r   X   r*   z_EventSlot.__len__c                    s    fdd}| S )Nc                  3   s     j D ]} | V  qd S r   r)   )targetr   r   r   r$   \   s   
z _EventSlot.__iter__.<locals>.genr   r%   r   r   r   r&   [   s   z_EventSlot.__iter__c                 C   s
   | j | S r   r5   )r   keyr   r   r   __getitem__b   r*   z_EventSlot.__getitem__N)r   r   r   r   r   r/   r2   r4   r   r&   r8   r   r   r   r   r   C   s    r   N)	Exceptionr   r   r   r   r   r   r   <module>   s    >