
    `                         d Z ddlZej        d         dk    Z	 ddlmZmZ n# e$ r ddlmZmZ Y nw xY werddl	m
Z
 n	ddl	m
Z d Z
d ZdS )	z9
Created on Mon Jan 13 18:17:15 2014

@author: takluyver
    N   )	signature	Parameter   )wrapsc                       fd}|S )Nc                 F     t                    |            | _        | S )N)_wraps__wrapped__)funcfs    1lib/python3.11/site-packages/backcall/backcall.pydeczwraps.<locals>.dec   s#    F1IIdOOO DK     )r   r   s   ` r   r   r      s#    	 	 	 	 	
 
r   c                    t          |           }g g c}|j                                        D ]\  }}|j        t          j        t          j        fv rt          d          |j        t          j	        us|j        t          j
        k    r|                    |           q                    |           t                              |          fd}|| _        | S )aJ  Decorator to process a callback prototype.
    
    A callback prototype is a function whose signature includes all the values
    that will be passed by the callback API in question.
    
    The original function will be returned, with a ``prototype.adapt`` attribute
    which can be used to prepare third party callbacks.
    z**args/**kwargs not supported in prototypesc                     t                     }	  |j        
i 	  S # t          $ r Y nw xY w
dd         }	                                g }|j                                        D ]<\  }}|j        t          j        k    r?t          |          dk    r|
                    d           D|                    |           Z|j        t          j        k    rl|j        t          j        ur|v r
                    |           t          |          dk    r|
                    d           |                    |           |j        t          j        k    rg }|j        t          j        k    r2|v r
                    |           #|                    |           :i >|r#t          d                     |                    t          
          t          |          z
  t%                      fd            }|S )z.Introspect and prepare a third party callback.Nr   z)Function {!r} had unmatched arguments: {}c                  \    | d         } D ]}|                     |            | i |S )z@Wrapper for third party callbacks that discards excess argumentsN)pop)argskwargsnamecallbackn_positionalunmatched_kws      r   adaptedz2callback_prototype.<locals>.adapt.<locals>.adapted_   sL     &D$ ! !

4    8T,V,,,r   )r   bind	TypeErrorcopy
parametersitemskindr   POSITIONAL_ONLYlenr   appendPOSITIONAL_OR_KEYWORDdefaultemptyVAR_POSITIONALKEYWORD_ONLYformatr   )r   sigunmatched_posunrecognisedr   paramr   r   r   r   
positionals   `      @@r   adaptz!callback_prototype.<locals>.adapt1   sL   !!	CHj+F+++O 	 	 	D	 #111{{}}>//11 	" 	"KD%zY666}%%))!%%a(((( ''----y>>>M88t|?S?S $$T****''!++!%%a(((( ''----y777 "y555<'' $$T**** ''----!  	hGNNxYeffggg:]););;	x	- 	- 	- 	- 	- 	- 
	- s   $ 
11)r   r    r!   r"   r   r)   VAR_KEYWORDr   r'   r(   r*   r%   dictfromkeysr1   )	prototypeprotosigkeywordr   r/   r1   r   r0   s         @@r   callback_prototyper8      s     ##HbJ*0022 $ $e:)2I4IJJJHIIIM00
i444NN4    d####]]7##F9 9 9 9 9 9v IOr   )__doc__sysversion_infoPY3inspectr   r   ImportError_signatures	functoolsr   r
   r8   r   r   r   <module>rA      s    
 



a2,,,,,,,,, 2 2 211111111112  
))))))  R R R R Rs   " 22