HEX
Server: Apache/2.4.65 (Unix) OpenSSL/1.1.1k
System: Linux vps109042.inmotionhosting.com 4.18.0 #1 SMP Mon Sep 30 15:36:27 MSK 2024 x86_64
User: cisa (1010)
PHP: 8.2.30
Disabled: NONE
Upload Files
File: //opt/imh-python/lib/python3.9/site-packages/zope/interface/__pycache__/interface.cpython-39.pyc
a

i�hZ��@sdZddlZddlZddlmZddlmZddlmZddlm	Z	ddl
mZddlm
Z
ddlm	Zgd	�Zd
ZdZdZd
Ze�Ze�Zdd�Zdd�ZGdd�d�ZeZeGdd�d��ZGdd�d�ZeGdd�dee��Zegd�ZGdd�de�Z Gdd�de!�Z"e"dee efd d!i�Z#d"d#�Z$Gd$d�de#�Z%e%d%d&d'�Z&d(d)�e&_'e&�(e&�e&j)e&fk�snJ�e&e _*e&e	_*Gd*d+�d+e%�Z+Gd,d-�d-e�Z,Gd.d/�d/e,�Z-d;d0d1�Z.d<d2d3�Z/d4d5�Z0dd6l1m2Z2dd7l1m3Z3dd8lm4Z4dd9lm5Z5dd:l1m6Z6e �(e6e6�dS)=z Interface object implementation
�N)�FunctionType)�
MethodType��Union)�ro)�_use_c_impl)�Invalid)�InterfaceClass�
Specification�
adapter_hooks��Z__interface_tagged_values__Z__interface_methods__cCs2t�d�j}|�ti�}|�dg�}|�|�tS)N��
invariants)�sys�	_getframe�f_locals�
setdefault�TAGGED_DATA�append�_decorator_non_return)�callr�tagsr�r��/root/rpmbuild/BUILDROOT/imh-python39-modules-3.9.7-92.el8.x86_64/opt/imh-python/lib/python3.9/site-packages/zope/interface/interface.py�	invariant2s

rcCs$t�d�j}|�ti�}|||<tS)z;Attaches a tagged value to an interface at definition time.r)rrrrrr)�key�valuerZ
tagged_valuesrrr�taggedValue:src@sXeZdZdZddd�Zdd�Zdd�Zd	d
�Zddd
�Zdd�Z	dd�Z
eZeZe	Z
dS)�ElementzI
    Default implementation of `zope.interface.interfaces.IElement`.
    �cCs0|s|�d�dkr|}d}||_||_d|_dS)N� r)�find�__name__�__doc__�_Element__tagged_values)�selfr#r$rrr�__init__LszElement.__init__cCs|jS)z! Returns the name of the object. �r#�r&rrr�getNameYszElement.getNamecCs|jS)z+ Returns the documentation for the object. )r$r)rrr�getDoc]szElement.getDoccCs|jst|��|j|S��* Returns the value associated with 'tag'. )r%�KeyError)r&�tagrrr�getTaggedValuehszElement.getTaggedValueNcCs|jr|j�||�S|Sr,)r%�get)r&r/�defaultrrr�queryTaggedValuens���zElement.queryTaggedValuecCs|jr|j��SdS)z# Returns a collection of all tags. r)r%�keysr)rrr�getTaggedValueTagstszElement.getTaggedValueTagscCs|jduri|_||j|<dS)z  Associates 'value' with 'key'. N)r%�r&r/rrrr�setTaggedValuexs
zElement.setTaggedValue)r )N)r#�
__module__�__qualname__r$r'r*r+r0r3r5r7�queryDirectTaggedValueZgetDirectTaggedValue�getDirectTaggedValueTagsrrrrrBs
�


rc@s,eZdZdZdd�Zdd�Zdd�ZeZdS)	�SpecificationBase)�_implied�_dependents�_bases�_v_attrs�__iro__�__sro__�__weakref__cCst|�}||jvS)z2Is the interface implemented by an object
        )�
