zmc
2023-12-22 9fdbf60165db0400c2e8e6be2dc6e88138ac719a
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
U
¸ý°dü ã@sødZddlmZddlmZddlmZddlmZddlmZddlmZddlm    Z    dd    lm
Z
dd
lm Z dd lm Z d d l mZd dlmZe dedZdddgZddddœdd„Zd(dddddœdd„Zddd dœd!d„Zd"d#d$œd%d&„Zd'S))zTopological sorting algorithms.é)Ú annotations)ÚAny)Ú
Collection)Ú DefaultDict)ÚIterable)ÚIterator)ÚSequence)ÚSet)ÚTuple)ÚTypeVaré)Úutil)ÚCircularDependencyErrorÚ_T)ÚboundÚsortÚsort_as_subsetsÚ find_cycleszCollection[Tuple[_T, _T]]zCollection[_T]zIterator[Sequence[_T]])ÚtuplesÚallitemsÚreturnc#s¢t t¡}|D]\}}|| |¡qt|ƒ}t|ƒ‰ˆržg}|D]}ˆ ||¡rB| |¡qB|sztdt||ƒt    |ƒƒ‚ˆ 
|¡‡fdd„|Dƒ}|Vq6dS)NzCircular dependency detected.csg|]}|ˆkr|‘qS©r)Ú.0Út©Ztodo_setrúRd:\z\workplace\vscode\pyvenv\venv\Lib\site-packages\sqlalchemy/util/topological.pyÚ
<listcomp>7sz#sort_as_subsets.<locals>.<listcomp>) r Ú defaultdictÚsetÚaddÚlistÚ
isdisjointÚappendrrÚ
_gen_edgesÚdifference_update)rrÚedgesÚparentÚchildÚtodoÚoutputÚnoderrrrs&
  ý
TÚboolz Iterator[_T])rrÚdeterministic_orderrccst||ƒD]}|EdHq
dS)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;szIterable[Tuple[_T, _T]]z Iterable[_T]zSet[_T]c CsÄt t¡}|D]\}}|| |¡qt|ƒ}tƒ}|D]†}|g}| |¡}    |r8|d}
||
D]R}||kr’|| |¡d…} |     | ¡| | ¡||    kr`| |¡|         |¡qLq`| 
¡}qLq8|S)Néÿÿÿÿ) r rrrÚ
differenceÚindexr$Úupdater"ÚremoveÚpop) rrr%r&r'Z nodes_to_testr)r*Ústackr(ÚtopZcycrrrrNs*
 
 
 
 
 
 zDefaultDict[_T, Set[_T]]zSet[Tuple[_T, _T]])r%rcs‡fdd„ˆDƒS)Ncs"h|]}ˆ|D] }||f’qqSrr)rÚleftÚright©r%rrÚ    <setcomp>ys
z_gen_edges.<locals>.<setcomp>rr8rr8rr#xsr#N)T)Ú__doc__Ú
__future__rÚtypingrrrrrrr    r
r Úr ÚexcrrÚ__all__rrrr#rrrrÚ<module>s&             
 ý*