Your IP : 216.73.216.85


Current Path : /opt/alt/python37/lib/python3.7/site-packages/funcsigs/__pycache__/
Upload File :
Current File : //opt/alt/python37/lib/python3.7/site-packages/funcsigs/__pycache__/__init__.cpython-37.pyc

B

�.W�v�@s\dZddlmZmZmZddlZddlZddlZddlZyddl	m
Z
Wn ek
rhddlm
Z
YnXddl
mZdddd	gZeej�Zeej�ZeeejfZd"d
d�Zdd
�Zdd	�ZGdd�de�ZGdd�de�ZGdd�de�Zeddd�Zeddd�Z eddd�Z!eddd�Z"eddd�Z#Gdd�de�Z$Gd d�de�Z%Gd!d�de�Z&dS)#z�Function signature objects for callables

Back port of Python 3.3's function signature tools from the inspect module,
modified to be compatible with Python 2.6, 2.7 and 3.3+.
�)�absolute_import�division�print_functionN)�OrderedDict)�__version__�BoundArguments�	Parameter�	Signature�	signaturecCs8t|t�r0|jdd|fkr |jS|jd|jSt|�S)N�builtinsZ__builtin__�.)�
isinstance�type�
__module__�__name__�repr)�
annotation�base_module�r�B/opt/alt/python37/lib/python3.7/site-packages/funcsigs/__init__.py�formatannotations

rcGs\y4|tkrdSt||�}x|D]}t|||�}qWWntk
rHdSXt|t�sX|SdS)N)r�getattr�AttributeErrorr
�_NonUserDefinedCallables)�cls�method_name�nested�meth�namerrr�_get_user_defined_method's