providedByr=)r&�ob�specrrrrD�szSpecificationBase.providedBycCst|�}||jvS)z�Test whether the specification is implemented by a class or factory.

        Raise TypeError if argument is neither a class nor a callable.
        )�
implementedByr=)r&�clsrFrrrrG�szSpecificationBase.implementedBycCs
||jvS)zCIs the interface the same as or extend the given interface
        �r=)r&�	interfacerrr�isOrExtends�szSpecificationBase.isOrExtendsN)r#r8r9�	__slots__rDrGrK�__call__rrrrr<�s

r<c@s8eZdZdZdd�Zdd�Zdd�Zdd	�Zd
d�ZdS)
�NameAndModuleComparisonMixinrcCs\||urdS|durdS|j|jf}z|j|jf}WntyJtYS0||k||kS)a�
        Compare *self* to *other* based on ``__name__`` and ``__module__``.

        Return 0 if they are equal, return 1 if *self* is
        greater than *other*, and return -1 if *self* is less than
        *other*.

        If *other* does not have ``__name__`` or ``__module__``, then
        return ``NotImplemented``.

        .. caution::
           This allows comparison to things well outside the type hierarchy,
           perhaps not symmetrically.

           For example, ``class Foo(object)`` and ``class Foo(Interface)``
           in the same file would compare equal, depending on the order of
           operands. Writing code like this by hand would be unusual, but it
           could happen with dynamic creation of types and interfaces.

        None is treated as a pseudo interface that implies the loosest
        contact possible, no contract. For that reason, all interfaces
        sort before None.
        rN���)r#r8�AttributeError�NotImplemented)r&�otherZn1Zn2rrr�_compare�s
z%NameAndModuleComparisonMixin._comparecCs|�|�}|tur|S|dkS�Nr�rSrQ�r&rR�crrr�__lt__�s
z#NameAndModuleComparisonMixin.__lt__cCs|�|�}|tur|S|dkSrTrUrVrrr�__le__�s
z#NameAndModuleComparisonMixin.__le__cCs|�|�}|tur|S|dkSrTrUrVrrr�__gt__�s
z#NameAndModuleComparisonMixin.__gt__cCs|�|�}|tur|S|dkSrTrUrVrrr�__ge__�s
z#NameAndModuleComparisonMixin.__ge__N)	r#r8r9rLrSrXrYrZr[rrrrrN�s
'rNc@s^eZdZdZdZddd�Zdd�Zedd	��Ze	fd
d�Z
dd
�Zdd�Zdd�Z
dd�ZdS)�
InterfaceBasez:Base class that wants to be replaced with a C base :)
    )r#�__ibmodule__�_v_cached_hashNcCs||_||_dS�N�r#r])r&�name�modulerrrr'szInterfaceBase.__init__cCst�dSr_)�NotImplementedError�r&�conformrrr�
_call_conformszInterfaceBase._call_conformcCs|jSr_)r]r)rrr�__module_property__sz!InterfaceBase.__module_property__cCsrz
|j}Wnty d}Yn0|dur@|�|�}|dur@|S|�|�}|durV|S|turb|Std||��dS)z)Adapt an object to the interface
        NzCould not adapt)Z__conform__rPrf�	__adapt__�_marker�	TypeError)r&�obj�	alternatere�adapterrrrrMs



zInterfaceBase.__call__cCs6|�|�r|StD]}|||�}|dur|SqdS)z(Adapt an object to the receiver
        N)rDr)r&rk�hookrmrrrrh0s


zInterfaceBase.__adapt__cCs4z|jWSty,t|j|jf�|_Yn0|jSr_)r^rP�hashr#r8r)rrr�__hash__=s
zInterfaceBase.__hash__cCs|�|�}|tur|S|dkSrTrUrVrrr�__eq__Es
zInterfaceBase.__eq__cCs*||urdS|�|�}|tur"|S|dkS)NFrrUrVrrr�__ne__Ks
zInterfaceBase.__ne__)NN)r#r8r9r$rLr'rf�propertyrgrirMrhrprqrrrrrrr\s


