]>
git.saurik.com Git - wxWidgets.git/blob - wxPython/distrib/wx_create.py
4 Originally written by David Hughes <dfh@forestfield.co.uk>
5 Massivly hacked by Robin Dunn
7 This automatically creates all the stub modules that are required in
8 the wx package in addition to __init__.py
10 The module names to make stubs for are found by scanning the wxPython
11 package directory. The default directory searched is ../wxPython, but
12 you can specify a different one on the command-line if needed.
14 The content of each module (.py file) is taken from wxmodule_template
15 with appropriate substitution of the %name% tokens
21 wxmodule_template
= """
22 \"\"\"Renamer stub: provides a way to drop the wx prefix from wxPython objects.\"\"\"
24 from wx import _rename
25 from wxPython%(prefix)s import %(suffix)s
26 _rename(globals(), %(suffix)s.__dict__, modulename='%(name)s')
32 if __name__ == '__main__':
36 wxPython_dir
= "../wxPython"
38 subpackage_list
= ['.',
39 'lib', 'lib/mixins', 'lib/editor', 'lib/colourchooser',
41 'tools', 'tools/XRCed',
44 skip_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_',
55 add_call_main
= ['py/PyAlaCarte.py', 'py/PyAlaMode.py', 'py/PyCrust.py',
56 'py/PyFilling.py', 'py/PyShell.py', 'py/PyWrap.py'
61 # Check for command-line arg
63 wxPython_dir
= sys
.argv
[1]
66 if 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!"
70 # check current location
71 if os
.path
.basename(os
.getcwd()) <> 'wx':
72 print 'This must be run from inside the target "wx" directory'
76 # build the modules and subpackages as needed
77 for subdir
in subpackage_list
:
78 # create subdir if needed
79 if not os
.path
.exists(subdir
):
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
):
87 f
.write("# Python package\n")
90 print subdir
+ 'exists but is not a directory'
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
:
99 prefix
= subdir
.replace('/', '.')
104 name
= prefix
+ '.' + suffix
105 prefix
= '.' + prefix
107 fname
= os
.path
.join(subdir
, suffix
+".py")
109 content
= wxmodule_template
% globals()
112 if fname
in add_call_main
:
115 print fname
+ ' created'