%PDF- %PDF-
Mini Shell

Mini Shell

Direktori : /lib/python3/dist-packages/zope/interface/__pycache__/
Upload File :
Create Path :
Current File : //lib/python3/dist-packages/zope/interface/__pycache__/ro.cpython-312.pyc

�

��e[^���dZdZgd�Zdad�Zd�Zd�Zd�ZGd�d	e�Z	Gd
�de
�ZGd�d
e�Z
Gd�d�ZGd�d�ZGd�d�ZGd�de�ZGd�de�ZGd�d�ZdZdd�Zd�Zy)aj

Compute a resolution order for an object and its bases.

.. versionchanged:: 5.0
   The resolution order is now based on the same C3 order that Python
   uses for classes. In complex instances of multiple inheritance, this
   may result in a different ordering.

   In older versions, the ordering wasn't required to be C3 compliant,
   and for backwards compatibility, it still isn't. If the ordering
   isn't C3 compliant (if it is *inconsistent*), zope.interface will
   make a best guess to try to produce a reasonable resolution order.
   Still (just as before), the results in such cases may be
   surprising.

.. rubric:: Environment Variables

Due to the change in 5.0, certain environment variables can be used to control errors
and warnings about inconsistent resolution orders. They are listed in priority order, with
variables at the bottom generally overriding variables above them.

ZOPE_INTERFACE_WARN_BAD_IRO
    If this is set to "1", then if there is at least one inconsistent resolution
    order discovered, a warning (:class:`InconsistentResolutionOrderWarning`) will
    be issued. Use the usual warning mechanisms to control this behaviour. The warning
    text will contain additional information on debugging.
ZOPE_INTERFACE_TRACK_BAD_IRO
    If this is set to "1", then zope.interface will log information about each
    inconsistent resolution order discovered, and keep those details in memory in this module
    for later inspection.
ZOPE_INTERFACE_STRICT_IRO
    If this is set to "1", any attempt to use :func:`ro` that would produce a non-C3
    ordering will fail by raising :class:`InconsistentResolutionOrderError`.

.. important::

   ``ZOPE_INTERFACE_STRICT_IRO`` is intended to become the default in the future.

There are two environment variables that are independent.

ZOPE_INTERFACE_LOG_CHANGED_IRO
    If this is set to "1", then if the C3 resolution order is different from
    the legacy resolution order for any given object, a message explaining the differences
    will be logged. This is intended to be used for debugging complicated IROs.
ZOPE_INTERFACE_USE_LEGACY_IRO
    If this is set to "1", then the C3 resolution order will *not* be used. The
    legacy IRO will be used instead. This is a temporary measure and will be removed in the
    future. It is intended to help during the transition.
    It implies ``ZOPE_INTERFACE_LOG_CHANGED_IRO``.

.. rubric:: Debugging Behaviour Changes in zope.interface 5

Most behaviour changes from zope.interface 4 to 5 are related to
inconsistent resolution orders. ``ZOPE_INTERFACE_STRICT_IRO`` is the
most effective tool to find such inconsistent resolution orders, and
we recommend running your code with this variable set if at all
possible. Doing so will ensure that all interface resolution orders
are consistent, and if they're not, will immediately point the way to
where this is violated.

