HOME


Mini Shell 1.0
Redirecting to https://devs.lapieza.net/iniciar-sesion Redirecting to https://devs.lapieza.net/iniciar-sesion.
DIR: /lib/python3/dist-packages/zope/interface/common/__pycache__/
Upload File :
Current File : //lib/python3/dist-packages/zope/interface/common/__pycache__/__init__.cpython-311.pyc
�

JDvc�(���ddlZddlmZddlmZddlmZddlmZddlmZddlm	Z	gZ
Gd�d	e��ZGd
�de��Z
d�Ze��ZdS)
�N)�FunctionType)�classImplements)�	Interface)�fromFunction)�InterfaceClass)�_decorator_non_returnc��eZdZd�ZdS)�optionalc��|j|_dS�N��__doc__)�self�methods  �@/usr/lib/python3/dist-packages/zope/interface/common/__init__.py�__init__zoptional.__init__#s���~�����N)�__name__�
__module__�__qualname__r�rrr
r
s#������&�&�&�&�&rr
c�z�eZdZdZd�Zed���Zd�Zed���Zed���Z	d�Z
dd	�Zd
�Zd�Z
dS)
�ABCInterfaceClassa�

    An interface that is automatically derived from a
    :class:`abc.ABCMeta` type.

    Internal use only.

    The body of the interface definition *must* define
    a property ``abc`` that is the ABC to base the interface on.

    If ``abc`` is *not* in the interface definition, a regular
    interface will be defined instead (but ``extra_classes`` is still
    respected).

    Use the ``@optional`` decorator on method definitions if
    the ABC defines methods that are not actually required in all cases
    because the Python language has multiple ways to implement a protocol.
    For example, the ``iter()`` protocol can be implemented with
    ``__iter__`` or the pair ``__len__`` and ``__getitem__``.

    When created, any existing classes that are registered to conform
    to the ABC are declared to implement this interface. This is *not*
    automatically updated as the ABC registry changes. If the body of the
    interface definition defines ``extra_classes``, it should be a
    tuple giving additional classes to declare implement the interface.

    Note that this is not fully symmetric. For example, it is usually
    the case that a subclass relationship carries the interface
    declarations over::

        >>> from zope.interface import Interface
        >>> class I1(Interface):
        ...     pass
        ...
        >>> from zope.interface import implementer
        >>> @implementer(I1)
        ... class Root(object):
        ...     pass
        ...
        >>> class Child(Root):
        ...     pass
        ...
        >>> child = Child()
        >>> isinstance(child, Root)
        True
        >>> from zope.interface import providedBy
        >>> list(providedBy(child))
        [<InterfaceClass __main__.I1>]

    However, that's not the case with ABCs and ABC interfaces. Just
    because ``isinstance(A(), AnABC)`` and ``isinstance(B(), AnABC)``
    are both true, that doesn't mean there's any class hierarchy
    relationship between ``A`` and ``B``, or between either of them
    and ``AnABC``. Thus, if ``AnABC`` implemented ``IAnABC``, it would
    not follow that either ``A`` or ``B`` implements ``IAnABC`` (nor
    their instances provide it)::

        >>> class SizedClass(object):
        ...     def __len__(self): return 1
        ...
        >>> from collections.abc import Sized
        >>> isinstance(SizedClass(), Sized)
        True
        >>> from zope.interface import classImplements
        >>> classImplements(Sized, I1)
        None
        >>> list(providedBy(SizedClass()))
        []

    Thus, to avoid conflicting assumptions, ABCs should not be
    declared to implement their parallel ABC interface. Only concrete
    classes specifically registered with the ABC should be declared to
    do so.

    .. versionadded:: 5.0.0
    c����|�_|�dd��}|�dd��}d|vrAtj�|||��t��||��t�_dS|�d��}|�_t|���_	t|���_
|dd�|jksJ||f����fd�t|�����D��}��
|��|d<|�|��tj�|||������dS)N�
extra_classesr�ignored_classes�abc�c����i|][\}}t|t�����|���/��|���D|��||����\Sr)�
isinstancer�#_ABCInterfaceClass__is_private_name�,_ABCInterfaceClass__is_reverse_protocol_name�(_ABCInterfaceClass__method_from_function)�.0�k�vrs   �r�
<dictcomp>z.ABCInterfaceClass.__init__.<locals>.<dictcomp>�s����
�
�
���1��!�\�*�*�
�
48�3I�3I�!�3L�3L�
��3�3�A�6�6�

�
�t�*�*�1�a�0�0�
�
�
rr)r�poprrr�$_ABCInterfaceClass__register_classes�	__class__�_ABCInterfaceClass__abc�tuple�!_ABCInterfaceClass__extra_classes�#_ABCInterfaceClass__ignored_classes�vars�items�$_ABCInterfaceClass__create_class_doc�update)r�name�bases�attrsrr�based_on�methodss`       rrzABCInterfaceClass.__init__xsq�����
��	�	�/�2�6�6�
��)�)�$5�r�:�:������
�#�D�$��u�=�=�=��0�0��}�o�V�V�V�+�D�N��F��9�9�U�#�#����
�$�]�3�3���!&��!7�!7����A�B�B�x�8�,�,�,�,�t�X�.>�,�,�,�
�
�
�
��X���,�,�.�.�	
�
�
��"�4�4�U�;�;��	�����u�������d�E�7�;�;�;����!�!�!�!�!rc���d�|���D��}|D]}t||<�
|sdSdd�d�|���D����z}|S)Nc�D�i|]\}}t|t���||��Sr)r r
�r$r%r&s   rr'z@ABCInterfaceClass.__optional_methods_to_docs.<locals>.<dictcomp>�s-��O�O�O�d�a��z�!�X�7N�7N�O�Q��O�O�Or�z)

