]>
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 __cvsid__ = \"\x24Id: \x24\"
25 __revision__ = \"\x24Revision: \x24\"[11:-2]
27 from wx import _rename
28 from wxPython%(prefix)s import %(suffix)s
29 _rename(globals(), %(suffix)s.__dict__, modulename='%(name)s')
34 wxPython_dir
= "../wxPython"
36 subpackage_list
= ['.',
37 'lib', 'lib/mixins', 'lib/editor', 'lib/colourchooser',
39 'tools', 'tools/XRCed',
42 skip_modules
= [ '__init__', '__version__',
43 'wx', 'windows', 'windows2', 'windows3', 'events', 'fonts', 'misc',
44 'misc2', 'gdi', 'mdi', 'controls', 'controls2', 'cmndlgs',
45 'stattool', 'frames', 'image', 'printfw', 'sizers', 'clip_dnd',
46 'filesys', 'streams', 'htmlhelp', 'oglbasic', 'oglshapes',
47 'oglshapes2', 'oglcanvas', 'stc_', 'utils', 'dllwidget_',
56 # Check for command-line arg
58 wxPython_dir
= sys
.argv
[1]
61 if not os
.path
.exists(wxPython_dir
) or not os
.path
.isdir(wxPython_dir
):
62 print wxPython_dir
, "does not exist or is not a directory!"
65 # check current location
66 if os
.path
.basename(os
.getcwd()) <> 'wx':
67 print 'This must be run from inside the target "wx" directory'
71 # build the modules and subpackages as needed
72 for subdir
in subpackage_list
:
73 # create subdir if needed
74 if not os
.path
.exists(subdir
):
77 # create __init__.py if needed
78 if os
.path
.isdir(subdir
):
79 fname
= os
.path
.join(subdir
, '__init__.py')
80 if not os
.path
.exists(fname
):
82 f
.write("# Python package\n")
85 print subdir
+ 'exists but is not a directory'
88 # find the .py files there and make renamer stubs for them here
89 src
= os
.path
.join(wxPython_dir
, subdir
, "*.py")
90 for srcname
in glob
.glob(src
):
91 suffix
= os
.path
.splitext(os
.path
.basename(srcname
))[0]
92 if suffix
in skip_modules
:
94 prefix
= subdir
.replace('/', '.')
99 name
= prefix
+ '.' + suffix
100 prefix
= '.' + prefix
102 fname
= os
.path
.join(subdir
, suffix
+".py")
104 content
= wxmodule_template
% globals()
108 print fname
+ ' created'