Occasionally, however, this may not be enough. This is because in some
cases, a C3 ordering can be found (the resolution order is fully
consistent) that is substantially different from the ad-hoc legacy
ordering. In such cases, you may find that you get an unexpected value
returned when adapting one or more objects to an interface. To debug
this, *also* enable ``ZOPE_INTERFACE_LOG_CHANGED_IRO`` and examine the
output. The main thing to look for is changes in the relative
positions of interfaces for which there are registered adapters.
�restructuredtext)�ro� InconsistentResolutionOrderError�"InconsistentResolutionOrderWarningNc�L�t�ddl}|jt�atS)N�)�__logger�logging�	getLogger�__name__)r	s �3/usr/lib/python3/dist-packages/zope/interface/ro.py�_loggerr
]s ������$�$�X�.���O�c��t�}g}t|�D]:}t|�D]*}||vs�|j|�|jd|��,�<|S)a�Merge multiple orderings so that within-ordering order is preserved

    Orderings are constrained in such a way that if an object appears
    in two or more orderings, then the suffix that begins with the
    object must be in both orderings.

    For example:

    >>> _mergeOrderings([
    ... ['x', 'y', 'z'],
    ... ['q', 'z'],
    ... [1, 3, 5],
    ... ['z']
    ... ])
    ['x', 'y', 'q', 1, 3, 5, 'z']

    r)�set�reversed�add�insert)�	orderings�seen�result�ordering�os     r�_legacy_mergeOrderingsrds_��&�5�D�
�F��Y�'�$���(�#�	$�A���}�������
�
�a��#�	$�$��Mrc�X�|g}d}t|�D]}|dz
}|j|||�|S)Nr�)�iter�	__bases__)�beginr�i�obs    r�_legacy_flattenr!�sB���W�F�	�A��6�l�#��	�Q����l�l��q���#��Mrc�,�tt|�g�S�N)rr!)r s r�
_legacy_ror$�s��!�?�2�#6�"7�8�8rc��eZdZdZy)rz>
    The warning issued when an invalid IRO is requested.
    N)r�
__module__�__qualname__�__doc__�rrrr�s��rrc��eZdZdZd�Zd�Zy)rzK
    The error raised when an invalid IRO is requested in strict mode.
    c��|j|_|j}t|jj�D��cic]\}}|||dz��c}}|_||_tj|�ycc}}w)Nr)	�leaf�C�	base_tree�	enumerater�base_ros�base_tree_remaining�	TypeError�__init__)�self�c3r1r.r�bases      rr3z)InconsistentResolutionOrderError.__init__�sp��������L�L�	�%�T�V�V�%5�%5�6�
���4�
�)�A��E�"�"�
��
�$7�� ����4� ��
s�A9c���ddl}dj|jj|j|j|j�|j|j��S)Nrz7{}: For object {!r}.
Base ROs:
{}
Conflict Location:
{})�pprint�format�	__class__rr-�pformatr0r1)r4r8s  r�__str__z(InconsistentResolutionOrderError.__str__�sN���L�S�S��N�N�#�#��F�F��N�N�4�=�=�)��N�N�4�3�3�4�	
�	
rN)rr&r'r(r3r<r)rrrr�s���!�
rrc���eZdZ�fd�Z�xZS)�
_NamedBoolc�>��t|t�||�}||_|Sr#)�superr>�__new__r)�cls�val�name�instr:s    �rrAz_NamedBool.__new__�s"����S�*�-�c�3�7����
��r)rr&r'rA�
__classcell__)r:s@rr>r>�s
����rr>c��eZdZdZd�Zy)�_ClassBoolFromEnvz�
    Non-data descriptor that reads a transformed environment variable
    as a boolean, and caches the result in the class.
    c�T�ddl}|jD]<}d}t|�D]&}||jvs�|j||us�$|}n|��<nt	d��d|z}|j
