ok

Mini Shell

Direktori : /lib64/python3.6/site-packages/zope/interface/__pycache__/
Upload File :
Current File : //lib64/python3.6/site-packages/zope/interface/__pycache__/interface.cpython-36.pyc

3

��[P�@s�dZddlmZddlZddlmZddlmZddlZddlZddl	m
Z
ddlmZdZ
d	Zd
Ze�Zdd�Zd
d�ZGdd�de�ZGdd�de�ZeZyddlmZWnek
r�YnXe�ZGdd�de�ZeZyddlmZWnek
�rYnXgZyddlmZWnek
�r0YnXGdd�de�ZGdd�deee�Zeddd�ZGdd �d e�Z Gd!d"�d"e �Z!d-d#d$�Z"d.d%d&�Z#d'd(�Z$dd)l%m&Z&dd*l%m'Z'dd+l	m(Z(dd,l	m)Z)dS)/z Interface object implementation
�)�
generatorsN)�
MethodType)�FunctionType)�Invalid)�ro��Z__interface_tagged_values__cCs2tjd�j}|jti�}|jdg�}|j|�tS)N��
invariants)�sys�	_getframe�f_locals�
setdefault�TAGGED_DATA�append�_decorator_non_return)�callr
Ztagsr
�r�!/usr/lib64/python3.6/interface.py�	invariant"s

rcCs$tjd�j}|jti�}|||<tS)z;Attaches a tagged value to an interface at definition time.r	)rrr
rrr)�key�valuer
Z
tagged_valuesrrr�taggedValue*src@sLeZdZdZddd�Zdd�Zdd�Zd	d
�Zddd
�Zdd�Z	dd�Z
dS)�ElementzI
    Default implementation of `zope.interface.interfaces.IElement`.
    �cCs2|r|jd�dkr|}d}||_||_i|_dS)N� r)�find�__name__�__doc__�_Element__tagged_values)�selfrrrrr�__init__<szElement.__init__cCs|jS)z! Returns the name of the object. )r)r rrr�getNameEszElement.getNamecCs|jS)z+ Returns the documentation for the object. )r)r rrr�getDocIszElement.getDoccCs
|j|S)z* Returns the value associated with 'tag'. )r)r �tagrrr�getTaggedValueMszElement.getTaggedValueNcCs|jj||�S)z* Returns the value associated with 'tag'. )r�get)r r$�defaultrrr�queryTaggedValueQszElement.queryTaggedValuecCs
|jj�S)z Returns a list of all tags. )r�keys)r rrr�getTaggedValueTagsUszElement.getTaggedValueTagscCs||j|<dS)z  Associates 'value' with 'key'. N)r)r r$rrrr�setTaggedValueYszElement.setTaggedValue)r)N)r�
__module__�__qualname__rr!r"r#r%r(r*r+rrrrr2s
	
rc@s(eZdZdd�Zdd�Zdd�ZeZdS)�SpecificationBasePycCst|�}||jkS)z2Is the interface implemented by an object
        )�
providedBy�_implied)r �ob�specrrrr/_szSpecificationBasePy.providedBycCst|�}||jkS)z�Test whether the specification is implemented by a class or factory.

        Raise TypeError if argument is neither a class nor a callable.
        )�
implementedByr0)r �clsr2rrrr3esz!SpecificationBasePy.implementedBycCs
||jkS)zCIs the interface the same as or extend the given interface
        )r0)r �	interfacerrr�isOrExtendsmszSpecificationBasePy.isOrExtendsN)rr,r-r/r3r6�__call__rrrrr.]sr.)�SpecificationBasec@s$eZdZdZefdd�Zdd�ZdS)�InterfaceBasePyz:Base class that wants to be replaced with a C base :)
    cCs\t|dd�}|dk	r*|j|�}|dk	r*|S|j|�}|dk	r@|S|tk	rL|Std||��dS)z)Adapt an object to the interface
        Z__conform__NzCould not adapt)�getattr�
_call_conform�	__adapt__�_marker�	TypeError)r �objZ	alternate�conform�adapterrrrr7s

