-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathcreate_graph.py
70 lines (64 loc) · 2.44 KB
/
create_graph.py
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
#!/usr/bin/env python
'''
Create and format a dependency graph for the project.
'''
from subprocess import Popen, PIPE
# create the graph file
result_1 = Popen(['sfood', 'quicknxs'], stdout=PIPE).communicate()[0]
dot = Popen(['sfood-graph'], stdout=PIPE, stdin=PIPE).communicate(result_1)[0]
# process result dot file data
out_dot = []
ext_packages = []
first_add = True
for line in dot.splitlines():
if (
line.startswith('"quicknxs"')
or 'version' in line
or '"logging"' in line
or 'sip' in line
or 'figureoptions' in line
or 'types' in line
or 'nxutils.so' in line
or 'output_templates' in line
or 'os' in line
or 'sys' in line
):
continue
elif line.startswith('"quicknxs/'):
line = line.replace('style=filled', 'style=filled, color="#00aa00" shape=box, fontsize=24').replace(
'quicknxs/', ''
)
if 'PyQt4' in line or 'email' in line or 'scipy' in line or 'matplotlib/' in line or 'IPython' in line:
line = line.split('/')[0] + '";'
if first_add:
first_add = False
out_dot.append('"PyQt4" [style=filled, color="#aa0000", fontsize=36];')
out_dot.append('"scipy" [style=filled, color="#aaaaff", fontsize=30];')
out_dot.append('"numpy" [style=filled, color="#0000aa", fontsize=32, fontcolor=white];')
out_dot.append('"matplotlib" [style=filled, color="#aa00aa", fontsize=32];')
out_dot.append('"IPython" [style=filled, color="#aaaa00", fontsize=24];')
out_dot.append('"h5py" [style=filled, color="#aaffaa", fontsize=32];')
for sys_module in [
'glob',
'subprocess',
'multiprocessing',
'traceback',
'zipfile',
'StringIO',
'cPickle',
'atexit',
'tempfile',
'getpass',
'time',
'copy',
'inspect',
'email',
'smtplib',
'ConfigParser',
'errno',
]:
out_dot.append('"%s" [shape=hexagon, fontsize=18];' % sys_module)
line = line.replace('pylab', 'matplotlib').replace('cStringIO', 'StringIO')
out_dot.append(line.replace('.py', ''))
out_dot = '\n'.join(out_dot)
Popen(['dot', '-Tps', '-o', 'import_graph.ps'], stdout=PIPE, stdin=PIPE).communicate(out_dot)