U
    -e                     @   s   d Z ddlZejd dkZzddlmZmZ W n$ ek
rR   ddlmZmZ Y nX erfddl	m
Z
 nddl	m
Z dd Z
d	d
 ZdS )z9
Created on Mon Jan 13 18:17:15 2014

@author: takluyver
    N   )	signature	Parameter   )wrapsc                    s    fdd}|S )Nc                    s   t  |   | _| S )N)_wraps__wrapped__)funcf R/var/www/html/Darija-Ai-Train/env/lib/python3.8/site-packages/backcall/backcall.pydec   s    zwraps.<locals>.decr   )r   r   r   r
   r   r      s    r   c                    s   t | }g g  }|j D ]P\}}|jtjtjfkr>td|jtj	k	sV|jtj
krb|| q| qt|  fd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                    sd  t  }z|j  W S  tk
r.   Y nX dd } g }|j D ]\}}|jtjkrt	|dkr~|
d n
|| qR|jtjkr|jtjk	r|kr
| n"t	|dkr|
d n
|| qR|jtjkrg }qR|jtjkr|kr
| n
|| qRi qR|r8td |t	t	| t  fdd}|S )z.Introspect and prepare a third party callback.Nr   z)Function {!r} had unmatched arguments: {}c                     s*   | d } D ]}| | q | |S )z@Wrapper for third party callbacks that discards excess argumentsN)pop)argskwargsnamecallbackZn_positionalZunmatched_kwr   r   adapted_   s    z2callback_prototype.<locals>.adapt.<locals>.adapted)r   bind	TypeErrorcopy
parametersitemskindr   POSITIONAL_ONLYlenr   appendPOSITIONAL_OR_KEYWORDdefaultemptyVAR_POSITIONALKEYWORD_ONLYformatr   )r   sigZunmatched_posZunrecognisedr   paramr   r   
positionalr   r   adapt1   sB    

z!callback_prototype.<locals>.adapt)r   r   r   r   r   r"   VAR_KEYWORDr   r    r!   r#   r   dictfromkeysr)   )Z	prototypeZprotosigkeywordr   r&   r)   r   r'   r   callback_prototype   s    	


;r.   )__doc__sysversion_infoPY3inspectr   r   ImportErrorZ_signatures	functoolsr   r   r.   r   r   r   r   <module>   s   