zInterfaceBasePy.__call__cCs6|j|�r|Sx"tD]}|||�}|dk	r|SqWdS)z(Adapt an object to the reciever
        N)r/�
adapter_hooks)r r?�hookrArrrr<�s


zInterfaceBasePy.__adapt__N)rr,r-rr=r7r<rrrrr9{sr9)�
InterfaceBase)rBc@s|eZdZdZejZejZffdd�Zdd�Zdd�Z	dd	�Z
ed
d�e
�Zdd
�Z
dd�Zddd�Zddd�Zddd�ZdS)�
SpecificationawSpecifications

    An interface specification is used to track interface declarations
    and component registrations.

    This class is a base class for both interfaces themselves and for
    interface specifications (declarations).

    Specifications are mutable.  If you reassign their bases, their
    relations with other specifications are adjusted accordingly.
    cCsi|_tj�|_t|�|_dS)N)r0�weakref�WeakKeyDictionary�
dependents�tuple�	__bases__)r �basesrrrr!�s
zSpecification.__init__cCs|jj|d�d|j|<dS)Nrr	)rHr&)r �	dependentrrr�	subscribe�szSpecification.subscribecCs@|jj|d�d}|s |j|=n|dkr4||j|<nt|��dS)Nrr	)rHr&�KeyError)r rL�nrrr�unsubscribe�s
zSpecification.unsubscribecCsJx|jD]}|j|�qW||jd<x|D]}|j|�q*W|j|�dS)NrJ)rJrP�__dict__rM�changed)r rK�brrrZ
__setBases�s

zSpecification.__setBasescCs|jjdf�S)NrJ)rQr&)r rrr�<lambda>�szSpecification.<lambda>cCs�y|`Wntk
rYnX|j}|j�t|�}yt|krH|jt�Wntk
r^YnXt|�|_	tdd�|D��|_
x|D]}f||<q�Wx t|jj��D]}|j
|�q�WdS)z4We, or something we depend on, have changed
        cSsg|]}t|t�r|�qSr)�
isinstance�InterfaceClass)�.0�ancestorrrr�
<listcomp>�sz)Specification.changed.<locals>.<listcomp>N)�_v_attrs�AttributeErrorr0�clearr�	Interfacer�	NameErrorrIZ__sro__�__iro__rHr)rR)r Zoriginally_changedZimpliedZ	ancestorsrXrLrrrrR�s$

zSpecification.changedccs@i}x6|jD],}x&|j�D]}||krd||<|VqWqWdS)zDReturn an iterator for the interfaces in the specification.
        r	N)rJ�
interfaces)r �seen�baser5rrrr`szSpecification.interfacesTcCs||jko|p||kS)z�Does the specification extend the given interface?

        Test whether an interface in the specification extends the
        given interface
        )r0)r r5�strictrrr�extendss
zSpecification.extendsNcCstj||�S)N)rF�ref)r �callbackrrrrFszSpecification.weakrefcCs|y
|j}Wntk
r(i}|_YnX|j|�}|dkrhx*|jD] }|j|�}|dk	rD|||<PqDW|dkrt|S|SdS)z+Query for an attribute description
        N)rZr[r&r_�direct)r �namer'�attrs�attrZifacerrrr&s


