HEX
Server: Apache/2.4.52 (Ubuntu)
System: Linux spn-python 5.15.0-89-generic #99-Ubuntu SMP Mon Oct 30 20:42:41 UTC 2023 x86_64
User: arjun (1000)
PHP: 8.1.2-1ubuntu2.20
Disabled: NONE
Upload Files
File: //usr/local/lib/python3.10/dist-packages/sqlalchemy/util/__pycache__/topological.cpython-310.pyc
o

���g�
�@s�dZddlmZddlmZddlmZddlmZddlmZddlmZddlm	Z	dd	lm
Z
dd
lmZddlmZdd
l
mZddlmZeded�Zgd�Zd+dd�Z	d,d-dd�Zd.d#d$�Zd/d(d)�Zd*S)0zTopological sorting algorithms.�)�annotations)�Any)�
Collection)�DefaultDict)�Iterable)�Iterator)�Sequence)�Set)�Tuple)�TypeVar�)�util)�CircularDependencyError�_T)�bound)�sort�sort_as_subsets�find_cycles�tuples�Collection[Tuple[_T, _T]]�allitems�Collection[_T]�return�Iterator[Sequence[_T]]c#s��t�t�}|D]\}}||�|�qt|�}t|���rSg}|D]}��||�r0|�|�q"|s>tdt||�t	|�����
|��fdd�|D�}|V�sdSdS)NzCircular dependency detected.csg|]}|�vr|�qS�r)�.0�t��todo_setr�F/usr/local/lib/python3.10/dist-packages/sqlalchemy/util/topological.py�
<listcomp>6sz#sort_as_subsets.<locals>.<listcomp>)r
�defaultdict�set�add�list�
isdisjoint�appendrr�
_gen_edges�difference_update)rr�edges�parent�child�todo�output�noderrrrs,�

��
�rT�deterministic_order�bool�Iterator[_T]ccs �t||�D]}|EdHqdS)a,sort the given list of items by dependency.

    'tuples' is a list of tuples representing a partial ordering.

    deterministic_order is no longer used, the order is now always
    deterministic given the order of "allitems".    the flag is there
    for backwards compatibility with Alembic.

    N)r)rrr/�set_rrrr:s��r�Iterable[Tuple[_T, _T]]�Iterable[_T]�Set[_T]cCs�t�t�}|D]\}}||�|�qt|�}t�}|D]D}|g}|�|�}	|r`|d}
||
D])}||vrI||�|�d�}|	�|�|�|�||	vrY|�|�|	�	|�nq0|�
�}|s(q|S)N���)r
r!r"r#�
difference�indexr(�updater&�remove�pop)rrr)r*r+�
nodes_to_testr-r.�stackr,�top�cycrrrrMs0





���rr)�DefaultDict[_T, Set[_T]]�Set[Tuple[_T, _T]]cs�fdd��D�S)Ncs"h|]
}�|D]}||f�qqSrr)r�left�right�r)rr�	<setcomp>xs"z_gen_edges.<locals>.<setcomp>rrDrrDrr'wsr'N)rrrrrr)T)rrrrr/r0rr1)rr3rr4rr5)r)r@rrA)�__doc__�
__future__r�typingrrrrrrr	r
r�r
�excrr�__all__rrrr'rrrr�<module>s(
�
*