diff options
author | Jack Jansen <jack.jansen@cwi.nl> | 2002-02-24 23:23:52 (GMT) |
---|---|---|
committer | Jack Jansen <jack.jansen@cwi.nl> | 2002-02-24 23:23:52 (GMT) |
commit | 414a195aa376f5e1d422fe825519c752c6eb6bb7 (patch) | |
tree | 5a9c7707b6075062d78d2e46cb6de61560738741 /Mac | |
parent | 109cd5c5b002b3c76de6502121fd97e6fb576416 (diff) | |
download | cpython-414a195aa376f5e1d422fe825519c752c6eb6bb7.zip cpython-414a195aa376f5e1d422fe825519c752c6eb6bb7.tar.gz cpython-414a195aa376f5e1d422fe825519c752c6eb6bb7.tar.bz2 |
Backport of 1.18 through 1.21:
- Get rid of keyword list and use keyword.iskeyword() function (which I wasn't aware of previously).
- Identify() enum values. This was changed in 1.14, but I don't think it is a good idea.
Diffstat (limited to 'Mac')
-rw-r--r-- | Mac/scripts/gensuitemodule.py | 14 |
1 files changed, 8 insertions, 6 deletions
diff --git a/Mac/scripts/gensuitemodule.py b/Mac/scripts/gensuitemodule.py index a1ae774..5a4c806 100644 --- a/Mac/scripts/gensuitemodule.py +++ b/Mac/scripts/gensuitemodule.py @@ -13,6 +13,7 @@ import sys import types import StringIO import macfs +import keyword from Carbon.Res import * @@ -360,6 +361,10 @@ def compilesuite((suite, fss, modname), major, minor, language, script, fname, b # Standard_Suite or so). Import everything from our base module fp.write('from %s import *\n'%basepackage._code_to_fullname[code][0]) basemodule = basepackage._code_to_module[code] + elif basepackage and basepackage._code_to_module.has_key(code.lower()): + # This is needed by CodeWarrior and some others. + fp.write('from %s import *\n'%basepackage._code_to_fullname[code.lower()][0]) + basemodule = basepackage._code_to_module[code.lower()] else: # We are not an extension. basemodule = None @@ -744,7 +749,7 @@ class ObjectCompiler: def compileenumerator(self, item): [name, code, desc] = item - self.fp.write("\t%s : %s,\t# %s\n" % (`name`, `code`, desc)) + self.fp.write("\t%s : %s,\t# %s\n" % (`identify(name)`, `code`, desc)) def checkforenum(self, enum): """This enum code is used by an event. Make sure it's available""" @@ -812,10 +817,6 @@ def compiledataflags(flags): bits.append(`i`) return '[%s]' % string.join(bits) -# XXXX Do we have a set of python keywords somewhere? -illegal_ids = [ "for", "in", "from", "and", "or", "not", "print", "class", "return", - "def" ] - def identify(str): """Turn any string into an identifier: - replace space by _ @@ -835,7 +836,7 @@ def identify(str): else: rv = rv + '_%02.2x_'%ord(c) ok = ok2 - if rv in illegal_ids: + if keyword.iskeyword(rv): rv = '_' + rv return rv @@ -844,3 +845,4 @@ def identify(str): if __name__ == '__main__': main() sys.exit(1) +print identify('for')
\ No newline at end of file |