rc
Cst|�std�|���t|tj�r�t|j�}|jdkr:|St	|j
���}|r^|djt
tfkrftd��|dj}|ttfkr�|dd�}n|tk	r�td��|j|d�Sy
|j}Wntk
r�YnX|dk	r�|Sy
|j}Wntk
r�Yn
Xt|�St|tj��rt�|�St|tj��r
t|j�}t|j
���}|j�pBd}|j �pNi}y|j!||�}Wn6tk
�r�}	zd	�|�}
t|
��Wdd}	~	XYnXx`|j"��D]R\}}||}
||k�r�|
j|d
d�||<n"|
jt
tfk�r�|
j#�s�|�$|��q�W|j|��d�Sd}t|t%��rxt&t%|�d�}|dk	�r<t|�}n:t&|d
�}|dk	�rZt|�}nt&|d�}|dk	�r�t|�}n.t|t'��s�t&t%|�dd�}|dk	�r�t|�}|dk	�r�|jt	|j
���dd�d�St|tj(��r�d�|�}
t|
��td�|���dS)z/Get a signature object for the passed callable.z{0!r} is not a callable objectNrzinvalid method signature�zinvalid argument type)�
parametersrz,partial object {0!r} has incorrect argumentsT)�default�_partial_kwarg�__call__�__new__�__init__Zim_funcz-no signature found for builtin function {0!r}z,callable {0!r} is not supported by signature))�callable�	TypeError�formatr
�types�
MethodTyper
�__func__�__self__�tupler!�values�kind�_VAR_KEYWORD�
_KEYWORD_ONLY�
ValueError�_POSITIONAL_OR_KEYWORD�_POSITIONAL_ONLY�_VAR_POSITIONAL�replace�
__signature__r�__wrapped__�FunctionTyper	�
from_function�	functools�partial�funcr�items�args�keywords�bind_partial�	argumentsr#�poprrr�BuiltinFunctionType)�obj�sig�paramsr0�wrapped�
new_params�partial_args�partial_keywords�ba�ex�msgZarg_name�	arg_value�param�call�new�initrrrr
7s�



















c@seZdZdZdS)�_voidz0A private marker - used in Parameter & SignatureN)rr�__qualname__�__doc__rrrrrU�srUc@seZdZdS)�_emptyN)rrrVrrrrrX�srXc@s$eZdZdd�Zdd�Zdd�ZdS)�_ParameterKindcOstj|f|��}|d|_|S)Nr)�intr%�_name)�selfr@�kwargsrFrrrr%�s
z_ParameterKind.__new__cCs|jS)N)r[)r\rrr�__str__�sz_ParameterKind.__str__cCsd�|j�S)Nz<_ParameterKind: {0!r}>)r)r[)r\rrr�__repr__�sz_ParameterKind.__repr__N)rrrVr%r^r_rrrrrY�srY�POSITIONAL_ONLY)rr �POSITIONAL_OR_KEYWORD��VAR_POSITIONAL��KEYWORD_ONLY��VAR_KEYWORDc@s�eZdZdZdZeZeZe	Z
eZe
ZeZeedfdd�Zedd��Zedd	��Zed
d��Zedd
��Zeeeeefdd�Zdd�Zdd�Zdd�Zdd�Zdd�ZdS)ra�Represents a parameter in a function signature.

    Has the following public attributes:

    * name : str
        The name of the parameter as a string.
    * default : object
        The default value for the parameter if specified.  If the
        parameter has no default value, this attribute is not set.
    * annotation
        The annotation for the parameter if specified.  If the
        parameter has no annotation, this attribute is not set.
    * kind : str
        Describes how argument values are bound to the parameter.
        Possible values: `Parameter.POSITIONAL_ONLY`,
        `Parameter.POSITIONAL_OR_KEYWORD`, `Parameter.VAR_POSITIONAL`,
        `Parameter.KEYWORD_ONLY`, `Parameter.VAR_KEYWORD`.
    )r[�_kind�_default�_annotationr#FcCs�|tttttfkrtd��||_|tk	rF|ttfkrFd�|�}t|��||_	||_
|dkrr|tkrjtd��||_n8t|�}|tkr�t
�d|t
j�s�d�|�}t|��||_||_dS)Nz,invalid value for 'Parameter.kind' attributez){0} parameters cannot have default valuesz<None is not a valid name for a non-positional-only parameterz
[a-z_]\w*$z#{0!r} is not a valid parameter name)r5r4r6r2r1r3rhrXr)rirjr[�str�re�match�Ir#)r\rr0r"rr#rOrrrr&�s(

zParameter.__init__cCs|jS)N)r[)r\rrrrszParameter.namecCs|jS)N)ri)r\rrrr"szParameter.defaultcCs|jS)N)rj)r\rrrrszParameter.annotationcCs|jS)N)rh)r\rrrr0!szParameter.kindcCs\|tkr|j}|tkr|j}|tkr*|j}|tkr8|j}|tkrF|j}t|�|||||d�S)z+Creates a customized copy of the Parameter.)r"rr#)rUr[rhrjrir#r)r\rr0rr"r#rrrr7%szParameter.replacecCs�|j}|j}|tkr*|dkr d}d�|�}|jtk	rFd�|t|j��}|jtk	rbd�|t|j��}|t	krtd|}n|t
kr�d|}|S)N�z<{0}>z{0}:{1}z{0}={1}�*z**)r0r[r5r)rjrXrrirr6r1)r\r0�	formattedrrrr^;s 



zParameter.__str__cCsd�|jjt|�|j�S)Nz<{0} at {1:#x} {2!r}>)r)�	__class__r�idr)r\rrrr_Ss
zParameter.__repr__cCsd�|jj�}t|��dS)Nzunhashable type: '{0}')r)rrrr()r\rOrrr�__hash__WszParameter.__hash__cCs<t|jt�o:|j|jko:|j|jko:|j|jko:|j|jkS)N)�
issubclassrrrr[rhrirj)r\�otherrrr�__eq__[s
zParameter.__eq__cCs|�|�S)N)rw)r\rvrrr�__ne__bszParameter.__ne__N)rrrVrW�	__slots__r5r`r4rar6rcr2rer1rgrX�emptyr&�propertyrr"rr0rUr7r^r_rtrwrxrrrrr�s*c@sTeZdZdZdd�Zedd��Zedd��Zedd	��Zd
d�Z	dd
�Z
dd�ZdS)raResult of `Signature.bind` call.  Holds the mapping of arguments
    to the function's parameters.

    Has the following public attributes:

    * arguments : OrderedDict
        An ordered mutable mapping of parameters' names to arguments' values.
        Does not contain arguments' default values.
    * signature : Signature
        The Signature object that created this instance.
    * args : tuple
        Tuple of positional arguments values.
    * kwargs : dict
        Dict of keyword arguments values.
    cCs||_||_dS)N)rC�
_signature)r\r
rCrrrr&wszBoundArguments.__init__cCs|jS)N)r|)r\rrrr
{szBoundArguments.signaturec	Cs�g}xt|jj��D]d\}}|jttfks.|jr0Py|j|}Wntk
rTPYqX|jt	krl|�
|�q|�|�qWt|�S)N)
r|r!r?r0r1r2r#rC�KeyErrorr6�extend�appendr.)r\r@�
param_namerQ�argrrrr@s
zBoundArguments.argsc	Cs�i}d}x�|jj��D]~\}}|sL|jttfks6|jr<d}n||jkrLd}q|sRqy|j|}Wntk
rtYqX|jtkr�|�	|�q|||<qW|S)NFT)
r|r!r?r0r1r2r#rCr}�update)r\r]�kwargs_startedr�rQr�rrrr]�s(

zBoundArguments.kwargscCsd�|jj�}t|��dS)Nzunhashable type: '{0}')r)rrrr()r\rOrrrrt�szBoundArguments.__hash__cCs$t|jt�o"|j|jko"|j|jkS)N)rurrrr
rC)r\rvrrrrw�szBoundArguments.__eq__cCs|�|�S)N)rw)r\rvrrrrx�szBoundArguments.__ne__N)rrrVrWr&r{r
r@r]rtrwrxrrrrrfsc@s�eZdZdZdZeZeZe	Z
de	dfdd�Zedd��Z
ed	d
��Zedd��Zeefd
d�Zdd�Zdd�Zdd�Zddd�Zdd�Zdd�Zdd�ZdS)r	aA Signature object represents the overall signature of a function.
    It stores a Parameter object for each parameter accepted by the
    function, as well as information specific to the function itself.

    A Signature object has the following public attributes and methods:

    * parameters : OrderedDict
        An ordered mapping of parameters' names to the corresponding
        Parameter objects (keyword-only arguments are in the same order
        as listed in `code.co_varnames`).
    * return_annotation : object
        The annotation for the return type of the function if specified.
        If the function has no annotation for its return type, this
        attribute is not set.
    * bind(*args, **kwargs) -> BoundArguments
        Creates a mapping from positional and keyword arguments to
        parameters.
    * bind_partial(*args, **kwargs) -> BoundArguments
        Creates a partial mapping from positional and keyword arguments
        to parameters (simulating 'functools.partial' behavior.)
    )�_return_annotation�_parametersNTcCs�|dkrt�}n�|r�t�}t}x�t|�D]z\}}|j}||krZd}	|	�||j�}	t|	��n|}|j}
|
dkr�t|�}
|j|
d�}|
|kr�d�|
�}	t|	��|||
<q(Wntdd�|D��}||_	||_
dS)z�Constructs Signature from the given list of Parameter
        objects and 'return_annotation'.  All arguments are optional.
        Nz%wrong parameter order: {0} before {1})rzduplicate parameter name: {0!r}css|]}|j|fVqdS)N)r)�.0rQrrr�	<genexpr>sz%Signature.__init__.<locals>.<genexpr>)rr5�	enumerater0r)r3rrkr7r�r�)r\r!�return_annotation�__validate_parameters__rH�top_kind�idxrQr0rOrrrrr&�s0


zSignature.__init__c	Cs�t|tj�std�|���|j}|j}|j}|j}t	|d|��}t
|dd�}||||�}t
|di�}	|j}
t
|dd�}|
r�t|
�}nd}g}
||}x4|d|�D]$}|	�
|t�}|
�|||td��q�WxBt||d��D].\}}|	�
|t�}|
�|||t|
|d��q�W|jd	@�rL|||}|	�
|t�}|
�|||td��xJ|D]B}t}|dk	�rp|�
|t�}|	�
|t�}|
�|||t|d���qRW|jd
@�r�||}|jd	@�r�|d7}||}|	�
|t�}|
�|||td��||
|	�
dt�d
d�S)z2Constructs Signature for the given python functionz{0!r} is not a Python functionN�co_kwonlyargcountr�__annotations__�__kwdefaults__)rr0)rr0r"rf�r �returnF)r�r�)r
r*r:r(r)�_parameter_cls�__code__�co_argcount�co_varnamesr.r�__defaults__�len�getrXrr4r��co_flagsr6r2r1)rr>r�	func_code�	pos_count�	arg_names�
positional�keyword_only_count�keyword_only�annotations�defaults�
kwdefaults�pos_default_countr!�non_default_countrr�offsetr"�indexrrrr;sd










