|
3282
|
1 """cmtest - List all components in the system"""
|
|
|
2
|
|
|
3 import Cm
|
|
|
4 import Res
|
|
|
5 import sys
|
|
|
6
|
|
|
7 def getstr255(r):
|
|
|
8 """Get string from str255 resource"""
|
|
|
9 if not r.data: return ''
|
|
|
10 len = ord(r.data[0])
|
|
|
11 return r.data[1:1+len]
|
|
|
12
|
|
|
13 def getinfo(c):
|
|
|
14 """Return (type, subtype, creator, fl1, fl2, name, description) for component"""
|
|
|
15 h1 = Res.Resource('')
|
|
|
16 h2 = Res.Resource('')
|
|
|
17 h3 = Res.Resource('')
|
|
|
18 type, subtype, creator, fl1, fl2 = c.GetComponentInfo(h1, h2, h3)
|
|
|
19 name = getstr255(h1)
|
|
|
20 description = getstr255(h2)
|
|
|
21 return type, subtype, creator, fl1, fl2, name, description
|
|
|
22
|
|
|
23 def getallcomponents():
|
|
|
24 """Return list with info for all components, sorted"""
|
|
|
25 any = ('\0\0\0\0', '\0\0\0\0', '\0\0\0\0', 0, 0)
|
|
|
26 c = None
|
|
|
27 rv = []
|
|
|
28 while 1:
|
|
|
29 try:
|
|
|
30 c = Cm.FindNextComponent(c, any)
|
|
|
31 except Cm.Error:
|
|
|
32 break
|
|
|
33 rv.append(getinfo(c))
|
|
|
34 rv.sort()
|
|
|
35 return rv
|
|
|
36
|
|
|
37 def main():
|
|
|
38 """Print info for all components"""
|
|
|
39 info = getallcomponents()
|
|
|
40 for type, subtype, creator, f1, f2, name, description in info:
|
|
|
41 print '%4.4s %4.4s %4.4s %s 0x%x 0x%x'%(type, subtype, creator, name, f1, f2)
|
|
|
42 print ' ', description
|
|
|
43 sys.exit(1)
|
|
|
44
|
|
|
45 main()
|