ok

Mini Shell

Direktori : /proc/thread-self/root/opt/alt/python311/lib64/python3.11/__pycache__/
Upload File :
Current File : //proc/thread-self/root/opt/alt/python311/lib64/python3.11/__pycache__/graphlib.cpython-311.pyc

�

�f�%��r�ddlmZddgZdZdZGd�d��ZGd�de��ZGd	�d��Zd
S)�)�GenericAlias�TopologicalSorter�
CycleError������c��eZdZdZd�ZdS)�	_NodeInfo��node�
npredecessors�
successorsc�0�||_d|_g|_dS�Nrr
)�selfrs  �//opt/alt/python311/lib64/python3.11/graphlib.py�__init__z_NodeInfo.__init__s ����	�
��������N)�__name__�
__module__�__qualname__�	__slots__r�rrr	r		s(������5�I�����rr	c��eZdZdZdS)raCSubclass of ValueError raised by TopologicalSorter.prepare if cycles
    exist in the working graph.

    If multiple cycles exist, only one undefined choice among them will be reported
    and included in the exception. The detected cycle can be accessed via the second
    element in the *args* attribute of the exception instance and consists in a list
    of nodes, such that each node is, in the graph, an immediate predecessor of the
    next node in the list. In the reported list, the first and the last node will be
    the same, to make it clear that it is cyclic.
    N)rrr�__doc__rrrrrs������	�	�	�Drc�f�eZdZdZd
d�Zd�Zd�Zd�Zd�Zd�Z	d	�Z
d
�Zd�Zd�Z
ee��ZdS)rzFProvides functionality to topologically sort a graph of hashable nodesNc��i|_d|_d|_d|_|�(|���D]\}}|j|g|�R��dSdSr)�
_node2info�_ready_nodes�_npassedout�
_nfinished�items�add)r�graphr�predecessorss    rrzTopologicalSorter.__init__,sq����� �����������&+�k�k�m�m�
.�
.�"��l�����-��-�-�-�-�-���
.�
.rc�p�|j�|��x}�t|��x|j|<}|S�N)r�getr	)rr�results   r�
_get_nodeinfozTopologicalSorter._get_nodeinfo6s9���o�)�)�$�/�/�/�F�8�-6�t�_�_�<�D�O�D�!�F��
rc��|j�td���|�|��}|xjt	|��z
c_|D]1}|�|��}|j�|���2dS)a�Add a new node and its predecessors to the graph.

        Both the *node* and all elements in *predecessors* must be hashable.

        If called multiple times with the same node argument, the set of dependencies
        will be the union of all dependencies passed in.

        It is possible to add a node with no dependencies (*predecessors* is not provided)
        as well as provide a dependency twice. If a node that has not been provided before
        is included among *predecessors* it will be automatically added to the graph with
        no predecessors of its own.

        Raises ValueError if called after "prepare".
        Nz/Nodes cannot be added after a call to prepare())r�
ValueErrorr)r�lenr
�append)rrr$�nodeinfo�pred�	pred_infos      rr"zTopologicalSorter.add;s�����(��N�O�O�O��%�%�d�+�+�����#�l�"3�"3�3���!�	.�	.�D��*�*�4�0�0�I�� �'�'��-�-�-�-�	.�	.rc���|j�td���d�|j���D��|_|���}|rtd|���dS)axMark the graph as finished and check for cycles in the graph.

        If any cycle is detected, "CycleError" will be raised, but "get_ready" can
        still be used to obtain as many nodes as possible until cycles block more
        progress. After a call to this function, the graph cannot be modified and
        therefore no more nodes can be added using "add".
        Nzcannot prepare() more than oncec�2�g|]}|jdk�
|j��S)r)rr)�.0�is  r�
<listcomp>z-TopologicalSorter.prepare.<locals>.<listcomp>as-��
�
�
����1�8L�8L�A�F�8L�8L�8Lrznodes are in a cycle)rr+r�values�_find_cycler)r�cycles  r�preparezTopologicalSorter.prepareVs�����(��>�?�?�?�
�
� �O�2�2�4�4�
�
�
���� � �"�"���	=��4�e�<�<�<�	=�	=rc��|j�td���t|j��}|j}|D]}t||_�|j���|xjt|��z
c_|S)a�Return a tuple of all the nodes that are ready.

        Initially it returns all nodes with no predecessors; once those are marked
        as processed by calling "done", further calls will return all new nodes that
        have all their predecessors already processed. Once no more progress can be made,
        empty tuples are returned.

        Raises ValueError if called without calling "prepare" previously.
        N�prepare() must be called first)	rr+�tupler�	_NODE_OUTr�clearrr,)rr(�n2irs    r�	get_readyzTopologicalSorter.get_readyls�����$��=�>�>�>��t�(�)�)���o���	0�	0�D�&/�C��I�#�#�	
