HEX
Server: Apache
System: Linux scp1.abinfocom.com 5.4.0-216-generic #236-Ubuntu SMP Fri Apr 11 19:53:21 UTC 2025 x86_64
User: confeduphaar (1010)
PHP: 8.1.33
Disabled: exec,passthru,shell_exec,system
Upload Files
File: //proc/self/root/usr/lib/python3/dist-packages/zope/interface/__pycache__/interface.cpython-38.pyc
U

ؒ�]�S�@s�dZddlmZddlZddlmZddlmZddlZddlZddl	m
Z
ddlmZdZ
d	Zd
Ze�Zdd�Zd
d�ZGdd�de�ZGdd�de�ZeZzddlmZWnek
r�YnXe�ZGdd�de�ZeZzddlmZWnek
�rYnXgZzddlmZWnek
�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__cCs2t�d�j}|�ti�}|�dg�}|�|�tS)N��
invariants)�sys�	_getframe�f_locals�
setdefault�TAGGED_DATA�append�_decorator_non_return)�callr
Ztagsr
�r�:/usr/lib/python3/dist-packages/zope/interface/interface.py�	invariant"s

rcCs$t�d�j}|�ti�}|||<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`.
    �cCs0|s|�d�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. )rr#rrr�getDocIszElement.getDoccCs
|j|S��* Returns the value associated with 'tag'. �r)r �tagrrr�getTaggedValueMszElement.getTaggedValueNcCs|j�||�Sr&)r�get)r r)�defaultrrr�queryTaggedValueQszElement.queryTaggedValuecCs
|j��S�z Returns a list of all tags. )r�keysr#rrr�getTaggedValueTagsUszElement.getTaggedValueTagscCs||j|<dS)z  Associates 'value' with 'key'. Nr(�r r)rrrr�setTaggedValueYszElement.setTaggedValue)r)N)r�
__module__�__qualname__rr!r$r%r*r-r0r2rrrrr2s	
	
rc@s(eZdZdd�Zdd�Zdd�ZeZdS)�SpecificationBasePycCst|�}||jkS)z2Is the interface implemented by an object
        )�
providedBy�_implied)r �ob�specrrrr6_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.
        )�
implementedByr7)r �clsr9rrrr:esz!SpecificationBasePy.implementedBycCs
||jkS)zCIs the interface the same as or extend the given interface
        �r7)r �	interfacerrr�isOrExtendsmszSpecificationBasePy.isOrExtendsN)rr3r4r6r:r>�__call__rrrrr5]sr5)�SpecificationBasec@s$eZdZdZefdd�Zdd�ZdS)�InterfaceBasePyz:Base class that wants to be replaced with a C base :)
    cCs\t|dd�}|dk	r*|�|�}|dk	r*|S|�|�}|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�adapterrrrr?s

zInterfaceBasePy.__call__cCs6|�|�r|StD]}|||�}|dk	r|SqdS)z(Adapt an object to the reciever
        N)r6�
adapter_hooks)r rG�hookrIrrrrD�s

zInterfaceBasePy.__adapt__N)rr3r4rrEr?rDrrrrrA{srA)�
InterfaceBase)rJc@szeZdZdZejZejZddd�Zdd�Zdd�Z	d	d
�Z
edd�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.
    rcCsi|_t��|_t|�|_dS�N)r7�weakref�WeakKeyDictionary�
dependents�tuple�	__bases__)r �basesrrrr!�s
zSpecification.__init__cCs|j�|d�d|j|<dS�Nrr	)rQr+)r �	dependentrrr�	subscribe�szSpecification.subscribecCs@|j�|d�d}|s |j|=n|dkr4||j|<nt|��dSrU)rQr+�KeyError)r rV�nrrr�unsubscribe�s
zSpecification.unsubscribecCsB|jD]}|�|�q||jd<|D]}|�|�q$|�|�dS)NrS)rSrZ�__dict__rW�changed)r rT�brrrZ
__setBases�s

zSpecification.__setBasescCs|j�dd�S)NrSr)r[r+r#rrr�<lambda>��zSpecification.<lambda>cCs�z|`Wntk
rYnX|j}|��t|�}zt|krH|�t�Wntk
r^YnXt|�|_	tdd�|D��|_
|D]}d||<q�t|j���D]}|�
|�q�dS)z4We, or something we depend on, have changed
        cSsg|]}t|t�r|�qSr)�
isinstance�InterfaceClass)�.0�ancestorrrr�
<listcomp>�s
�z)Specification.changed.<locals>.<listcomp>rN)�_v_attrs�AttributeErrorr7�clearr�	Interfacer�	NameErrorrRZ__sro__�__iro__rQr/r\)r Zoriginally_changedZimpliedZ	ancestorsrcrVrrrr\�s$

