Graphics/GraphicsUtilities.py

branch
Py2 comp.
changeset 3057
10516539f238
parent 2538
b2642e7a4c18
parent 2991
226481ff40d1
child 3145
a9de05d4a22f
equal deleted inserted replaced
3056:9986ec0e559a 3057:10516539f238
13 13
14 class RecursionError(OverflowError, ValueError): 14 class RecursionError(OverflowError, ValueError):
15 """ 15 """
16 Unable to calculate result because of recursive structure. 16 Unable to calculate result because of recursive structure.
17 """ 17 """
18 18 pass
19
19 20
20 def sort(nodes, routes, noRecursion=False): 21 def sort(nodes, routes, noRecursion=False):
21 """ 22 """
22 Function to sort widgets topographically. 23 Function to sort widgets topographically.
23 24
50 nodes = list(filter(lambda x, l=stage: x not in l, nodes)) 51 nodes = list(filter(lambda x, l=stage: x not in l, nodes))
51 while nodes: 52 while nodes:
52 previousStageChildren = [] 53 previousStageChildren = []
53 nodelen = len(nodes) 54 nodelen = len(nodes)
54 55
55 # second stage are those nodes, which are direct children of the first stage 56 # second stage are those nodes, which are direct children of the
57 # first stage
56 for node in stage: 58 for node in stage:
57 for child in children.get(node, []): 59 for child in children.get(node, []):
58 if child not in previousStageChildren and child not in taken: 60 if child not in previousStageChildren and child not in taken:
59 previousStageChildren.append(child) 61 previousStageChildren.append(child)
60 elif child in taken and noRecursion: 62 elif child in taken and noRecursion:

eric ide

mercurial