
    T%                     V    d Z ddlZej        dk    r	dZdZdZdZndZdZd	Zd
Zd Zd ZdS )zRobust apply mechanism

Provides a function "call", which can sort out
what arguments a given callable object can take,
and subset the given arguments to match only
those which are acceptable.
    Ni   __func____self____code__im_funcim_selfim_code	func_codec                    t          | d          r;t          | j        t                    st          | j        t                    r| j        } t          | t                    r+| t	          t	          | t                    t
                    dfS t          | t
                    s"t          d| dt          |                     | t	          | t
                    dfS )zGet function-like callable object for given receiver

    returns (function_or_method, codeObject, fromMethod)

    If fromMethod is true, then the callable already
    has its first argument bound
    __call__   zunknown reciever type  r   )hasattrr   r   r   getattrr	   
ValueErrortype)receivers    6lib/python3.11/site-packages/pydispatch/robustapply.pyfunctionr      s     x$$ )H%w// 	)7H<Mw3W3W 	)(H'## S7!;!;YGGJJh	** Sj$x...QRRRWXi00!33    c                 f   t          |           \  } }}|j        |t          |          z   |j                 |j        ||t          |          z            D ]}||v rt	          d|d|           |j        dz  s-t          fd|                                D                       } | |i |S )zDCall receiver with arguments and an appropriate subset of named
    z	Argument z: specified both positionally and as a keyword for calling    c                 &    g | ]\  }}|v 	||fS  r   ).0kv
acceptables      r   
<listcomp>zrobustApply.<locals>.<listcomp>6   s*    HHH!ZHqeHHHr   )r   co_varnameslenco_argcount	TypeErrorco_flagsdictitems)r   	argumentsnamed
codeObject
startIndexnamer   s         @r   robustApplyr+   '   s     (0';';$Hj*'
3y>>(A*BX(XYJ&z*S^^2K'KL  5= 	)DD((  	 !# J HHHHu{{}}HHHII8Y(%(((r   )	__doc__sys
hexversionr   r   r   r	   r   r+   r   r   r   <module>r/      s{     


>Y 	GGGIIGGGI4 4 4&) ) ) ) )r   