blob: bdbca23d307266ffea13895724d4aa5b51fa8aab [file] [log] [blame]
Jack Jansenb9968561995-11-30 15:03:09 +00001"""cmtest - List all components in the system"""
2
Jack Jansen5a6fdcd2001-08-25 12:15:04 +00003from Carbon import Cm
4from Carbon import Res
5from Carbon import sys
Jack Jansenb9968561995-11-30 15:03:09 +00006
7def 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
13def 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
23def 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
37def 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
45main()