j
|d�dk(}t||�}t|||�t|d|z|�|S)NrzUnable to find self�ZOPE_INTERFACE_��1�ORIG_)	�os�__mro__�dir�__dict__�RuntimeError�environ�getr>�setattr)	r4rE�klassrNrB�my_name�k�env_namerCs	         r�__get__z_ClassBoolFromEnv.__get__�s�����=�=�		6�C��G���Z�
������$����a��D�)@��G��
��"��		6��4�5�5�$�w�.���j�j�n�n�X�r�*�c�1����g�&����w��$���w��(�$�/��
rN)rr&r'r(rZr)rrrHrH�s���
rrHc��eZdZdZd�Zd�Zy)�
_StaticMRONc�2�||_t|�|_yr#)r,�tuple�_StaticMRO__mro)r4r-�mros   rr3z_StaticMRO.__init__�s����	��3�Z��
rc�,�t|j�Sr#)�listr_�r4s rr`z_StaticMRO.mro�s���D�J�J��r)rr&r'�had_inconsistencyr3r`r)rrr\r\�s���� � rr\c���eZdZed��ZdZdZdZd�Ze	d��Z
e	d��Ze�Z
e�Ze�Ze�Ze�ZdZd�Zed	��Zed
��Zd�Zd�ZGd
�de�Zd�Zd�Zd�Zy)�C3c��|�|ntj}t}|rt}ntjrt}i}|xsi}|j�D]$\}}||jvsJ�t||�||<�&|||�Sr#)rf�
STRICT_IRO�	_StrictC3�
TRACK_BAD_IRO�_TrackingC3�itemsrr\)r-�strict�	base_mros�factory�memor6r`s       r�resolverzC3.resolver�s���!�-��2�=�=������G�
�
�
�!�G����O��	�"���*�	/�I�D�#��1�;�;�&�&�&�#�D�#�.�D��J�	/��q�$��rNFc��||_||_|j}g}|jD](}||vr|||�}|||<|j	||��*|gg|jD�cgc]}||j���c}zt
|j�gz|_td�|D��|_	t|j�dk(r*|g||jdj�z|_yycc}w)Nc3�4K�|]}|j���y�wr#)rd)�.0r6s  r�	<genexpr>zC3.__init__.<locals>.<genexpr>s����*]�d�4�+A�+A�*]�s�rr)r,rpr:r�appendr`rbr.�any�bases_had_inconsistency�len�_C3__mro)r4r-rp�kind�base_resolversr6rqs       rr3zC3.__init__s����	���	��~�~�����K�K�	.�D��4����d�+��%��T�
��!�!�$�t�*�-�		.��C�
�*+���
�!%�D��J�N�N��
�
�

�����
�	
���(+�*]�n�*]�']��$��q�{�{��q� ���t�A�K�K��N�3�7�7�9�9�D�J�!��
s�%C:c�6�|jxs|jSr#)�direct_inconsistencyrxrcs rrdzC3.had_inconsistencys���(�(�H�D�,H�,H�Hrc��|j�#tt|j��|_t	|j�Sr#)�_C3__legacy_ror^r$r,rbrcs r�	legacy_rozC3.legacy_ro"s5�����#�$�Z��	�	�%:�;�D���D�$�$�%�%rr)c�R�|jsyddl}|jdt�y)Nra�An inconsistent resolution order is being requested. (Interfaces should follow the Python class rules known as C3.) For backwards compatibility, zope.interface will allow this, making the best guess it can to produce as meaningful an order as possible. In the future this might be an error. Set the warning filter to error, or set the environment variable 'ZOPE_INTERFACE_TRACK_BAD_IRO' to '1' and examine ro.C3.BAD_IROS to debug, or set 'ZOPE_INTERFACE_STRICT_IRO' to raise exceptions.)�WARN_BAD_IRO�warnings�warnr)r4r�s  r�	_warn_irozC3._warn_iro/s*��� � �
���
�
�
_�
/�		
rc�B�|D]}|r|d|ur�
|D]	}||us�y�y)NrFTr))r6r1�bases�bs    r�_can_choose_basezC3._can_choose_baseAsB��)�	!�E��E�!�H��,���
!����9� �
!�		!�rc��ttd|D��cgc]}|D�cgc]	}||us�|��c}��c}}��Scc}wcc}}wr#)rb�filter)r.�ignoringr�r�s    r�_nonempty_bases_ignoringzC3._nonempty_bases_ignoringNsJ���F�4��"
���3�1��(�!2�Q�3�"
���	��3��"
s�	>�	9�9�>�>c�N�|j|�}|�|S|j|�S)z�
        Return the next base.

        The return value will either fit the C3 constraints or be our best
        guess about what to do. If we cannot guess, this may raise an exception.
        )�_find_next_C3_base�_guess_next_base)r4r1r6s   r�_choose_next_basezC3._choose_next_baseVs2���&�&�':�;�����K��$�$�%8�9�9rc�H�|D]}|d}|j||�s�|cSy)za
        Return the next base that fits the constraints, or ``None`` if there isn't one.
        rN)r�)r4r1r�r6s    rr�zC3._find_next_C3_basebs7��)�	�E���8�D��$�$�T�+>�?���	�rc��eZdZy)�C3._UseLegacyRON)rr&r'r)rr�_UseLegacyROr�ls��rr�c�\�|j�t||�|_|j�r#)r�rr~r��r4r1s  rr�zC3._guess_next_baseos+��X	
