-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsrc.py
More file actions
executable file
·87 lines (66 loc) · 2.05 KB
/
src.py
File metadata and controls
executable file
·87 lines (66 loc) · 2.05 KB
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
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
"""
# Rules of src
## Optimizations
Best to run this with pypy3
## Using global options
Files needing global options start with `from choice import *`.
Global options are read into class static variables using, eg.
```
class num:
hedges = our.num.hedges # 0.38
conf = our.num.conf # 0.95
```
Thereafter, code needed the options talks to `className.var` and not
`our.x.y`. Why? Well, if you are sick of my global system, then dump it and
make all the config static class variables.
Todo
====
- slit numeg over into thing
- redp div knowing abut thing.n()
"""
from GLOBALS import *
import sys,re
import GLOBALS
from pprint import pprint
from collections import defaultdict
from itertools import takewhile, count
def tsort(graph):
levels_by_name = {}
names_by_level = defaultdict(set)
def walk_depth_first(name):
if name in levels_by_name:
return levels_by_name[name]
children = graph.get(name, None)
level = 0 if not children else (1 +
max(walk_depth_first(lname)
for lname in children))
levels_by_name[name] = level
names_by_level[level].add(name)
return level
for name in graph:
walk_depth_first(name)
return list(takewhile(lambda x: x is not None,
(names_by_level.get(i, None)
for i in count())))
graph = dict(eg = ["GLOBALS"],
GLOBALS= ["opt"],
sample = ["GLOBALS"],
num = ["GLOBALS"],
sym = ["GLOBALS"],
egeg = ["eg"],
table = ["num","sym"])
if our.all.egs:
import os
files=[f for f in os.listdir('.') if re.match(r'.*eg\.py', f)]
print(files)
for file in files:
if file == '__init__.py' : continue
if file=="src.py" : continue
if file=="eg.py" : continue
print("########################")
print("#",file)
print("########################")
__import__(file[:-3])
oks()
if our.all.depends:
pprint( tsort(graph))