
    01i                    X    S r SSKJr  SSKJrJrJr  SS/r " S S5      r " S S5      r	g)	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                  $    \ rS rSrSrS rS rSrg)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                :    U R                   R                  U5        g N)__dict__update)selfkws     G/home/james-whalen/.local/lib/python3.13/site-packages/rdflib/events.py__init__Event.__init__7   s    R     c                    [        U R                  R                  5       5      nSU Vs/ s H  o"PM     sn< S3$ s  snf )Nz<rdflib.events.Event >)sortedr   keys)r   attrsas      r   __repr__Event.__repr__:   s4    t}}))+,9>-?Aa-?AA-?s   ; N)__name__
__module____qualname____firstlineno____doc__r   r   __static_attributes__r   r   r   r   r   *   s    
!Br   c                  D    \ rS rSr% SrSrS\S'   SS jrS rS r	S	 r
S
rg)r   ?   zQ
An object that can dispatch events to a privately managed group of
subscribers.
NzOptional[Dict[Any, Any]]_dispatch_mapc                    Xl         U $ r   r&   )r   amaps     r   set_mapDispatcher.set_mapG   s    !r   c                    U R                   $ r   r(   )r   s    r   get_mapDispatcher.get_mapK   s    !!!r   c                    U R                   c  U R                  0 5        U R                   R                  US5      nUc  U/nOUR                  U5        X0R                   U'   U $ )zeSubscribe 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   	subscribeDispatcher.subscribeN   s_     %LL  $$Z6;)CJJw),:&r   c                    U R                   bQ  U R                   R                  [        U5      S5      nUc  [        S[        U5      -  5      eU H  nU" U5        M     gg)zHDispatch the given event to the subscribed handlers for
the event's typeNzunknown event type: %s)r&   r0   type
ValueError)r   eventr4   l_s       r   dispatchDispatcher.dispatch^   s\     )$$((ed;C{ !9DK!GHH5	 	 *r   r(   )r)   zDict[Any, Any])r   r   r    r!   r"   r&   __annotations__r*   r-   r5   r<   r#   r   r   r   r   r   ?   s(    
 /3M+2" r   N)
r"   
__future__r   typingr   r   r   __all__r   r   r   r   r   <module>rB      s6    D # & &L
!B B*' 'r   