]> git.saurik.com Git - wxWidgets.git/blame_incremental - wxPython/distrib/wx_create.py
mention ShouldInheritColours() change
[wxWidgets.git] / wxPython / distrib / wx_create.py
... / ...
CommitLineData
1"""
2wx_create.py
3
4Originally written by David Hughes <dfh@forestfield.co.uk>
5Massivly hacked by Robin Dunn
6
7This automatically creates all the stub modules that are required in
8the wx package in addition to __init__.py
9
10The module names to make stubs for are found by scanning the wxPython
11package directory. The default directory searched is ../wxPython, but
12you can specify a different one on the command-line if needed.
13
14The content of each module (.py file) is taken from wxmodule_template
15with appropriate substitution of the %name% tokens
16
17"""
18
19import os, sys, glob
20
21wxmodule_template = """
22\"\"\"Renamer stub: provides a way to drop the wx prefix from wxPython objects.\"\"\"
23
24from wx import _rename
25from wxPython%(prefix)s import %(suffix)s
26_rename(globals(), %(suffix)s.__dict__, modulename='%(name)s')
27del %(suffix)s
28del _rename
29"""
30
31call_main = """
32if __name__ == '__main__':
33 main()
34"""
35
36wxPython_dir = "../wxPython"
37
38subpackage_list = ['.',
39 'lib', 'lib/mixins', 'lib/editor', 'lib/colourchooser',
40 'py',
41 'tools', 'tools/XRCed',
42 ]
43
44skip_modules = [ '__init__', '__version__',
45 'wx', 'windows', 'windows2', 'windows3', 'events', 'fonts', 'misc',
46 'misc2', 'gdi', 'mdi', 'controls', 'controls2', 'cmndlgs',
47 'stattool', 'frames', 'image', 'printfw', 'sizers', 'clip_dnd',
48 'filesys', 'streams', 'htmlhelp', 'oglbasic', 'oglshapes',
49 'oglshapes2', 'oglcanvas', 'stc_', 'utils', 'dllwidget_',
50
51 'PyAlaModeTest',
52 ]
53
54
55add_call_main = ['py/PyAlaCarte.py', 'py/PyAlaMode.py', 'py/PyCrust.py',
56 'py/PyFilling.py', 'py/PyShell.py', 'py/PyWrap.py'
57 ]
58
59
60
61# Check for command-line arg
62if len(sys.argv) > 1:
63 wxPython_dir = sys.argv[1]
64
65# check wxPython_dir
66if not os.path.exists(wxPython_dir) or not os.path.isdir(wxPython_dir):
67 print wxPython_dir, "does not exist or is not a directory!"
68 sys.exit()
69
70# check current location
71if os.path.basename(os.getcwd()) <> 'wx':
72 print 'This must be run from inside the target "wx" directory'
73 sys.exit()
74
75
76# build the modules and subpackages as needed
77for subdir in subpackage_list:
78 # create subdir if needed
79 if not os.path.exists(subdir):
80 os.mkdir(subdir)
81
82 # create __init__.py if needed
83 if os.path.isdir(subdir):
84 fname = os.path.join(subdir, '__init__.py')
85 if not os.path.exists(fname):
86 f = open(fname, 'w')
87 f.write("# Python package\n")
88 f.close()
89 else:
90 print subdir + 'exists but is not a directory'
91 sys.exit()
92
93 # find the .py files there and make renamer stubs for them here
94 src = os.path.join(wxPython_dir, subdir, "*.py")
95 for srcname in glob.glob(src):
96 suffix = os.path.splitext(os.path.basename(srcname))[0]
97 if suffix in skip_modules:
98 continue
99 prefix = subdir.replace('/', '.')
100 if prefix == '.':
101 prefix = ''
102 name = suffix
103 else:
104 name = prefix + '.' + suffix
105 prefix = '.' + prefix
106
107 fname = os.path.join(subdir, suffix+".py")
108
109 content = wxmodule_template % globals()
110 f = open(fname, 'w')
111 f.write(content)
112 if fname in add_call_main:
113 f.write(call_main)
114 f.close()
115 print fname + ' created'
116
117
118
119sys.exit()
120
121
122
123