r\rc@s�eZdZdZdZdZejZejZddd�Z	e
dd��Zdd	�Zd
d�Z
dd
�Ze
dd�e�ZeZdd�Zdd�Zdd�Zddd�Zddd�Zd dd�ZdS)!r
awSpecifications

    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.
    rNcCs2d|_d|_i|_d|_d|_d|_t|�|_dS)Nr)r>r?r=r@rArB�tuple�	__bases__)r&�basesrrrr'ns	zSpecification.__init__cCs|jdurt��|_|jSr_)r>�weakref�WeakKeyDictionaryr)rrr�
dependents�s

zSpecification.dependentscCs|j�|d�d|j|<dS)Nrr)ryr1r>)r&�	dependentrrr�	subscribe�szSpecification.subscribecCsZz|j|}Wnty(t|��Yn0|d8}|s@|j|=n|dksLJ�||j|<dS)Nrr)r>rjr.ry)r&rz�nrrr�unsubscribe�s
zSpecification.unsubscribecCs>|jD]}|�|�q||_|D]}|�|�q |�|�dSr_)rur}r?r{�changed)r&rv�brrrZ
__setBases�s
zSpecification.__setBasescCs|jSr_)r?r)rrr�<lambda>��zSpecification.<lambda>csV|jdd�|jD�d�}|j��durR|rR|d�urR�fdd�|D�}|���|S)z�Compute resolution order for this object using its ``__bases__``.

        Ensures that ``Interface`` is always the last (lowest priority)
        element.
        cSsi|]}||j�qSr)rB)�.0rrrr�
<dictcomp>�s�z0Specification._calculate_sro.<locals>.<dictcomp>)Z	base_mrosNrOcsg|]}|�ur|�qSrr)r��x��rootrr�
<listcomp>�s�z0Specification._calculate_sro.<locals>.<listcomp>)�_do_calculate_roru�_ROOTr)r&Zsrorr�r�_calculate_sro�s"
�

�
zSpecification._calculate_srocCs~d|_|j}|��|��}t|�|_tdd�|D��|_|D]}d||<q>t|jr^|j��nd�D]}|�	|�qdd|_dS)z�
        We, or something we depend on, have changed.

        By the time this is called, the things we depend on,
        such as our bases, should themselves be stable.
        NcSsg|]}t|t�r|�qSr��
isinstancer	)r��ancestorrrrr��s
�z)Specification.changed.<locals>.<listcomp>r)
r@r=�clearr�rtrBrAr>r4r~)r&Zoriginally_changedZimpliedZ	ancestorsr�rzrrrr~�s

�zSpecification.changedccs8i}|jD](}|��D]}||vrd||<|Vqq
dS)�DReturn an iterator for the interfaces in the specification.
        rN)ru�
interfaces)r&�seen�baserJrrrr�s
zSpecification.interfacesTcCs||jvo|p||kS)z�Does the specification extend the given interface?

        Test whether an interface in the specification extends the
        given interface
        rI)r&rJ�strictrrr�extendss
�zSpecification.extendscCst�||�Sr_)rw�ref)r&�callbackrrrrwszSpecification.weakrefcCsd|j}|duri}|_|�|�}|durT|jD]"}|�|�}|dur0|||<qTq0|dur`|S|S)z+Query for an attribute description
        N)r@r1rA�direct)r&rar2�attrs�attr�ifacerrrr1s



zSpecification.get)r)T)N)N)r#r8r9r$rLr�r<rKrDr'rsryr{r}Z_Specification__setBasesru�calculate_ror�r�r~r�r�rwr1rrrrr
Xs*

�	8"