The following methods are optional:
 - z
-c3�4K�|]\}}|�d|j��V��dS)�
Nr
r:s   r�	<genexpr>z?ABCInterfaceClass.__optional_methods_to_docs.<locals>.<genexpr>�sL����K
�K
�*.�!�Q����1�9�9�%�K
�K
�K
�K
�K
�K
r)r0r�join)r5�	optionalsr%�docss    r�__optional_methods_to_docsz,ABCInterfaceClass.__optional_methods_to_docs�s���O�O�e�k�k�m�m�O�O�O�	��	-�	-�A�,�E�!�H�H��	��2�=��
�
�K
�K
�2;�/�/�2C�2C�K
�K
�K
�A
�A
�
���rc	���|j}d��d��fd�t|�������D����}|rd|z}|jpd}|���}|r|dnd}d|j�d	|j�d
|�d|���|�	|���|��}|S)Nc�j�|j}|j}|tjkrd|zS|dkrd}d|�d|�d�S)Nz`%s`�_io�io�`�.)rr�str)�c�modr3s   r�refz1ABCInterfaceClass.__create_class_doc.<locals>.ref�sI���,�C��:�D��c�n�$�$���}�$��e�|�|���� #���T�T�T�*�*rz
 - c3�.�K�|]}�|��V��dSrr)r$rJrLs  �rr>z7ABCInterfaceClass.__create_class_doc.<locals>.<genexpr>�s?�����+
�+
��
�C��F�F�+
�+
�+
�+
�+
�+
r)�keyz!

Known implementations are:

 - r;rzInterface for the ABC `rHz`.

r)
r+r?�sorted�getRegisteredConformersr�
splitlinesrr�get�,_ABCInterfaceClass__optional_methods_to_docs)rr5r6�implementations_doc�based_on_doc�docrLs      @r�__create_class_docz$ABCInterfaceClass.__create_class_doc�s����:��	+�	+�	+�&�l�l�+
�+
�+
�+
��D�8�8�:�:��D�D�D�+
�+
�+
�
�
���	`�"I�L_�"_�� �(�.�B��#�.�.�0�0��*6�>�|�A���B���
�����!2�!2�!2��I�I�i��.�.�.��+�+�E�2�2�2���	
���
rc��|�d��r|�d��rdS|�d��S)N�__F�_��
startswith�endswith�r3s r�__is_private_namez#ABCInterfaceClass.__is_private_name�s@���?�?�4� � �	�T�]�]�4�%8�%8�	��5����s�#�#�#rc�V�|�d��o|�d��S)N�__rrYr[r^s r�__is_reverse_protocol_namez,ABCInterfaceClass.__is_reverse_protocol_name�s'�����u�%�%�=�$�-�-��*=�*=�=rc�R�t|||���}|jdd�|_|S)Nr^r)r�
positional)r�functionr3rs    r�__method_from_functionz(ABCInterfaceClass.__method_from_function�s1���h��4�8�8�8��#�-�a�b�b�1����
rNc��|�|n|���}|�|n|j}|D]}||vr�t||���dSr)rPr.r)r�
conformersr�ignored�clss     r�__register_classesz$ABCInterfaceClass.__register_classes�sg��$.�#9�Z�Z�t�?[�?[�?]�?]�
�%4�%@�/�/�d�F\���	'�	'�C��g�~�~���C��&�&�&�&�	'�	'rc��|jS)z;
        Return the ABC this interface represents.
        )r+)rs r�getABCzABCInterfaceClass.getABC�s���z�rc�l�|j}	t|j��t|j��z}n\#t$rOddlm}||��}|d}|d}d�tj||��D��}d�|D��}YnwxYwttj||j
����S)zz
        Return an iterable of the classes that are known to conform to
        the ABC this interface parallels.
        r)�	_get_dumprc�"�g|]}|����
Srr�r$�xs  r�
<listcomp>z=ABCInterfaceClass.getRegisteredConformers.<locals>.<listcomp>s��H�H�H�!�!�!�#�#�H�H�Hrc��g|]}|�|��Srrrqs  rrsz=ABCInterfaceClass.getRegisteredConformers.<locals>.<listcomp>s��A�A�A��1�=�!�=�=�=r)r+�list�
_abc_registry�
_abc_cache�AttributeErrorrro�	itertools�chain�setr-)rr6�
registeredro�data�registry�caches       rrPz)ABCInterfaceClass.getRegisteredConformers�s���
�:��
	B��h�4�5�5��X�=P�8Q�8Q�Q�J�J���	B�	B�	B�
&�%�%�%�%�%��9�X�&�&�D��A�w�H���G�E�H�H�y��x��'G�'G�H�H�H�J�A�A�Z�A�A�A�J�J�J�	B�����9�?�:�t�/C�D�D�E�E�Es�)3�AB�B)NN)rrrrr�staticmethodrSr1r!r"r#r)rmrPrrrrr's�������J�J�`!"�!"�!"�F����\�����<�$�$��\�$�
�>�>��\�>����'�'�'�'����F�F�F�F�Frrc�n�dtfif}tjtg|�R�}tj|g|�R�|S)N�ABCInterface)rr�__new__rr)�abc_name_bases_attrs�instances  r�_create_ABCInterfacer�sL��
+�Y�L�"�=�� �(�):�R�=Q�R�R�R�H���H�<�';�<�<�<�<��Or)ry�typesr�zope.interfacerr�zope.interface.interfacerrr�__all__�objectr
rr�r�rrr�<module>r�s������������*�*�*�*�*�*�$�$�$�$�$�$�1�1�1�1�1�1�3�3�3�3�3�3�:�:�:�:�:�:���&�&�&�&�&�v�&�&�&�\F�\F�\F�\F�\F��\F�\F�\F�~���$�#�%�%���r