zSpecification.changedccs8i}|jD](}|��D]}||krd||<|Vqq
dS)�DReturn an iterator for the interfaces in the specification.
        r	N)rS�
interfaces)r �seen�baser=rrrrls
zSpecification.interfacesTcCs||jko|p||kS)z�Does the specification extend the given interface?

        Test whether an interface in the specification extends the
        given interface
        r<)r r=�strictrrr�extendss
�zSpecification.extendsNcCst�||�SrN)rO�ref)r �callbackrrrrOszSpecification.weakrefcCszz
|j}Wntk
r(i}|_YnX|�|�}|dkrf|jD]"}|�|�}|dk	rB|||<qfqB|dkrr|S|SdS)z+Query for an attribute description
        N)rerfr+rj�direct)r �namer,�attrs�attrZifacerrrr+s



zSpecification.get)r)T)N)N)rr3r4rr@r>r6r!rWrZZ_Specification__setBases�propertyrSr\rlrprOr+rrrrrM�s 

	�!

rMc@s�eZdZdZd9dd�Zdd�Zdd	�Zd
d�Zd:d
d�Zdd�Z	d;dd�Z
dd�ZeZdd�Z
dd�Zd<dd�Zd=dd�Zd>dd�Zdd �Zd!d"�Zd#d$�Zd%d&�Zd'd(�Zd)d*�Zd+d,�Zd-d.�Zd/d0�Zd1d2�Zd3d4�Zd5d6�Zd7d8�ZdS)?raz0Prototype (scarecrow) Interfaces Implementation.rNc	Cs�|dkri}|dkr^|�d�}t|t�r0|d=n.zt�d�jd}Wnttfk
r\YnX||_|�d�}|dk	r�t|t	�s�|dkr�|}|d=|dkr�d}t
�|||�|�t
d�}|dk	r�|��D]\}}	|�||	�q�|D]}
t|
t�s�td��q�t�||�t|���D]~\}}|dk�r.||=�qt|t	��rP||_|j�s�||_n>t|t��rpt|||d�||<n|tk�r�||=ntd	|���q||_d
|j|jf|_dS)Nr3r	rrrzExpected base interfaces)Z
__locals__r4�__annotations__)rtzConcrete attribute, �%s.%s)r+r`�strrr�	f_globalsrfrXr3�	Attributerr!�popr�itemsr2rarFrM�listr=rr�fromFunctionr�InvalidInterface�_InterfaceClass__attrsZ__identifier__)r rtrTrurr3�dZtagged_datar�valrnrvrrrr!5sV







zInterfaceClass.__init__ccs
|VdS)rkNrr#rrrrlyszInterfaceClass.interfacescCs|jSrN)rSr#rrr�getBases~szInterfaceClass.getBasescCs||kp|�|�S)zSame interface or extends?)rp)r �otherrrr�isEqualOrExtendedBy�sz"InterfaceClass.isEqualOrExtendedByFcCsB|s|j��S|j��}|jD]}|�t�|�|���q|��S)z4Return the attribute names defined by the interface.)r�r/�copyrS�update�dict�fromkeys�names�r �all�rrnrrrr��s


zInterfaceClass.namescCst|jdd��S)NT)r�)�iterr�r#rrr�__iter__�szInterfaceClass.__iter__cCsP|s|j��Si}|jddd�D]}|�t|�|���q"|�|j�|��S)z=Return attribute names and descriptions defined by interface.N���)r�r~rSr�r��namesAndDescriptionsr�rrrr��s
z#InterfaceClass.namesAndDescriptionscCs"|�|�}|dk	r|St|��dS)z4Return the attribute description for the given name.N)r+rX)r rtr�rrr�getDescriptionFor�s
z InterfaceClass.getDescriptionForcCs|�|�dk	SrN�r+�r rtrrr�__contains__�szInterfaceClass.__contains__cCs|j�|�SrN)r�r+r�rrrrs�szInterfaceClass.directcCs|�||�SrNr�)r rtr,rrr�queryDescriptionFor�sz"InterfaceClass.queryDescriptionForcCs�|�dg�D]J}z||�Wqtk
rT}z|dkr:�n
|�|�W5d}~XYqXq|jD]4}z|�||�Wq^tk
r�|dkr��Yq^Xq^|r�t|��dS)z&validate object to defined invariants.r
N)r-rrrS�validateInvariants)r rG�errorsr�ernrrrr��s

z!InterfaceClass.validateInvariantscCsJtj||td�}|tk	r|S|jD]"}|j|td�}|tk	r"|Sq"|S�r')r,)rr-rErS)r r)r,rrnrrrr-�s

zInterfaceClass.queryTaggedValuecCs"|j|td�}|tkrt|��|Sr�)r-rErXr1rrrr*�szInterfaceClass.getTaggedValuecCs>tt�|��}|jD]$}|��D]}||kr |�|�q q|Sr.)rrr0rSr)r r/rnrrrrr0�s
z!InterfaceClass.getTaggedValueTagscCsXz|jWStk
rR|j}|j}|r4d||f}d|jj|f}||_|YSXdS)Nryz<%s %s>)Z_v_reprrfrr3�	__class__)r rt�mr�rrr�__repr__�szInterfaceClass.__repr__cCs8z
||�WStk
r2t��djdk	r.�YnXdS)N�)rFr�exc_info�tb_next)r rHrrrrC�s
zInterfaceClass._call_conformcCs|jSrNr"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�rrr3)rB)r r�Zn1Zn2rrrZ__cmps
zInterfaceClass.__cmpcCs4|j}d|ksd|kr$t�d�dSt|j|jf�S)Nr3rz-Hashing uninitialized InterfaceClass instancer	)r[�warnings�warn�hashrr3)r r�rrr�__hash__#s

zInterfaceClass.__hash__cCs|�|�}|dkS�Nr��_InterfaceClass__cmp�r r��crrr�__eq__*s
zInterfaceClass.__eq__cCs|�|�}|dkSr�r�r�rrr�__ne__.s
zInterfaceClass.__ne__cCs|�|�}|dkSr�r�r�rrr�__lt__2s
zInterfaceClass.__lt__cCs|�|�}|dkSr�r�r�rrr�__le__6s
zInterfaceClass.__le__cCs|�|�}|dkSr�r�r�rrr�__gt__:s
zInterfaceClass.__gt__cCs|�|�}|dkSr�r�r�rrr�__ge__>s
zInterfaceClass.__ge__)rNNN)F)F)N)N)N)rr3r4rr!rlr�r�r�r�r�r��__getitem__r�rsr�r�r-r*r0r�rCr�r�r�r�r�r�r�r�r�rrrrra-s<�
D





	rarhzzope.interface)r3c@seZdZdZdZdS)r|zAttribute descriptions
    N)rr3r4rr=rrrrr|Esr|c@s`eZdZdZdZZdZZZdd�Z	dd�Z
