-
Notifications
You must be signed in to change notification settings - Fork 15
/
exp.py
82 lines (70 loc) · 2.04 KB
/
exp.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
71
72
73
74
75
76
77
78
79
80
81
82
from pprint import pprint
from glob import glob
from biplist import readPlist
import yaml
def fix(name):
name = name.lstrip('_')
if name.startswith('input'):
return name[5:]
elif name.startswith('output'):
return name[6:]
return name
fp = file('classes.yaml', 'w')
for fn in glob('qcxmls/QC*.xml'):
cls = fn[9:-4]
node = readPlist(fn)
#if cls in 'Patch ImageLoader Keyboard OpenCL OSCBroadcaster Splitter'.split(' '):
# continue
yaml.dump(node, file('qcxmls/QC%s.yaml' % cls, 'w'))
print >>fp, '%s:' % cls
#pprint(node)
inp = {}
outp = {}
if '.identifiers' in node:
print >>fp, ' identifiers:'
for ident, sub in node['.identifiers'].items():
print >>fp, ' - %s # %s' % (ident, sub['nodeAttributes']['name'])
if 'inputAttributes' in sub:
for name, elem in sub['inputAttributes'].items():
name = fix(name)
if name not in inp:
inp[name] = [[], None]
if not isinstance(elem, dict):
elem = dict(name=elem)
inp[name][0].append(elem['name'])
if 'outputAttributes' in sub:
for name, elem in sub['outputAttributes'].items():
name = fix(name)
if name not in outp:
outp[name] = []
outp[name].append(elem['name'])
if 'inputAttributes' in node:
for name, info in node['inputAttributes'].items():
if not isinstance(info, dict):
continue
name = fix(name)
if name not in inp:
inp[name] = [[], None]
inp[name][0].append(info['name'])
if 'menu' in info:
inp[name][1] = info['menu']
if 'outputAttributes' in node:
for name, info in node['outputAttributes'].items():
name = fix(name)
if name not in outp:
outp[name] = []
outp[name].append(info['name'])
if len(inp):
print >>fp, ' in:'
for name, (names, menu) in inp.items():
print >>fp, ' - %s # %s' % (name, '/'.join(names))
if menu:
for elem in menu:
print >>fp, ' # %s' % elem
if len(outp):
print >>fp, ' out:'
for name, names in outp.items():
print >>fp, ' - %s # %s' % (name, '/'.join(names))
if not len(inp) and not len(outp):
print >>fp, ' -'
print >>fp