
    4Ysh
                     \    d Z ddgZ G d de      Z G d de      Zd Zedk(  r e        yy)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:

  >>> 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:

  >>> 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:

  >>> d.dispatch(Event(foo='bar', data='yours', used_by='the event handlers'))
  <rdflib.events.Event ['data', 'foo', 'used_by']>
Event
Dispatcherc                       e Zd ZdZd Zd Zy)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                   j                  |       y N)__dict__update)selfkws     m/var/www/sten-cake5-migrate2.hellocrow.space/lexinfo-master/env/lib/python3.12/site-packages/rdflib/events.py__init__zEvent.__init__*   s    R     c                 z    t        | j                  j                               }d|D cg c]  }| c}dS c c}w )Nz<rdflib.events.Event >)sortedr   keys)r	   attrsas      r   __repr__zEvent.__repr__-   s0    t}}))+,9>-?Aa-?AA-?s   	8N)__name__
__module____qualname____doc__r   r    r   r   r   r      s    
!Br   c                   ,    e Zd ZdZdZd Zd Zd Zd Zy)r   z]
    An object that can dispatch events to a privately managed group of
    subscribers.
    Nc                     || _         | S r   _dispatch_map)r	   amaps     r   set_mapzDispatcher.set_map:   s    !r   c                     | j                   S r   r   )r	   s    r   get_mapzDispatcher.get_map>   s    !!!r   c                     | j                   | j                  i        | j                   j                  |d      }||g}n|j                  |       || 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.subscribeA   sa     %LL  $$Z6;)CJJw),:&r   c                     | j                   N| j                   j                  t        |      d      }|t        dt        |      z        |D ]
  } ||        yy)zPDispatch the given event to the subscribed handlers for
        the event's typeNzunknown event type: %s)r   r#   type
ValueError)r	   eventr'   l_s       r   dispatchzDispatcher.dispatchO   sa     )$$((ed;C{ !9DK!GHH 5		 *r   )	r   r   r   r   r   r   r!   r(   r.   r   r   r   r   r   2   s"    
 M"r   c                  ,    dd l } | j                          y )N    )doctesttestmod)r1   s    r   testr3   Z   s    OOr   __main__N)r   __all__objectr   r   r3   r   r   r   r   <module>r7      sL   2 L
!BF B*% %P zF r   