r
c@s,eZdZdZdd�Zedd��Zdd�ZdS)	�_InterfaceMetaClassrcCsPt�d�jd}tjd}t|t�r.tjd}||d<t�||||�}||_	|S)Nrr#r8rg)
rr�	f_globalsr\�__dict__r��str�type�__new__�_InterfaceMetaClass__module)rHrarvr�r8Zmoduledescr�kindrrrr�|s


z_InterfaceMetaClass.__new__cCs|jSr_)r��rHrrrr8�sz_InterfaceMetaClass.__module__cCsd�|j|j�S)Nz<class '{}.{}'>)�formatr�r#r�rrr�__repr__�s�z_InterfaceMetaClass.__repr__N)r#r8r9rLr�rsr�rrrrr�0s
J
r�r	rLrcCs&t�d�j}|�ti�}|||j<tS)a�
    Convert a method specification to an actual method of the interface.

    This is a decorator that functions like `staticmethod` et al.

    The primary use of this decorator is to allow interface definitions to
    define the ``__adapt__`` method, but other interface methods can be
    overridden this way too.

    .. seealso::
        `zope.interface.interfaces.IInterfaceDeclaration.interfacemethod`
    r)rrrr�INTERFACE_METHODSr#r)�funcr�methodsrrr�interfacemethod�s

r�c@s�eZdZdZd3dd�Zd4dd�Zdd	�Zd
d�Zdd
�Zdd�Z	d5dd�Z
dd�Zd6dd�Zdd�Z
e
Zdd�Zdd�Zd7dd�Zd8dd �Zd9d!d"�Zd#d$�Zd%d&�Zd'd(�Zd)d*�Zd+d,�Zd-d.�Zd/d0�Zd1d2�ZdS):r	z�
    Prototype (scarecrow) Interfaces Implementation.

    Note that it is not possible to change the ``__name__`` or ``__module__``
    after an instance of this object has been constructed.
    NrcCs�t|t�sJ�|pi}|�td�}|r�|�d|vr@d|�d�ini�d|vrVd|d<t|t�rh|f}n|turxtf}n|tf}t|�|d||�}t	�
|�S)N�
__classcell__rhrZ_CALL_CUSTOM_ADAPTz<WithCustomMethods>)r�rt�popr��update�
issubclass� _InterfaceClassWithCustomMethodsr	r��_InterfaceClassBaser�)rHrarvr�r$r8Zneeds_custom_classZ	cls_basesrrrr��s,��
�zInterfaceClass.__new__c
	Cs*tdd�|D��std��|dur&i}|durv|�d�}t|t�rJ|d=n,zt�d�jd}Wntt	fytYn0t
�|||�|�d�}|dur�t|t�s�|dur�|}|d=|dur�d}t
�|||�|�td�}|dur�|��D]\}}	|�||	�q�t�||�|�|�|_|�d	|��|_dS)
Ncss|]}t|t�VqdSr_r�)r�r�rrr�	<genexpr>�r�z*InterfaceClass.__init__.<locals>.<genexpr>zExpected base interfacesr8rr#r$r �.)�allrjr1r�r�rrr�rPr.r\r'�	Attributerr�r�itemsr7r
�_InterfaceClass__compute_attrs�_InterfaceClass__attrsZ__identifier__)
r&rarvr�r$r8�dZtagged_datar�valrrrr'�s:



zInterfaceClass.__init__cs"�fdd���fdd�|��D�S)NcsHt|t�r�|_|jsD||_n&t|t�r8t|�|d�}ntd|��|S)N)razConcrete attribute, )r�r�rJr#r�fromFunction�InvalidInterface)�aname�avalr)rr�update_value!s

