Team Ai
Datasetpublic

codekingpro/portable-devtools

sourceHugging Faceupdated 5mo agoView on Hugging Face
1likes14kdownloads
graphlib.cpython-314.pyc100 linesDownload Raw Back to __pycache__
1+
2��i-&��`�^RIHtRR.tR	tR3t!RR4t!RR]4t!RR4tR#)�)�GenericAlias�TopologicalSorter�4CycleErrorc�*a�]tRt^	toRtRtRtVtR#)�	_NodeInfoc�.�Wn^Vn.VnR#)rN��node�
npredecessors�5successors)�selfr6s&&�Lib\graphlib.py�__init__�_NodeInfo.__init__s���	�7������r	N)�__name__�8__module__�__qualname__�__firstlineno__�	__slots__r�__static_attributes__�__classdictcell__��
__classdict__s@rrr	s����5�I��rrc��]tRt^tRtRtR#)ra#Subclass of ValueError raised by TopologicalSorter.prepare if cycles9exist in the working graph.10 11If multiple cycles exist, only one undefined choice among them will be reported12and included in the exception. The detected cycle can be accessed via the second13element in the *args* attribute of the exception instance and consists in a list14of nodes, such that each node is, in the graph, an immediate predecessor of the15next node in the list. In the reported list, the first and the last node will be16the same, to make it clear that it is cyclic.17�N)rrrr�__doc__rrrrrrs��	�	rc�ta�]tRt^)toRtRRltRtRtRtRt	Rt18R	tR19tRt
Rt]!]4tR
tVtR#)rzFProvides functionality to topologically sort a graph of hashable nodesNc��/VnRVn^Vn^VnVe0VP	4Fwr#VP20!V.VO5!K	R#R#�N)�21_node2info�_ready_nodes�_npassedout�22_nfinished�items�add)r
�graphr23�predecessorss&&  rr�TopologicalSorter.__init__,sO����� �����������&+�k�k�m�"������-��-�'4�rc�x�VPPV4;pf\V4;VPV&pV#r )r!�getr)r
r24�results&& r�
_get_nodeinfo�TopologicalSorter._get_nodeinfo6s8���o�o�)�)�$�/�/�F�8�-6�t�_�<�D�O�O�D�!�F��
rc��VPe\R4hVPV4pV;P\	V4,
unVF/pVPV4pVP25P
V4K1	R#)a;Add a new node and its predecessors to the graph.26 27Both the *node* and all elements in *predecessors* must be hashable.28 29If called multiple times with the same node argument, the set of dependencies30will be the union of all dependencies passed in.31 32It is possible to add a node with no dependencies (*predecessors* is not provided)33as well as provide a dependency twice. If a node that has not been provided before34is included among *predecessors* it will be automatically added to the graph with35no predecessors of its own.36 37Raises ValueError if called after "prepare".38Nz/Nodes cannot be added after a call to prepare())r"�39ValueErrorr-r�lenr�append)r
r40r(�nodeinfo�pred�	pred_infos&&*   rr&�TopologicalSorter.add;st�����(��N�O�O��%�%�d�+�����#�l�"3�3��!�D��*�*�4�0�I�� � �'�'��-�!rc�B�VP^8�d\R4hVPfLVPP	4Uu.uF!qP41^8XgKVPNK#	upVnVP4pV'd
\RV4hR#uupi)a�Mark the graph as finished and check for cycles in the graph.42 43If any cycle is detected, "CycleError" will be raised, but "get_ready" can44still be used to obtain as many nodes as possible until cycles block more45progress. After a call to this function, the graph cannot be modified and46therefore no more nodes can be added using "add".47 48Raise ValueError if nodes have already been passed out of the sorter.49 50z$cannot prepare() after starting sortNznodes are in a cycle)	r#r0r"r!�valuesrr51�_find_cycler)r
�i�cycles&  r�prepare�TopologicalSorter.prepareVs������a���C�D�D����$� $��� 6� 6� 8�!� 8�1�O�O�q�<P����� 8�!�D��� � �"����3�U�;�;���!s�B�Bc�&�VPf\R4h\VP4pVPpVFp\W#,nK	VPP
4V;P\V4,
unV#)ayReturn a tuple of all the nodes that are ready.52 53Initially it returns all nodes with no predecessors; once those are marked54as processed by calling "done", further calls will return all new nodes that55have all their predecessors already processed. Once no more progress can be made,56empty tuples are returned.57 58Raises ValueError if called without calling "prepare" previously.59�prepare() must be called first)	r"r0�tupler!�	_NODE_OUTr�clearr#r1)r
r,�n2ir60s&   r�	get_ready�TopologicalSorter.get_readypsy�����$��=�>�>��t�(�(�)���o�o���D�&/�C�I�#��61	
�����!����C��K�'���
rc��VPf\R4hVPVP8;'g\	VP4#)aReturn ``True`` if more progress can be made and ``False`` otherwise.62 63Progress can be made if cycles do not block the resolution and either there64are still nodes ready that haven't yet been returned by "get_ready" or the65number of nodes marked "done" is less than the number that have been returned66by "get_ready".67 68Raises ValueError if called without calling "prepare" previously.69r?)r"r0r$r#�bool�r
s&r�	is_active�TopologicalSorter.is_active�sD�����$��=�>�>�����!1�!1�1�L�L�T�$�:K�:K�5L�Lrc�"�VP4#r )rIrHs&r�__bool__�TopologicalSorter.__bool__�s���~�~��rc�j�VPf\R4hVPpVEFpVPV4;pf\RV:R24hVPpV\708wdAV^8�d\RV:R24hV\8Xd\RV:R24hQRT:RT24h\VnVPFRpW&,pV;P^,unVP^8XgK7VPPV4KT	V;P^,
un	EK		R#)a�Marks a set of nodes returned by "get_ready" as processed.71 72This method unblocks any successor of each node in *nodes* for being returned73in the future by a call to "get_ready".74 75Raises ValueError if any node in *nodes* has already been marked as76processed by a previous call to this method, if a node was not added to the77graph by using "add" or if called without calling "prepare" previously or if78node has not yet been returned by "get_ready".79Nr?znode z was not added using add()z% was not passed out (still not ready)z was already marked donez: unknown status )80r"r0r!r+rrA�81_NODE_DONErr2r$)r
�nodesrCr82r3�stat�	successor�successor_infos&*      r�done�TopologicalSorter.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�I�E�$��1B�4�&�"I�I�5�&0�H�"�&�0�0�	�!$����,�,��1�,�!�/�/�1�4��%�%�,�,�Y�7�	1�83
�O�O�q� �O�O�9rc��VPp.p.p\4p/pVF�pWd9dKWd9dWe9dW%V,RV.,u#McVPV4VP\	W,P844P4\V4WV&VPV4V'dVR,!4pK�K�	R# \d%YRP4TP4KMi;i)TN�����)85r!�setr&r2�iterr�__next__r1�
StopIteration�pop)r
rC�stack�itstack�seen�node2stackir86s&      rr9�TopologicalSorter._find_cycle�s����o�o�������u�����D��|����<��*�$��%6�%8�9�T�F�B�B�+��H�H�T�N��N�N�4��	�(<�(<�#=�#F�#F�G�(+�E�87�K�%��L�L��&��&�&�r�{�}���88�7�8��)�&�'�	�	��4����
�&�s�9C�+C>�=C>c#�"�VP4VP4'd-VP4pTRjx�L89VP!V!KBR#L5i)a)Returns an iterable of nodes in a topological order.90 91The particular order that is returned may depend on the specific92order in which the items were inserted in the graph.93 94Using this method does not require to call "prepare" or "done". If any95cycle is detected, :exc:`CycleError` will be raised.96N)r<rIrDrT)r
�97node_groups& r�static_order�TopologicalSorter.static_order�sF���	
�����n�n������)�J�!�!�!��I�I�z�"��!�s�&A�A�A�A)r$r!r#r"r )rrrrrrr-r&r<rDrIrLrTr9rd�classmethodr�__class_getitem__rrrs@rrr)sJ����P�.��98.�6<�4�4M� �-!�^#�J
#�$�L�1�rNrW�����)	�typesr�__all__rArOrr0rrrrr�<module>rks>�����99-���	�
�100���"	��	�U2�U2r
codekingpro/portable-devtools · Team Ai