����!�!�!����C��K�K�'����
rc�v�|j�td���|j|jkpt	|j��S)a�Return ``True`` if more progress can be made and ``False`` otherwise.

        Progress can be made if cycles do not block the resolution and either there
        are still nodes ready that haven't yet been returned by "get_ready" or the
        number of nodes marked "done" is less than the number that have been returned
        by "get_ready".

        Raises ValueError if called without calling "prepare" previously.
        Nr;)rr+r r�bool�rs r�	is_activezTopologicalSorter.is_active�s<����$��=�>�>�>����!1�1�L�T�$�:K�5L�5L�Lrc�*�|���Sr&)rDrCs r�__bool__zTopologicalSorter.__bool__�s���~�~���rc��|j�td���|j}|D]�}|�|��x}�td|�d����|j}|t
krG|dkrtd|�d����|tkrtd|�d����Jd|�d	|�����t|_|jD]?}||}|xjd
zc_|jdkr|j�|���@|xj	d
z
c_	��dS)a�Marks a set of nodes returned by "get_ready" as processed.

        This method unblocks any successor of each node in *nodes* for being returned
        in the future by a call to "get_ready".

        Raises :exec:`ValueError` if any node in *nodes* has already been marked as
        processed by a previous call to this method, if a node was not added to the
        graph by using "add" or if called without calling "prepare" previously or if
        node has not yet been returned by "get_ready".
        Nr;znode z was not added using add()rz% was not passed out (still not ready)z was already marked doneFz: unknown status �)
rr+rr'rr=�
_NODE_DONEr
r-r )r�nodesr?rr.�stat�	successor�successor_infos        r�donezTopologicalSorter.done�sc����$��=�>�>�>��o���	!�	!�D� �G�G�D�M�M�)��2� �!K��!K�!K�!K�L�L�L��)�D��y� � ��1�9�9�$�M��M�M�M�����Z�'�'�$�%M�T�%M�%M�%M�N�N�N�I�"I�$�"I�"I�4�"I�"I�I�I�5�&0�H�"�&�0�
8�
8�	�!$�Y����,�,��1�,�,�!�/�1�4�4��%�,�,�Y�7�7�7���O�O�q� �O�O�O�9	!�	!rc��|j}g}g}t��}i}|D]�}||vr�	||vr||vr|||d�|gzcSnn|�|��|�t	||j��j��t|��||<|�|��|rM	|d��}n<#t$r,||�	��=|�	��YnwxYw|�Mn�ތ�dS)NTr)
r�setr"r-�iterr
�__next__r,�
StopIteration�pop)rr?�stack�itstack�seen�node2stackirs       rr7zTopologicalSorter._find_cycle�sQ���o�������u�u�����	�	�D��t�|�|��
��4�<�<��{�*�*�$�[��%6�%8�%8�9�T�F�B�B�B�B�+��H�H�T�N�N�N��N�N�4��D�	�(<�#=�#=�#F�G�G�G�(+�E�
�
�K��%��L�L��&�&�&���&�*�w�r�{�}�}����(�&�&�&�'��	�	���4����
�
�
�
�
�&����	���/
�.��ts�6C�3C=�<C=c#��K�|���|���r<|���}|Ed{V��|j|�|����:dSdS)aQReturns an iterable of nodes in a topological order.

        The particular order that is returned may depend on the specific
        order in which the items were inserted in the graph.

        Using this method does not require to call "prepare" or "done". If any
        cycle is detected, :exc:`CycleError` will be raised.
        N)r9rDr@rN)r�
node_groups  r�static_orderzTopologicalSorter.static_order�s�����	
�������n�n���	#����)�)�J�!�!�!�!�!�!�!�!��D�I�z�"�"��n�n���	#�	#�	#�	#�	#rr&)rrrrrr)r"r9r@rDrFrNr7r[�classmethodr�__class_getitem__rrrrr)s�������P�P�.�.�.�.����
.�.�.�6=�=�=�,���4M�M�M� � � �-!�-!�-!�^#�#�#�J
#�
#�
#�$��L�1�1���rN)	�typesr�__all__r=rIr	r+rrrrr�<module>r`s�����������
-���	�
�
���������"	�	�	�	�	��	�	�	�Q2�Q2�Q2�Q2�Q2�Q2�Q2�Q2�Q2�Q2r

Zerion Mini Shell 1.0