z4InterfaceClass.__compute_attrs.<locals>.update_valuecs,i|]$\}}|dvr|tur|�||��qS))Z
__locals__r9�__annotations__Z__static_attributes__Z__firstlineno__Z__classdictcell__)r)r�r�r�)r�rrr�,s�z2InterfaceClass.__compute_attrs.<locals>.<dictcomp>)r�)r&r�r)r&r�rZ__compute_attrss
�zInterfaceClass.__compute_attrsccs
|VdS)r�Nrr)rrrr�BszInterfaceClass.interfacescCs|jSr_)rur)rrr�getBasesGszInterfaceClass.getBasescCs||kp|�|�S)zSame interface or extends?)r��r&rRrrr�isEqualOrExtendedByJsz"InterfaceClass.isEqualOrExtendedByFcCsB|s|j��S|j��}|jD]}|�t�|�|���q|��S)z4Return the attribute names defined by the interface.)r�r4�copyrur��dict�fromkeys�names�r&r��rr�rrrr�Ns


zInterfaceClass.namescCst|jdd��S)NT)r�)�iterr�r)rrr�__iter__ZszInterfaceClass.__iter__cCsP|s|j��Si}|jddd�D]}|�t|�|���q"|�|j�|��S)z=Return attribute names and descriptions defined by interface.NrO)r�r�rur�r��namesAndDescriptionsr�rrrr�]s
z#InterfaceClass.namesAndDescriptionscCs"|�|�}|dur|St|��dS)z4Return the attribute description for the given name.N)r1r.�r&rar�rrr�getDescriptionForls
z InterfaceClass.getDescriptionForcCs|�|�duSr_�r1�r&rarrr�__contains__vszInterfaceClass.__contains__cCs|j�|�Sr_)r�r1r�rrrr�yszInterfaceClass.directcCs|�||�Sr_r�)r&rar2rrr�queryDescriptionFor|sz"InterfaceClass.queryDescriptionForcCsv|jD]^}|�dd�D]L}z||�Wqty`}z"|durJ|�|�n�WYd}~qd}~00qq|rrt|��dS)z&validate object to defined invariants.rrN)rAr:rr)r&rk�errorsr�r�errorrrr�validateInvariantss
z!InterfaceClass.validateInvariantscCs,|jD] }|�|t�}|tur|Sq|S)z�
        Queries for the value associated with *tag*, returning it from the
        nearest interface in the ``__iro__``.

        If not found, returns *default*.
        )rAr:ri)r&r/r2r�rrrrr3�s


zInterfaceClass.queryTaggedValuecCs"|j|td�}|turt|��|S)r-)r2)r3rir.r6rrrr0�szInterfaceClass.getTaggedValuecCs$t�}|jD]}|�|���q|S)z Returns a list of all tags. )�setrAr�r;)r&r4r�rrrr5�s
z!InterfaceClass.getTaggedValueTagscCsHz|jWStyBt|�}d|jj�d|�d�}||_|YS0dS)N�<r!�>)Z_v_reprrPr��	__class__r#r�rrrr��szInterfaceClass.__repr__cCs"|j}|j}|r|�d|��}|S)Nr�r`)r&ra�mrrr�__str__�s
zInterfaceClass.__str__cCs6z
||�WSty0t��djdur,�Yn0dS)N�)rjr�exc_info�tb_nextrdrrrrf�s
zInterfaceClass._call_conformcCs|jSr_r(r)rrr�
__reduce__�szInterfaceClass.__reduce__cCst||fS)z,Allow type hinting syntax: Interface | None.rr�rrr�__or__�szInterfaceClass.__or__cCst||fS)z,Allow type hinting syntax: None | Interface.rr�rrr�__ror__�szInterfaceClass.__ror__)NrNNN)rNNN)F)F)N)N)N)r#r8r9r$r�r'r�r�r�r�r�r�r�r��__getitem__r�r�r�r�r3r0r5r�r�rfr�r�r�rrrrr	�sF�
'�
9$
�




	�	Interfacezzope.interface)r8cCstfSr_)r�rrrrr��r�r�c@seZdZdZdS)r�zc
    Marker class for interfaces with custom methods that override
    InterfaceClass methods.
    N)r#r8r9r$rrrrr��sr�c@s,eZdZdZdZdd�Zdd�Zdd�ZdS)	r�zAttribute descriptions
    NcCsdS)z/Return extra data to put at the end of __str__.r rr)rrr�
