a
    lc                     @   s   d Z ddlZejd dkZzddlmZmZ W n" eyP   ddlmZmZ Y n0 erdd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 M/var/www/html/django/DPS/env/lib/python3.9/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v r>td|jtj	u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                    sf  t  }z|ji   W S  ty0   Y n0 dd } g }|j D ]\}}|jtjkrt	|dkr|
d n
|| qT|jtjkr|jtjur|v r
| n"t	|dkr|
d n
|| qT|jtjkrg }qT|jtjkr|v r
| n
|| qTi qT|r:t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 | i |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   