
    Be%                     \    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y)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                 v   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.12/site-packages/pydispatch/robustapply.pyfunctionr      s     x$H%%w/7H<M<Mw3W((H'#7!;YGJJh	*$x.QRRWXi0!33    c                 t   t        |       \  } }}|j                  |t        |      z   |j                   }|j                  ||t        |      z    D ]  }||v st	        d|d|        |j
                  dz  s3t        |j                         D cg c]  \  }}||v s||f c}}      } | |i |S c c}}w )zDCall receiver with arguments and an appropriate subset of named
    z	Argument z: specified both positionally and as a keyword for calling    )r   co_varnameslenco_argcount	TypeErrorco_flagsdictitems)	r   	argumentsnamed
codeObject
startIndex
acceptablenamekvs	            r   robustApplyr'   '   s     (0';$Hj*''
3y>(A*BXBXYJ&&z*S^2KL 5=(  !# u{{}H!ZqeHIY(%(( Is   B4
B4
)	__doc__sys
hexversionr   r   r   r	   r   r'    r   r   <module>r,      sM    >>YGGGIGGGI4&)r   