
    5j%                         S SK Jr  S SKJr  S SKJrJrJrJr  S SK	J
r
  \ " S S5      5       r " S S5      r\" 5       rS	\S
\\/\4   4S jrS r\" S\S9rS\S
\4S jrg)    )	dataclasswraps)CallableListTypeTypeVar)EventEmitterc                   *    \ rS rSr% \\S'   \\S'   Srg)Handler   eventmethod N)__name__
__module____qualname____firstlineno__str__annotations__r   __static_attributes__r       G/root/lseg-credit/backend/venv/lib/python3.13/site-packages/pyee/cls.pyr   r      s    Jr   r   c                   ,    \ rS rSrS rS rS rS rSrg)Handlers   c                     / U l         g N	_handlersselfs    r   __init__Handlers.__init__   s	    (*r   c                 :    U R                   R                  U5        g r   )r    append)r"   handlers     r   r&   Handlers.append   s    g&r   c                 ,    [        U R                  5      $ r   )iterr    r!   s    r   __iter__Handlers.__iter__   s    DNN##r   c                     / U l         g r   r   r!   s    r   resetHandlers.reset   s	    r   r   N)	r   r   r   r   r#   r&   r+   r.   r   r   r   r   r   r      s    +'$r   r   r   returnc                 0   ^  S[         S[         4U 4S jjnU$ )zf
Register an event handler on an evented class. See the `evented` class
decorator for a full example.
r   r0   c                 B   > [         R                  [        TU S95        U $ )N)r   r   )r    r&   r   )r   r   s    r   	decoratoron.<locals>.decorator%   s    uV<=r   )r   )r   r3   s   ` r   onr5      s    ( x  r   c                 4   ^ ^ [        T5      UU 4S j5       nU$ )Nc                     > T" T/U Q70 UD6$ r   r   )argskwargsr   r"   s     r   bound_bind.<locals>.bound-   s    d,T,V,,r   r   )r"   r   r:   s   `` r   _bindr<   ,   s     
6]- - Lr   Cls)r:   clsc                    ^^ [        [        5      m[        R                  5         U R                  m[	        U R                  5      UU4S j5       nXl        U $ )a  
Configure an evented class.

Evented classes are classes which use an EventEmitter to call instance
methods during runtime. To achieve this without this helper, you would
instantiate an `EventEmitter` in the `__init__` method and then call
`event_emitter.on` for every method on `self`.

This decorator and the `on` function help make things look a little nicer
by defining the event handler on the method in the class and then adding
the `__init__` hook in a wrapper:

```py
from pyee.cls import evented, on

@evented
class Evented:
    @on("event")
    def event_handler(self, *args, **kwargs):
        print(self, args, kwargs)

evented_obj = Evented()

evented_obj.event_emitter.emit(
    "event", "hello world", numbers=[1, 2, 3]
)
```

The `__init__` wrapper will create a `self.event_emitter: EventEmitter`
automatically but you can also define your own event_emitter inside your
class's unwrapped `__init__` method. For example, to use this
decorator with a `TwistedEventEmitter`::

```py
@evented
class Evented:
    def __init__(self):
        self.event_emitter = TwistedEventEmitter()

    @on("event")
    async def event_handler(self, *args, **kwargs):
        await self.some_async_action(*args, **kwargs)
```
c                    > T" U /UQ70 UD6  [        U S5      (       d  [        5       U l        T H<  nU R                  R                  UR                  [        XR                  5      5        M>     g )Nevent_emitter)hasattrr
   rA   r5   r   r<   r   )r"   r8   r9   hhandlersog_inits       r   initevented.<locals>.initi   sY    &t&v&t_--!-DA!!!''5xx+@A r   )listr    r.   r#   r   )r>   rF   rD   rE   s     @@r   eventedrI   7   sK    Z #9oHOOG
3<<B B LJr   N)dataclassesr   	functoolsr   typingr   r   r   r	   pyeer
   r   r   r    r   r5   r<   r=   rI   r   r   r   <module>rN      s    !  0 0    
  J	
c 
hz834 
 e4 = = =r   