
    ztf                        d Z ddlmZ ddlmZmZ ddlmZ ddlm	Z	 ddl
mZmZmZmZ ddlmZ dd	lmZmZ dd
lmZ ddgZddZededf	 	 	 	 	 	 	 dd       Z	 d	 	 	 	 	 ddZdZdZddZddZy)z@These utilities may help when using signals and evented objects.    )annotations)contextmanagersuppress)partial)Path)AnyCallable	GeneratorIterator)warn   )EmissionInfoSignalGroup)SignalInstancemonitor_eventsiter_signal_instancesc                `    t        | j                  j                   d| j                         y )Nz.emit)printsignalnameargs)infos    W/var/www/html/software/conda/envs/higlass/lib/python3.12/site-packages/psygnal/utils.py_default_event_monitorr      s$    	T[[eDII=
12    NFc           	   #  "  K   t        dd      }t        |xr |j                  dkD        }| *|rt        d      t        j
                  c}t        _        ns|rt        dd       t               }t        | |      D ]K  }|r
|ddfd	}n	|ddfd
}|j                  t        |j                  |j                  |                   M 	 d | t        _        yD ]	  }	 |	         y# | t        _        w D ]	  }	 |	         w xY ww)a  Context manager to print or collect events emitted by SignalInstances on `obj`.

    Parameters
    ----------
    obj : object, optional
        Any object that has an attribute that has a SignalInstance (or SignalGroup).
        If None, all SignalInstances will be monitored.
    logger : Callable[[EmissionInfo], None], optional
        A optional function to handle the logging of the event emission.  This function
        must take two positional args: a signal name string, and a tuple that contains
        the emitted arguments. The default logger simply prints the signal name and
        emitted args.
    include_private_attrs : bool
        Whether private signals (starting with an underscore) should also be logged,
        by default False
    __code__Nr   zFlogger function must take a single argument (an EmissionInfo instance)z{logger functions must now take a single argument (an instance of psygnal.EmissionInfo). Please update your logger function.   )
stacklevel)r   c                ,     | j                   |       y N)r   r   r   loggers     r   _reportzmonitor_events.<locals>._report@   s    6;;-r   c                *     t        | |             y r!   )r   r"   s     r   r$   zmonitor_events.<locals>._reportE   s    <56r   )r   r   r   r   returnNone)getattrboolco_argcount
ValueErrorr   _debug_hookr   setr   addr   
disconnectconnect)
objr#   include_private_attrscode_old_apibeforedisconnectorssiginstr$   disconnectors
    `        r   r   r      s%    , 6:t,DD1T--12H
{X  .<-G-G**M
 ,S2GH 	UGAH . .
 BI 7 gg&8&8'//':RST	U;)/N& -  ;)/N& - s   C	DC. D.DDc              #  `  K   t        | t              r| D ]	  }| |     yt        |       D ]q  }|s|j                  d      rt	        t
        t              5  t        | |      }t        |t              r| t        |t              r|j                   ddd       s y# 1 sw Y   ~xY ww)a  Yield all `SignalInstance` attributes found on `obj`.

    Parameters
    ----------
    obj : object
        Any object that has an attribute that has a SignalInstance (or SignalGroup).
    include_private_attrs : bool
        Whether private signals (starting with an underscore) should also be logged,
        by default False

    Yields
    ------
    SignalInstance
        SignalInstances (and SignalGroups) found as attributes on `obj`.
    N_)

isinstancer   dir
startswithr   AttributeErrorFutureWarningr(   r   _psygnal_relay)r1   r2   signattrs        r   r   r   T   s     & #{# 	Cc(N	 X *$c):nm4 	*3?D$/
$,)))	* 	**	* 	*s   AB.?B"B."B+	'B.)z.soz.pyd_BAKc                     t         D ]Z  } t        t              j                  j	                  d|        D ]*  }|j                  |j                  |  t                      , \ y)zMangle names of mypyc-compiled files so that they aren't used.

    This function requires write permissions to the psygnal source directory.
    **/*N)_COMPILED_EXTSr   __file__parentrglobrenamewith_suffixrD   suffixpaths     r   	decompilerP   |   s]    
 ! =N))//$vh@ 	=DKK((F8D6):;<	==r   c                     t         D ]X  } t        t              j                  j	                  d|  t
               D ]"  }|j                  |j                  |              $ Z y)zFix all name-mangled mypyc-compiled files so that they ARE used.

    This function requires write permissions to the psygnal source directory.
    rF   N)rG   r   rH   rI   rJ   rD   rK   rL   rM   s     r   	recompilerR      sY    
 ! 2N))//$vhtf0EF 	2DKK((01	22r   )r   r   r&   r'   )r1   z
Any | Noner#   zCallable[[EmissionInfo], Any]r2   r)   r&   zIterator[None])F)r1   r   r2   r)   r&   z%Generator[SignalInstance, None, None])r&   r'   )__doc__
__future__r   
contextlibr   r   	functoolsr   pathlibr   typingr   r	   r
   r   warningsr   _groupr   r   _signalr   __all__r   r   r   rG   rD   rP   rR    r   r   <module>r^      s    F " /   5 5  - #4
53 ,B"';	;);  ; 	; ;~ -2!*	!*%)!**!*H !=2r   