
    Pi                    f    d Z ddlmZ ddlmZmZmZ ddgZ G d d          Z G d d          Z	dS )	a  
Dirt Simple Events

A Dispatcher (or a subclass of Dispatcher) stores event handlers that
are 'fired' simple event objects when interesting things happen.

Create a dispatcher:

```python
>>> d = Dispatcher()

```

Now create a handler for the event and subscribe it to the dispatcher
to handle Event events.  A handler is a simple function or method that
accepts the event as an argument:

```python
>>> def handler1(event): print(repr(event))
>>> d.subscribe(Event, handler1) # doctest: +ELLIPSIS
<rdflib.events.Dispatcher object at ...>

```

Now dispatch a new event into the dispatcher, and see handler1 get
fired:

```python
>>> d.dispatch(Event(foo='bar', data='yours', used_by='the event handlers'))
<rdflib.events.Event ['data', 'foo', 'used_by']>

```
    )annotations)AnyDictOptionalEvent
Dispatcherc                      e Zd ZdZd Zd ZdS )r   a  
    An event is a container for attributes.  The source of an event
    creates this object, or a subclass, gives it any kind of data that
    the events handlers need to handle the event, and then calls
    notify(event).

    The target of an event registers a function to handle the event it
    is interested with subscribe().  When a sources calls
    notify(event), each subscriber to that event will be called in no
    particular order.
    c                :    | j                             |           d S N)__dict__update)selfkws     a/home/jaya/work/projects/VOICE-AGENT/VIET/agent-env/lib/python3.11/site-packages/rdflib/events.py__init__zEvent.__init__7   s    R         c                n    t          | j                                                  }dd |D             dS )Nz<rdflib.events.Event c                    g | ]}|S  r   ).0as     r   
<listcomp>z"Event.__repr__.<locals>.<listcomp><   s    -?-?-?Aa-?-?-?r   >)sortedr   keys)r   attrss     r   __repr__zEvent.__repr__:   s<    t}))++,,-?-?-?-?-?-?-?AAr   N)__name__
__module____qualname____doc__r   r   r   r   r   r   r   *   sA        
 
! ! !B B B B Br   c                  <    e Zd ZU dZdZded<   ddZd Zd	 Zd
 Z	dS )r   z]
    An object that can dispatch events to a privately managed group of
    subscribers.
    NzOptional[Dict[Any, Any]]_dispatch_mapamapDict[Any, Any]c                    || _         | S r   r#   )r   r$   s     r   set_mapzDispatcher.set_mapG   s    !r   c                    | j         S r   r'   )r   s    r   get_mapzDispatcher.get_mapK   s    !!r   c                    | j         |                     i            | j                             |d          }||g}n|                    |           || j         |<   | S )zuSubscribe the given handler to an event_type.  Handlers
        are called in the order they are subscribed.
        N)r#   r(   getappend)r   
event_typehandlerlsts       r   	subscribezDispatcher.subscribeN   si     %LL $$Z66;)CCJJw),:&r   c                    | j         Y| j                             t          |          d          }|t          dt          |          z            |D ]} ||           dS dS )zPDispatch the given event to the subscribed handlers for
        the event's typeNzunknown event type: %s)r#   r,   type
ValueError)r   eventr0   l_s       r   dispatchzDispatcher.dispatch^   sz     )$((ed;;C{ !9DKK!GHHH  5				 *) r   )r$   r%   )
r   r   r    r!   r#   __annotations__r(   r*   r1   r7   r   r   r   r   r   ?   st          
 /3M2222   " " "       r   N)
r!   
__future__r   typingr   r   r   __all__r   r   r   r   r   <module>r<      s      D # " " " " " & & & & & & & & & &L
!B B B B B B B B*' ' ' ' ' ' ' ' ' 'r   