zSpecification.get)T)N)N)rr,r-rr8r6r/r!rMrPZ_Specification__setBases�propertyrJrRr`rdrFr&rrrrrE�s	!

rEc@s�eZdZdZfdddfdd�Zdd�Zdd�Zd	d
�Zd2dd
�Zdd�Z	d3dd�Z
dd�ZeZdd�Z
dd�Zd4dd�Zd5dd�Zdd�Zdd�Zd d!�Zd"d#�Zd$d%�Zd&d'�Zd(d)�Zd*d+�Zd,d-�Zd.d/�Zd0d1�ZdS)6rVz0Prototype (scarecrow) Interfaces Implementation.NcCs�|dkri}|dkr^|jd�}t|t�r0|d=n.ytjd�jd}Wnttfk
r\YnX||_|jd�}|dk	r�t|t	�s�|dkr�|}|d=|dkr�d}t
j|||�|jt
d�}|dk	r�x |j�D]\}}	|j||	�q�Wx|D]}
t|
t�s�td��q�Wtj||�x�t|j��D]~\}}|d
k�r8||=�qt|t	��rZ||_|j�s�||_n>t|t��rzt|||d
�||<n|tk�r�||=ntd|���qW||_d|j|jf|_dS)Nr,r	rrrzExpected base interfaces�
__locals__r-�__annotations__)rhzConcrete attribute, z%s.%s)rlr-rm)r&rU�strrr�	f_globalsr[rNr,�	Attributerr!�popr�itemsr+rVr>rE�listr5rr�fromFunctionr�InvalidInterface�_InterfaceClass__attrsZ__identifier__)r rhrKrirr,�dZtagged_datar�valrbrjrrrr!5sV







zInterfaceClass.__init__ccs
|VdS)zDReturn an iterator for the interfaces in the specification.
        Nr)r rrrr`yszInterfaceClass.interfacescCs|jS)N)rJ)r rrr�getBases~szInterfaceClass.getBasescCs||kp|j|�S)zSame interface or extends?)rd)r �otherrrr�isEqualOrExtendedBy�sz"InterfaceClass.isEqualOrExtendedByFcCsF|s|jj�S|jj�}x$|jD]}|jtj|j|���q W|j�S)z4Return the attribute names defined by the interface.)rvr)�copyrJ�update�dict�fromkeys�names)r �all�rrbrrrr��s

zInterfaceClass.namescCst|jdd��S)NT)r�)�iterr�)r rrr�__iter__�szInterfaceClass.__iter__cCsT|s|jj�Si}x,|jddd�D]}|jt|j|���q$W|j|j�|j�S)z=Return attribute names and descriptions defined by interface.Nr	���)rvrrrJr}r~�namesAndDescriptions)r r�r�rbrrrr��s
z#InterfaceClass.namesAndDescriptionscCs"|j|�}|dk	r|St|��dS)z4Return the attribute description for the given name.N)r&rN)r rhr�rrr�getDescriptionFor�s
z InterfaceClass.getDescriptionForcCs|j|�dk	S)N)r&)r rhrrr�__contains__�szInterfaceClass.__contains__cCs|jj|�S)N)rvr&)r rhrrrrg�szInterfaceClass.directcCs|j||�S)N)r&)r rhr'rrr�queryDescriptionFor�sz"InterfaceClass.queryDescriptionForcCs�xZ|jdg�D]J}y||�Wqtk
rV}z|dkr<�n
|j|�WYdd}~XqXqWx>|jD]4}y|j||�Wqdtk
r�|dkr��YqdXqdW|r�t|��dS)z&validate object to defined invariants.r
N)r(rrrJ�validateInvariants)r r?�errorsr�erbrrrr��s z!InterfaceClass.validateInvariantscCsRy|jStk
rL|j}|j}|r2d||f}d|jj|f}||_|SXdS)Nz%s.%sz<%s %s>)Z_v_reprr[rr,�	__class__)r rh�mr�rrr�__repr__�szInterfaceClass.__repr__cCs6y||�Stk
r0tj�djdk	r,�YnXdS)N�)r>r�exc_info�tb_next)r r@rrrr;�szInterfaceClass._call_conformcCs|jS)N)r)r rrr�
__reduce__�szInterfaceClass.__reduce__cCsL|dkrdSt|dd�t|dd�f}t|dd�t|dd�f}||k||kS)a�Make interfaces sortable

        TODO: It would ne nice if:

           More specific interfaces should sort before less specific ones.
           Otherwise, sort on name and module.

           But this is too complicated, and we're going to punt on it
           for now.

        For now, sort on interface and module name.

        None is treated as a pseudo interface that implies the loosest
        contact possible, no contract. For that reason, all interfaces
        sort before None.

        Nr	rrr,r�)r:)r rzZn1Zn2rrrZ__cmp�s
zInterfaceClass.__cmpcCs4|j}d|ksd|kr$tjd�dSt|j|jf�S)Nr,rz-Hashing uninitialized InterfaceClass instancer	)rQ�warnings�warn�hashrr,)r rwrrr�__hash__s

