]> git.saurik.com Git - wxWidgets.git/blob - wxPython/wx/py/wxd/gen.py
Tool tweaks and metadata update
[wxWidgets.git] / wxPython / wx / py / wxd / gen.py
1
2 import inspect
3 from wxPython import wx
4
5
6 def scan():
7 d = wx.__dict__
8 newd = {}
9 keys = d.keys()
10 keys.sort()
11 for key in keys:
12 if key.endswith('Ptr'):
13 # Skip
14 pass
15 elif key+'Ptr' in keys:
16 # Rename
17 newd[key] = d[key+'Ptr']
18 else:
19 # Include as is
20 newd[key] = d[key]
21 d = newd
22 keys = d.keys()
23 keys.sort()
24 for key in keys:
25 value = d[key]
26 if inspect.isclass(value):
27 # genClass(value)
28 pass
29 elif callable(value):
30 genFunction(value)
31 pass
32 else:
33 # print type(value), value
34 pass
35
36
37 def genClass(cls):
38 sp4 = ' ' * 4
39 name = cls.__name__
40 if name.endswith('Ptr'):
41 name = name[:-3]
42 ## if name != 'wxNotebook':
43 ## return
44 parent = ''
45 if cls.__bases__:
46 parent = cls.__bases__[0].__name__
47 if parent.endswith('Ptr'):
48 parent = parent[:-3]
49 parent = '(%s)' % parent
50 items = cls.__dict__.keys()
51 items.sort()
52 print
53 print 'class %s%s:' % (name, parent)
54 print sp4 + '""""""'
55 print
56 for item in items:
57 attr = cls.__dict__[item]
58 if inspect.isfunction(attr):
59 print sp4 + 'def ' + item + '(self):'
60 print sp4 + sp4 + '""""""'
61 print sp4 + sp4 + 'pass'
62 print
63
64
65 def genFunction(func):
66 sp4 = ' ' * 4
67 name = func.__name__
68 print 'def %s():' % name
69 print sp4 + '""""""'
70 print sp4 + 'pass'
71 print