dd	�Zee	e
e�Z
d
d�Zdd
�Zdd�ZdS)�Methodz�Method interfaces

    The idea here is that you have objects that describe methods.
    This provides an opportunity for rich meta-data.
    rNcCs|jdkriS|jSrN��	_optionalr#rrr�
_get_optional_s
zMethod._get_optionalcCs
||_dSrNr�)r �optrrr�
_set_optionalcszMethod._set_optionalcCs
d|_dSrNr�r#rrr�
_del_optionaleszMethod._del_optionalcOst|j|j��dSrN)�BrokenImplementationr=r)r �args�kwrrrr?iszMethod.__call__cCs|j|j|j|j|jd�S)N��
positional�required�optional�varargs�kwargsr�r#rrr�getSignatureInfols�zMethod.getSignatureInfocCs�g}|jD]:}|�|�||j��kr
|ddt|j|�7<q
|jr\|�d|j�|jrr|�d|j�dd�|�S)Nr��=�*z**z(%s)z, )r�rr�r/�reprr�r��join)r Zsig�vrrr�getSignatureStringts

 zMethod.getSignatureString)rr3r4rr�r�r�r�r�r�r�r�rwr�r?r�r�rrrrr�Qsr�cCs|p|j}t||j�}t|dd�p$d}|j}|j|}|j|d�}i}	|t|�}
|
dkrn||
d�}d}
|	�t	t
||
d�|���|d|�|_|d|
�|_|	|_
|}|jt@r�|||_|d}nd|_|jt@r�|||_nd|_||_|j��D]\}}
|�||
��q|S)N�__defaults__rrr	)rr�rrB�__code__�co_argcount�co_varnames�lenr�r��zipr�r�r��co_flags�
CO_VARARGSr��CO_VARKEYWORDSr�r=r[r~r2)�funcr=�imlevelrt�method�defaults�codeZnar�r�ZnrZargnorrrrrr��s6





r�cCs&t|t�r|j}n|}t||d|d�S)Nr	)r�rt)r`r�__func__r�)�methr=rtr�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�r|r�r�r�rar�rM)r�r�r�r�r�rrr�_wire�s


r�)r:)r6)r�)r�)NrN)NN)*rZ
__future__rr�typesrrr�rOZzope.interface.exceptionsrZzope.interface.rorr�r�r�objectrrrrr5r@Z-zope.interface._zope_interface_coptimizations�ImportErrorrErArLrJrMrarhr|r�r�r�r�r�r:r6r�r�rrrr�<module>s`+"0
-