Kaydet (Commit) b2ecc2c6 authored tarafından Jack Jansen's avatar Jack Jansen

Get rid of keyword list and use keyword.iskeyword() function (which I wasn't aware of previously).

üst 744f67fb
...@@ -13,6 +13,7 @@ import sys ...@@ -13,6 +13,7 @@ import sys
import types import types
import StringIO import StringIO
import macfs import macfs
import keyword
from Carbon.Res import * from Carbon.Res import *
...@@ -816,12 +817,6 @@ def compiledataflags(flags): ...@@ -816,12 +817,6 @@ def compiledataflags(flags):
bits.append(`i`) bits.append(`i`)
return '[%s]' % string.join(bits) return '[%s]' % string.join(bits)
# Set of Python keywords (as of Python 2.2)
illegal_ids = ["and", "elif", "global", "or", "assert", "else", "if", "pass",
"break", "except", "import", "print", "class", "exec", "in", "raise",
"continue", "finally", "is", "return", "def", "for", "lambda", "try",
"del", "from", "not", "while", "yield"]
def identify(str): def identify(str):
"""Turn any string into an identifier: """Turn any string into an identifier:
- replace space by _ - replace space by _
...@@ -841,7 +836,7 @@ def identify(str): ...@@ -841,7 +836,7 @@ def identify(str):
else: else:
rv = rv + '_%02.2x_'%ord(c) rv = rv + '_%02.2x_'%ord(c)
ok = ok2 ok = ok2
if rv in illegal_ids: if keyword.iskeyword(rv):
rv = '_' + rv rv = '_' + rv
return rv return rv
...@@ -850,3 +845,4 @@ def identify(str): ...@@ -850,3 +845,4 @@ def identify(str):
if __name__ == '__main__': if __name__ == '__main__':
main() main()
sys.exit(1) sys.exit(1)
print identify('for')
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment