Hacked By AnonymousFox

Current Path : /opt/alt/python312/lib64/python3.12/__pycache__/
Upload File :
Current File : //opt/alt/python312/lib64/python3.12/__pycache__/graphlib.cpython-312.opt-1.pyc

�

0�f�%��^�ddlmZddgZdZdZGd�d�ZGd�de�ZGd	�d�Zy
)�)�GenericAlias�TopologicalSorter�
CycleError������c��eZdZdZd�Zy)�	_NodeInfo��node�
npredecessors�
successorsc�.�||_d|_g|_y�Nrr
)�selfrs  �//opt/alt/python312/lib64/python3.12/graphlib.py�__init__z_NodeInfo.__init__s����	�
������N)�__name__�
__module__�__qualname__�	__slots__r�rrr	r		s��5�I�rr	c��eZdZdZy)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��	�	rc�^�eZdZdZd
d�Zd�Zd�Zd�Zd�Zd�Z	d	�Z
d
�Zd�Zd�Z
ee�Zy)rzFProvides functionality to topologically sort a graph of hashable nodesNc��i|_d|_d|_d|_|�,|j	�D]\}}|j
|g|����yyr)�
_node2info�_ready_nodes�_npassedout�
_nfinished�items�add)r�graphr�predecessorss    rrzTopologicalSorter.__init__,sS����� �����������&+�k�k�m�"��l������-��-�'4�rc�t�|jj|�x}�t|�x|j|<}|S�N)r�getr	)rr�results   r�
_get_nodeinfozTopologicalSorter._get_nodeinfo6s8���o�o�)�)�$�/�/�F�8�-6�t�_�<�D�O�O�D�!�F��
rc��|j�td��|j|�}|xjt	|�z
c_|D].}|j|�}|j
j
|��0y)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;st�����(��N�O�O��%�%�d�+�����#�l�"3�3��!�D��*�*�4�0�I�� � �'�'��-�!rc��|j�td��|jj�D�cgc]}|jdk(s�|j
�� c}|_|j
�}|rtd|��ycc}w)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 oncerznodes are in a cycle)rr+r�valuesrr�_find_cycler)r�i�cycles   r�preparezTopologicalSorter.prepareVs}�����(��>�?�?�!�O�O�2�2�4�
�����1�8L�A�F�F�
���� � �"����3�e�<�<���
s�A>�	A>c��|j�td��t|j�}|j}|D]}t||_�|jj
�|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.
        �prepare() must be called first)	rr+�tupler�	_NODE_OUTr�clearrr,)rr(�n2irs    r�	get_readyzTopologicalSorter.get_readyls{�����$��=�>�>��t�(�(�)���o�o���D�&/�C��I�#��
	
�����!����C��K�'���
rc��|j�td��|j|jkxst	|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.
        r8)rr+r r�bool�rs r�	is_activezTopologicalSorter.is_active�sA�����$��=�>�>�����!1�!1�1�L�T�$�:K�:K�5L�Lrc�"�|j�Sr&)rAr@s r�__bool__zTopologicalSorter.__bool__�s���~�~��rc�
�|j�td��|j}|D]�}|j|�x}�td|�d���|j}|t
k7r,|dk\rtd|�d���|tk(rtd|�d���t|_|jD]G}||}|xjdzc_|jdk(s�-|jj|��I|xjdz
c_	��y)	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".
        Nr8znode z was not added using add()rz% was not passed out (still not ready)z was already marked done�)
rr+rr'rr:�
_NODE_DONEr
r-r )r�nodesr<rr.�stat�	successor�successor_infos        r�donezTopologicalSorter.done�s�����$��=�>�>��o�o���D� �G�G�D�M�)��2� �5���0J�!K�L�L��)�)�D��y� ��1�9�$���x�'L�M����Z�'�$�u�T�H�4L�%M�N�N�
&0�H�"�&�0�0�	�!$�Y����,�,��1�,�!�/�/�1�4��%�%�,�,�Y�7�	1�

�O�O�q� �O�9rc���|j}g}g}t�}i}|D]�}||vr�	||vr||vro|||d|gzcS|j|�|jt	||j
�j�t|�||<|j|�|r	|d�}n����y#t$r$||j�=|j�YnwxYw|r�C�8)Nr)
r�setr"r-�iterr
�__next__r,�
StopIteration�pop)rr<�stack�itstack�seen�node2stackirs       rr3zTopologicalSorter._find_cycle�s���o�o�������u�����D��t�|����4�<��{�*�$�[��%6�%8�9�T�F�B�B��H�H�T�N��N�N�4��D�	�(<�(<�#=�#F�#F�G�(+�E�
�K��%��L�L��&��&�*�w�r�{�}���
�/�	�8��)�&�'��	�	��4����
�&��	�s�"
B1�1*C�Cc#��K�|j�|j�r;|j�}|Ed{���|j|�|j�r�:yy7�&�w)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)r6rAr=rK)r�
node_groups  r�static_orderzTopologicalSorter.static_order�sM����	
�����n�n�����)�J�!�!�!��D�I�I�z�"��n�n��!�s�6A!�A�#A!�A!r&)rrrrrr)r"r6r=rArCrKr3rX�classmethodr�__class_getitem__rrrrr)sG��P�.��
.�6=�,�4M� �-!�^#�J
#�$�L�1�rN)	�typesr�__all__r:rFr	r+rrrrr�<module>r]s>�����
-���	�
�
���"	��	�Q2�Q2r

Hacked By AnonymousFox1.0, Coded By AnonymousFox