����$D�T�K^�$_��!����rc�
�gx}|_|j}d}	|j||�}|s|S	|j|�}|j
|��:#|j$r |j
|_|j
cYSwxYwr#)rzr.r�r�r�r�rv)r4rr1r6s    r�_mergez	C3._merge�s��� � ����"�n�n�����
#'�"?�"?�@S�UY�"Z��&��
�
&��-�-�.A�B��

�M�M�$�����$�$�
&�!�^�^��
��~�~�%�
&�s�A�,B�Bc��|j�t|j��|_t|j�Sr#)rzr^r�rbrcs rr`zC3.mro�s-���:�:���t�{�{�}�-�D�J��D�J�J��r)rr&r'�staticmethodrqrzr�r~r3�propertyrdr�rHrjrhr��LOG_CHANGED_IRO�USE_LEGACY_IRO�BAD_IROSr�r�r�r�r��	Exceptionr�r�r�r`r)rrrfrf�s���� �� � 
�E��K� ��:�2�I��I��&��&�
&�'�M�"�$�J�$�&�L�'�)�O�&�(�N��H�
�$�
��
�����
:��
�y�
�. �` �, rrfc��eZdZdZd�Zy)rir)c��t||��r#)rr�s  rr�z_StrictC3._guess_next_base�s��.�t�5H�I�IrN�rr&r'�	__slots__r�r)rrriri�s
���I�Jrric��eZdZdZd�Zy)rkr)c�J�ddl}tj}|j|vrl|dk(rddl}|j�x}t_t
||�|j�fx||j<}t�jd|d�tj||�S)Nrr)zTracking inconsistent IRO: %s)�	tracebackrfr�r,�weakref�WeakKeyDictionaryr�format_stackr
�warningr�)r4r1r��bad_irosr��ts      rr�z_TrackingC3._guess_next_base�s�����;�;���9�9�H�$��2�~��)0�)B�)B�)D�D��2�;�0��7J�K��&�&�(�'�
�H�T�Y�Y��!�
�I���=�q��t�D��"�"�4�)<�=�=rNr�r)rrrkrk�s���I�
>rrkc��eZdZGd�d�ZGd�de�ZGd�de�ZeZGd�d�ZGd	�d
e�Z	dZ
dZd�Zd
�Z
d�Zed��Zd�Zy)�
_ROComparisonc��eZdZdZd�Zd�Zy)�_ROComparison.Item�  c��||_yr#)�item)r4r�s  rr3z_ROComparison.Item.__init__�s	���D�Irc�N�dj|j|j�S)Nz{}{})r9�prefixr�rcs rr<z_ROComparison.Item.__str__�s!���=�=�����	�	��
rN)rr&r'r�r3r<r)rr�Itemr��s����	�	rr�c��eZdZdZy)�_ROComparison.Deleted�- N�rr&r'r�r)rr�Deletedr������rr�c��eZdZdZy)�_ROComparison.Inserted�+ Nr�r)rr�Insertedr��r�rr�c� �eZdZdZdZd�Zd�Zy)�_ROComparison.ReplacedByr�rKc� �||_||_yr#)�chunk�total_count)r4r�r�s   rr3z!_ROComparison.ReplacedBy.__init__�s���D�J�*�D�rc��|jD�cgc]'}|jt|�z|jz��)}}t	|�|j
kr*|j
d�t	|�|j
kr�*t|�Scc}w)NrK)r�r��str�suffixryr�rvr)r4r��liness   r�__iter__z!_ROComparison.ReplacedBy.__iter__�s���!�J�J������c�$�i�'�$�+�+�5��E���e�*�t�/�/�/����R� ��e�*�t�/�/�/���;���s�,B
N)rr&r'r�r�r3r�r)rr�
ReplacedByr��s������	+�	rr�c��eZdZdZdZy)�_ROComparison.Replacingr�rKN)rr&r'r�r�r)rr�	Replacingr��s�����rr�Nc�.�||_||_||_yr#)r5�c3_ror�)r4r5r�r�s    rr3z_ROComparison.__init__s�������
�"��rc�~�|D]8}|j||��|j|j���:yr#)rv�Empty)r4�from_�to_r��	operation�xs      r�__movez_ROComparison.__move
s3���	'�A��J�J�y��|�$��L�L�����&�	'rc����j��eddl}|jd�j�j�}gx�_}gx�_}|j
�D�]\}}}}}	�j||	}
�j||}|dk(r4|j�fd�|
D��|j�fd�|D��|dk(r"|
rJ��j|||�j�|dk(r"|rJ��j|||
�j�|dk(s��tt|
�t|��}|j�j|
|��|j�j||�����j�j
fS)Nr�equalc3�@�K�|]}�j|����y�wr#�r��rtr�r4s  �rruz1_ROComparison._generate_report.<locals>.<genexpr>s�����$D�a�T�Y�Y�q�\�$D���c3�@�K�|]}�j|����y�wr#r�r�s  �rruz1_ROComparison._generate_report.<locals>.<genexpr> s�����(L�!����1��(L�r��deleter�replace)�
_c3_report�difflib�SequenceMatcherr�r��_legacy_report�get_opcodes�extend�_ROComparison__mover�r��maxryr�r�)
r4r��matcher�	c3_report�
legacy_report�opcode�leg1�leg2�c31�c32�c3_chunk�legacy_chunk�
chunk_sizes
`            r�_generate_reportz_ROComparison._generate_reportsq����?�?�"���-�-�d�D�N�N�D�J�J�O�G�+-�,�D�O�i�24�4�D��-�07�0C�0C�0E�
T�,���d�C���:�:�c�#�.��#�~�~�d�4�8���W�$��$�$�$D�8�$D�D�!�(�(�(L�|�(L�L��X�%�'�'�<��K�K�	�=�,����U��X�%�+�+�+��K�K�
�y�(�D�M�M�R��Y�&�!$�S��]�C��4E�!F�J��$�$�T�^�^�H�j�%I�J�!�(�(�����z�)R�S�)
T�,���� 3� 3�3�3rc���g}|jjr|jd�|jjr|jd�|rdj	|�SdS)N�directr��+�no)r5r~rvrx�join)r4�inconsistents  r�_inconsistent_labelz!_ROComparison._inconsistent_label1sS�����7�7�'�'�����)��7�7�*�*�����(�)5�s�x�x��%�?�4�?rc	��|j�\}}t|�t|�k(sJ�|D�cgc]
}t|���}}|D�cgc]
}t|���}}t|�t|�k(sJ�d}td�|D��}td�|D��}dj	t|j
��}	dj	t|j�|j�}
||	j|�z|z|
j|�z|d|t|�z|zzzg}|t||�D��
cgc]\}}
||j|�z|z|
z��!c}
}z
}dj|�Scc}wcc}wcc}
}w)Nr�c3�2K�|]}t|����y�wr#�ry�rtr�s  rruz(_ROComparison.__str__.<locals>.<genexpr>Fs����2�!�s�1�v�2���c3�2K�|]}t|����y�wr#rrs  rruz(_ROComparison.__str__.<locals>.<genexpr>Gs����4�1��A��4�rzLegacy RO (len={})zC3 RO (len={}; inconsistent={})�=�
)r�ryr�r�r9r�r�r��ljust�zipr�)r4r�r�r��
left_lines�right_lines�padding�max_left�	max_right�
left_title�right_titler��left�rights              rr<z_ROComparison.__str__:s���#'�#8�#8�#:� �	�=��9�~��]�!3�3�3�3�&3�4��c�!�f�4�
�4�'0�1�!�s�1�v�1��1��:��#�k�"2�2�2�2����2�z�2�2���4��4�4�	�)�0�0��T�^�^�1D�E�
�7�>�>���
�
�O��$�$�
��
�z�'�'��1�
1�G�
;�k�>O�>O�PY�>Z�
Z��c�X��G��4�y�@�A�A�
��	�"�:�{�;�
���e�
�d�j�j��*�*�W�4�u�<�
�	
��
�y�y�����55��1��(
s�E:�	E?�?$F)rr&r'r�r�r�r�r�r�r�r�r�r3r�r�r�r�r<r)rrr�r��sx�����$���4��
�E���"�J��
�J��N�#�
'�
 4�D�@��@� rr�c�l�tj|||�}|j�}|�|n|j}|�|n|j}|s|r�|j
}	t
|	t�sJ�t
|t�sJ�|	|k7}
|
r5|	D�cgc]
}|tus�|��}}|D�cgc]
}|tus�|��}
}||
k7}
|
r(t|||	�}t�jd||�|jr8|	|k(r3t|||	�}t�jd|||j�|r|	S|Scc}wcc}w)aR
    ro(C) -> list

    Compute the precedence list (mro) according to C3.

    :return: A fresh `list` object.

    .. versionchanged:: 5.0.0
       Add the *strict*, *log_changed_ro* and *use_legacy_ro*
       keyword arguments. These are provisional and likely to be
       removed in the future. They are most useful for testing.
    z.Object %r has different legacy and C3 MROs:
%szVObject %r had inconsistent IRO and used the legacy RO:
%s
Inconsistency entered at:
%s)rfrqr`r�r�r��
isinstancerb�_ROOTr�r
r�rdr~)r-rmrn�log_changed_ro�
use_legacy_rorqr`�log_changed�
use_legacyr��changedr��legacy_without_root�mro_without_root�
comparisons               rrr_sG���{�{�1�f�i�0�H�
�,�,�.�C�$2�$>�.�H�D\�D\�K�"/�";���AX�AX�J��j��&�&�	��)�T�*�*�*��#�t�$�$�$��s�"���/8�"J��1�E�>�1�"J��"J�+.�A�a�!�5�.��A��A�)�-=�=�G��&�x��i�@�J��I���A��:�
��%�%�)�s�*:�&�x��i�@�J��I���2��:�x�<�<�
�
����J��)#K��As�
D,�D,�
D1�-D1c�F�tj|dd�jS)zn
    Check if the resolution order for *C*, as computed by :func:`ro`, is consistent
    according to C3.
    FN)rfrqrd)r-s r�
is_consistentr�s ��
�{�{�1�e�T�*�<�<�<�<r)NNNN)r(�
__docformat__�__all__rr
rr!r$�PendingDeprecationWarningrr2r�intr>rHr\rfrirkr�rrrr)rr�<module>r"s���D�J#�
�������:�9��)B��

�y�
�:�����6 � �K �K �\J��J�>�"�>�$E �E �T	
��2�j=r

Zerion Mini Shell 1.0