Hacked By AnonymousFox

Current Path : /opt/alt/python39/lib64/python3.9/__pycache__/
Upload File :
Current File : //opt/alt/python39/lib64/python3.9/__pycache__/graphlib.cpython-39.opt-1.pyc

a

R�fe%�@s@ddgZdZdZGdd�d�ZGdd�de�ZGdd�d�ZdS)	�TopologicalSorter�
CycleError������c@seZdZdZdd�ZdS)�	_NodeInfo��node�
npredecessors�
successorscCs||_d|_g|_dS�N�r)�selfr�r
�-/opt/alt/python39/lib64/python3.9/graphlib.py�__init__
sz_NodeInfo.__init__N)�__name__�
__module__�__qualname__�	__slots__rr
r
r
rrsrc@seZdZdZdS)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__r
r
r
rrsc@sbeZdZdZddd�Zdd�Zdd�Zd	d
�Zdd�Zd
d�Z	dd�Z
dd�Zdd�Zdd�Z
dS)rzFProvides functionality to topologically sort a graph of hashable nodesNcCsHi|_d|_d|_d|_|durD|��D]\}}|j|g|�R�q(dSr
)�
_node2info�_ready_nodes�_npassedout�
_nfinished�items�add)rZgraphr�predecessorsr
r
rr*szTopologicalSorter.__init__cCs*|j�|�}dur&t|�|j|<}|S�N)r�getr)rr�resultr
r
r�
_get_nodeinfo4szTopologicalSorter._get_nodeinfocGsR|jdurtd��|�|�}|jt|�7_|D]}|�|�}|j�|�q2dS)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�
ValueErrorrr�lenr	�append)rrr�nodeinfoZpredZ	pred_infor
r
rr9s


zTopologicalSorter.addcCsB|jdurtd��dd�|j��D�|_|��}|r>td|��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 oncecSsg|]}|jdkr|j�qS)r)rr)�.0�ir
r
r�
<listcomp>_sz-TopologicalSorter.prepare.<locals>.<listcomp>znodes are in a cycle)rr r�values�_find_cycler)r�cycler
r
r�prepareTs
�zTopologicalSorter.preparecCsV|jdurtd��t|j�}|j}|D]}t||_q&|j��|jt|�7_|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!)rr�n2irr
r
r�	get_readyjs



zTopologicalSorter.get_readycCs(|jdurtd��|j|jkp&t|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 rr�bool�rr
r
r�	is_active�s

zTopologicalSorter.is_activecCs|��Sr)r3r2r
r
r�__bool__�szTopologicalSorter.__bool__cGs�|jdurtd��|j}|D]�}|�|�}durBtd|�d���|j}|tkr�|dkrjtd|�d���n|tkr�td|�d���nt|_|jD]0}||}|jd8_|jdkr�|j�|�q�|j	d7_	qdS)	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 done�)
rr rrrr-�
_NODE_DONEr	r"r)rZnodesr/rr#�statZ	successorZsuccessor_infor
r
r�done�s*

�

zTopologicalSorter.donec	Cs�|j}g}g}t�}i}|D]�}||vr*q||vrV||vr�|||d�|gSn6|�|�|�t||j�j�t|�||<|�|�|r�z|d�}Wq*Wq�ty�||�	�=|�	�Yq�0q�qq*qdS)Nr)
r�setrr"�iterr	�__next__r!�
StopIteration�pop)rr/�stackZitstack�seenZnode2stackirr
r
rr(�s0



zTopologicalSorter._find_cycleccs2|��|��r.|��}|EdH|j|�qdS)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)r*r3r0r8)rZ
node_groupr
r
r�static_order�s
	
zTopologicalSorter.static_order)N)rrrrrrrr*r0r3r4r8r(r@r
r
r
rr's

/%N)�__all__r-r6rr rrr
r
r
r�<module>s


Hacked By AnonymousFox1.0, Coded By AnonymousFox