zSignature.from_functioncCs0yt�|j�Stk
r*t|j���SXdS)N)r*�MappingProxyTyper�rrr?)r\rrrr!TszSignature.parameterscCs|jS)N)r�)r\rrrr�[szSignature.return_annotationcCs0|tkr|j��}|tkr |j}t|�||d�S)z�Creates a customized copy of the Signature.
        Pass 'parameters' and/or 'return_annotation' arguments
        to override them in the new copy.
        )r�)rUr!r/r�r)r\r!r�rrrr7_s
zSignature.replacecCsd�|jj�}t|��dS)Nzunhashable type: '{0}')r)rrrr()r\rOrrrrtnszSignature.__hash__c	Cs�tt|�t�r.|j|jks.t|j�t|j�kr2dStdd�t|j���D��}x�t|j�	��D]�\}\}}|j
tkr�y|j|}Wntk
r�dSX||kr�dSq^y||}Wntk
r�dSX||ks�||j|kr^dSq^WdS)NFcss|]\}}||fVqdS)Nr)r�r�rQrrrr�xsz#Signature.__eq__.<locals>.<genexpr>T)
rurr	r�r�r!�dictr��keysr?r0r2r})r\rvZother_positionsr�r�rQZother_paramZ	other_idxrrrrwrs,
zSignature.__eq__cCs|�|�S)N)rw)r\rvrrrrx�szSignature.__ne__FcCs�t�}t|j���}d}t|�}|rTx.|j��D] \}}	|	jr0||kr0|	j||<q0W�xryt|�}
Wn�tk
�r,yt|�}	Wntk
r�PYn�X|	j	t
kr�Pn�|	j|kr�|	j	tkr�d}|j
|	jd�}t|��|	f}PnH|	j	tks�|	jtk	r�|	f}Pn*|�r|	f}Pnd}|j
|	jd�}t|��YqXXyt|�}	Wntk
�rXtd��YqXX|	j	ttfk�rrtd��|	j	t
k�r�|
g}|�|�t|�||	j<P|	j|k�r�tdj
|	jd���|
||	j<qXWd}
x�t�||�D]�}	|	j	tk�r�tdj
|	jd���|	j	tk�r|	}
�q�|	j}y|�|�}
WnDtk
�rj|�sf|	j	t
k�rf|	jtk�rftdj
|d���Yn
X|
||<�q�W|�r�|
dk	�r�|||
j<ntd|��|�||�S)	z$Private method.  Don't use directly.rzA{arg!r} parameter is positional only, but was passed as a keyword)r�z'{arg!r} parameter lacking default valueztoo many positional argumentsz$multiple values for argument {arg!r}Nztoo many keyword arguments %r)r�iterr!r/r?r#r"�next�
StopIterationr0r6rr5r)r(r1rXr2r~r.�	itertools�chainrDr}�_bound_arguments_cls)r\r@r]r=rCr!�
parameters_ex�arg_valsr�rQ�arg_valrOr/�kwargs_paramrrr�_bind�s�






zSignature._bindcOs|d�|dd�|�S)z�Get a BoundArguments object, that maps the passed `args`
        and `kwargs` to the function's signature.  Raises `TypeError`
        if the passed arguments can not be bound.
        rr N)r�)r@r]rrr�bindszSignature.bindcOs|j||dd�S)z�Get a BoundArguments object, that partially maps the
        passed `args` and `kwargs` to the function's signature.
        Raises `TypeError` if the passed arguments can not be bound.
        T)r=)r�)r\r@r]rrrrBszSignature.bind_partialc	Cs�g}d}xZt|j���D]H\}}t|�}|j}|tkr<d}n|tkrV|rV|�d�d}|�|�qWd�d�	|��}|j
tk	r�t|j
�}|d�|�7}|S)NTFrpz({0})z, z -> {0})
r�r!r/rkr0r6r2rr)�joinr�rXr)	r\�result�render_kw_only_separatorr�rQrqr0�rendered�annorrrr^!s 


zSignature.__str__)F)rrrVrWryrr�rr�rXrzr&�classmethodr;r{r!r�rUr7rtrwrxr�r�rBr^rrrrr	�s&%I
)N)'rW�
__future__rrrr�r<rlr*�collectionsr�ImportErrorZordereddictZfuncsigs.versionr�__all__rr$�_WrapperDescriptor�all�_MethodWrapperrErrrr
�objectrUrXrZrYr5r4r6r2r1rrr	rrrr�<module>s@




a