_get_str_info�szAttribute._get_str_infocCs<d}|jdur&|jjd|jjd}||jp0d|��S)Nr r�z	<unknown>)rJr8r#r�)r&Zofrrrr��s
����zAttribute.__str__cCs d�t|�jt|�jt|�|�S)Nz<{}.{} object at 0x{:x} {}>)r�r�r8r#�idr)rrrr�s�zAttribute.__repr__)r#r8r9r$rJr�r�r�rrrrr��s
r�c@sdeZdZdZdZZdZZZdd�Z	dd�Z
dd	�Zee	e
e�Z
d
d�Zdd
�Zdd�ZeZdS)�Methodz�Method interfaces

    The idea here is that you have objects that describe methods.
    This provides an opportunity for rich meta-data.
    rNcCs|jduriS|jSr_��	_optionalr)rrr�
_get_optionals
zMethod._get_optionalcCs
||_dSr_r�)r&�optrrr�
_set_optional!szMethod._set_optionalcCs
d|_dSr_r�r)rrr�
_del_optional$szMethod._del_optionalcOst|j|j��dSr_)�BrokenImplementationrJr#)r&�args�kwrrrrM)szMethod.__call__cCs|j|j|j|j|jd�S)N��
positional�required�optional�varargs�kwargsr�r)rrr�getSignatureInfo,s�zMethod.getSignatureInfocCs�g}|jD]:}|�|�||j��vr
|ddt|j|�7<q
|jr\|�d|j�|jrr|�d|j�dd�|�S)NrO�=�*z**z(%s)z, )r�rr�r4�reprr�r��join)r&�sig�vrrr�getSignatureString4s

 zMethod.getSignatureString)r#r8r9r$r�r�r�r�r�r�r�r�rsr�rMr�r�r�rrrrr�
s
r�cCs0|p|j}t||j�}t|dd�p$d}|j}|j|}|j|d�}i}	t|�}
|
s`t|dd�}
||
}|dkr�||d�}d}|	�t	t
||d�|���|d|�|_|d|�|_|	|_
|}|jt@r�|||_|d}nd|_|jt@r�|||_nd|_||_|j��D]\}
}|�|
|��q|S)N�__defaults__rZ__defaults_count__rr)r#r�r$�getattr�__code__�co_argcount�co_varnames�lenr�r��zipr�r�r��co_flags�
CO_VARARGSr��CO_VARKEYWORDSr�rJr�r�r7)r�rJ�imlevelra�method�defaults�code�nar�r�Zdefaults_count�nrZargnorrrrrr�Ds<





r�cCs&t|t�r|j}n|}t||d|d�S)Nr)rra)r�r�__func__r�)�methrJrar�rrr�
fromMethodxs
rcCs~ddlm}ddlm}|t|�ddlm}|t|�ddlm}|t|�ddlm	}|t
|�ddlm}|t|�dS)Nr)�classImplements)�IElement)�
IAttribute)�IMethod)�ISpecification)�
IInterface)
�zope.interface.declarationsrZzope.interface.interfacesrrrr�rr�rr
rr	)rrrrrrrrr�_wire�s



r)rG)rD)r�)r�)�_empty)NrN)NN)7r$rrw�typesrr�typingrZzope.interfacerZzope.interface._compatrZzope.interface.exceptionsrZzope.interface.ror��__all__rrrr��objectrrirrrZSpecificationBasePyr<rNr\rr
r�r�r�r�r	r�r�r~rBr�r�r�r�r�rrrrGrDr�r�rrrrr�<module>sp
A.OP
Yi�'

$7
4