zInterfaceClass.__hash__cCs|j|�}|dkS)Nr)�_InterfaceClass__cmp)r rz�crrr�__eq__s
zInterfaceClass.__eq__cCs|j|�}|dkS)Nr)r�)r rzr�rrr�__ne__s
zInterfaceClass.__ne__cCs|j|�}|dkS)Nr)r�)r rzr�rrr�__lt__s
zInterfaceClass.__lt__cCs|j|�}|dkS)Nr)r�)r rzr�rrr�__le__s
zInterfaceClass.__le__cCs|j|�}|dkS)Nr)r�)r rzr�rrr�__gt__s
zInterfaceClass.__gt__cCs|j|�}|dkS)Nr)r�)r rzr�rrr�__ge__#s
zInterfaceClass.__ge__)F)F)N)N)rr,r-rr!r`ryr{r�r�r�r��__getitem__r�rgr�r�r�r;r�r�r�r�r�r�r�r�r�rrrrrV-s4C




rVr]zzope.interface)r,c@seZdZdZdZdS)rpzAttribute descriptions
    N)rr,r-rr5rrrrrp*srpc@s`eZdZdZfZZdZZZdd�Z	dd�Z
dd�Zee	e
e�Z
d	d
�Zdd�Zd
d�ZdS)�Methodz�Method interfaces

    The idea here is that you have objects that describe methods.
    This provides an opportunity for rich meta-data.
    NcCs|jdkriS|jS)N)�	_optional)r rrr�
_get_optionalDs
zMethod._get_optionalcCs
||_dS)N)r�)r �optrrr�
_set_optionalHszMethod._set_optionalcCs
d|_dS)N)r�)r rrr�
_del_optionalJszMethod._del_optionalcOst|j|j��dS)N)�BrokenImplementationr5r)r �args�kwrrrr7NszMethod.__call__cCs|j|j|j|j|jd�S)N)�
positional�required�optional�varargs�kwargs)r�r�r�r�r�)r rrr�getSignatureInfoQs
zMethod.getSignatureInfocCs�g}xD|jD]:}|j|�||jj�kr|ddt|j|�7<qW|jr`|jd|j�|jrv|jd|j�ddj|�S)Nr	�=�*z**z(%s)z, r�)r�rr�r)�reprr�r��join)r Zsig�vrrr�getSignatureStringYs
"zMethod.getSignatureString)rr,r-rr�r�r�r�r�r�r�r�rkr�r7r�r�rrrrr�6sr�cCs |p|j}t||j�}t|dd�p$f}|j}|j|}|j|d�}i}	|t|�}
|
dkrn||
d�}d}
|	jt	t
||
d�|���|d|�|_|d|
�|_|	|_
|}|jt@r�|||_|d}nd|_|jt@r�|||_nd|_||_x$|jj�D]\}}
|j||
��qW|S)N�__defaults__rr	)rr�rr:�__code__�co_argcount�co_varnames�lenr}r~�zipr�r�r��co_flags�
CO_VARARGSr��CO_VARKEYWORDSr�r5rQrrr+)�funcr5�imlevelrh�methodZdefaults�codeZnar�r�ZnrZargnorrrrrrtfs6





rtcCs&t|t�r|j}n|}t||d|d�S)Nr	)r�rh)rUr�__func__rt)�methr5rhr�rrr�
fromMethod�s
r�cCshddlm}ddlm}|t|�ddlm}|t|�ddlm}|t|�ddlm	}|t
|�dS)Nr)�classImplements)�
IAttribute)�IMethod)�
IInterface)�ISpecification)�zope.interface.declarationsr�Zzope.interface.interfacesr�rpr�r�r�rVr�rE)r�r�r�r�r�rrr�_wire�s


r�)r3)r/)ru)r�)NrN)NN)*rZ
__future__rr�typesrrr�rFZzope.interface.exceptionsrZzope.interface.rorr�r�r�objectrrrrr.r8Z-zope.interface._zope_interface_coptimizations�ImportErrorr=r9rDrBrErVr]rpr�rtr�r�r�r3r/rur�rrrr�<module>s^+"|0
-
	

Zerion Mini Shell 1.0