Regenerated the files for the wx renamer package

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/branches/WX_2_4_BRANCH@21064 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Robin Dunn
2003-06-11 23:56:55 +00:00
parent 2ac01a6ca3
commit 1f1c4a921b
115 changed files with 845 additions and 723 deletions

View File

@@ -1,41 +1,74 @@
"""wx package
Provides a way to drop the wx prefix from wxPython objects."""
Provides a way to drop the wx prefix from wxPython objects by
dynamically loading and renaming objects from the real wxPython
package. This is the first phase of a transition to a new style of
using wxPython. For example:
import wx
class MyFrame(wx.Frame):
...
instead of:
from wxPython.wx import *
class MyFrame(wxFrame):
...
or:
from wxPython import wx
class MyFrame(wx.wxFrame):
...
Internally, this package contains only one function, called _rename,
and one dictionary, called _newnames. These are used by wx itself and
by its sub-modules whenever they are imported. The _rename function
changes the names in the real wxPython module being imported according
to the rules that have been decided, e.g. most wx prefixes are
removed, and the new names are made visible in the wx package or
sub-packages.
The _newnames dictionary holds the set of new names (from wx and ALL
sub-modules), keyed by the original name. This serves two purposes,
duplicate old names in different modules are eliminated, the survivor
being the name in wx itself; and the dictionary is accessible to
external scripts whose purpose is to change occurrences of the
corresponding names in application programs that use wx.
"""
__author__ = "Patrick K. O'Brien <pobrien@orbtech.com>"
__cvsid__ = "$Id$"
__revision__ = "$Revision$"[11:-2]
from wxPython import wx
import types
_newnames = {}
d_new = globals()
d_old = wx.__dict__
for old, obj in d_old.items():
if type(obj) is types.ModuleType or old.startswith('_'):
# Skip modules and private names.
continue
new = old
if old.startswith('EVT_'):
# Leave name unmodified; add to the new wx namespace.
d_new[new] = obj
elif old.startswith('wxEVT_'):
# Leave name unmodified; add to the new wx namespace.
d_new[new] = obj
else:
if old.startswith('wx'):
# Remove the 'wx' prefix.
def _rename(d_new, d_old, modulename=None):
" copy the names from d_old to d_new according to the rules"
global _newnames
import types
prefix = 'wx.'
if modulename:
prefix += modulename + '.'
for old, obj in d_old.items():
if type(obj) is types.ModuleType or old.startswith('_'):
# Skip modules and private names.
continue
if old.startswith('wx') and not old.startswith('wxEVT_'):
# remove all wx prefixes except wxEVT_
new = old[2:]
# Add to the new wx package namespace.
d_new[new] = obj
else:
# add everything else unchanged
new = old
if _newnames.has_key(old):
d_new[new] = obj
_newnames[old] = prefix + new # add fully qualified new name to lookup using old name as key
del d_new
del d_old
del new
del obj
del old
del types
# rename the wx namespace itself
_rename(globals(), wx.__dict__)
del wx