2010-03-11 18:53:45 -04:00
|
|
|
#! /usr/bin/env python3
|
2000-02-04 11:10:34 -04:00
|
|
|
|
|
|
|
"""Keywords (from "graminit.c")
|
|
|
|
|
|
|
|
This file is automatically generated; please don't muck it up!
|
|
|
|
|
|
|
|
To update the symbols in this file, 'cd' to the top directory of
|
|
|
|
the python source tree after building the interpreter and run:
|
|
|
|
|
2011-11-29 11:45:34 -04:00
|
|
|
./python Lib/keyword.py
|
2000-02-04 11:10:34 -04:00
|
|
|
"""
|
1997-03-20 15:45:51 -04:00
|
|
|
|
2002-10-30 01:17:22 -04:00
|
|
|
__all__ = ["iskeyword", "kwlist"]
|
2001-01-24 02:27:27 -04:00
|
|
|
|
1997-03-20 15:45:51 -04:00
|
|
|
kwlist = [
|
|
|
|
#--start keywords--
|
Merged revisions 56020-56124 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/branches/p3yk
................
r56037 | georg.brandl | 2007-06-19 05:33:20 -0700 (Tue, 19 Jun 2007) | 2 lines
Patch #1739659: don't slice dict.keys() in pydoc.
................
r56060 | martin.v.loewis | 2007-06-21 13:00:02 -0700 (Thu, 21 Jun 2007) | 2 lines
Regenerate to add True, False, None.
................
r56069 | neal.norwitz | 2007-06-21 22:31:56 -0700 (Thu, 21 Jun 2007) | 1 line
Get the doctest working again after adding None, True, and False as kewyords.
................
r56070 | neal.norwitz | 2007-06-21 23:25:33 -0700 (Thu, 21 Jun 2007) | 1 line
Add space to error message.
................
r56071 | neal.norwitz | 2007-06-21 23:40:04 -0700 (Thu, 21 Jun 2007) | 6 lines
Get pybench working, primarily
* Use print function
* Stop using string module
* Use sorted instead of assuming dict methods return lists
* Convert range result to a list
................
r56089 | collin.winter | 2007-06-26 10:31:48 -0700 (Tue, 26 Jun 2007) | 1 line
Fix AttributeError in distutils/dir_util.py.
................
r56124 | guido.van.rossum | 2007-06-29 18:04:31 -0700 (Fri, 29 Jun 2007) | 30 lines
Merged revisions 56014-56123 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk
........
r56019 | lars.gustaebel | 2007-06-18 04:42:11 -0700 (Mon, 18 Jun 2007) | 2 lines
Added exclude keyword argument to the TarFile.add() method.
........
r56023 | lars.gustaebel | 2007-06-18 13:05:55 -0700 (Mon, 18 Jun 2007) | 3 lines
Added missing \versionchanged tag for the new exclude
parameter.
........
r56038 | georg.brandl | 2007-06-19 05:36:00 -0700 (Tue, 19 Jun 2007) | 2 lines
Bug #1737864: allow empty message in logging format routines.
........
r56040 | georg.brandl | 2007-06-19 05:38:20 -0700 (Tue, 19 Jun 2007) | 2 lines
Bug #1739115: make shutil.rmtree docs clear wrt. file deletion.
........
r56084 | georg.brandl | 2007-06-25 08:21:23 -0700 (Mon, 25 Jun 2007) | 2 lines
Bug #1742901: document None behavior of shlex.split.
........
r56091 | georg.brandl | 2007-06-27 07:09:56 -0700 (Wed, 27 Jun 2007) | 2 lines
Fix a variable name in winreg docs.
........
................
2007-06-30 02:01:58 -03:00
|
|
|
'False',
|
|
|
|
'None',
|
|
|
|
'True',
|
1997-03-20 15:45:51 -04:00
|
|
|
'and',
|
2006-02-28 18:50:17 -04:00
|
|
|
'as',
|
1997-07-23 15:10:52 -03:00
|
|
|
'assert',
|
1997-03-20 15:45:51 -04:00
|
|
|
'break',
|
|
|
|
'class',
|
|
|
|
'continue',
|
|
|
|
'def',
|
|
|
|
'del',
|
|
|
|
'elif',
|
|
|
|
'else',
|
|
|
|
'except',
|
|
|
|
'finally',
|
|
|
|
'for',
|
|
|
|
'from',
|
|
|
|
'global',
|
|
|
|
'if',
|
|
|
|
'import',
|
|
|
|
'in',
|
|
|
|
'is',
|
|
|
|
'lambda',
|
2007-02-28 16:21:30 -04:00
|
|
|
'nonlocal',
|
1997-03-20 15:45:51 -04:00
|
|
|
'not',
|
|
|
|
'or',
|
|
|
|
'pass',
|
|
|
|
'raise',
|
|
|
|
'return',
|
|
|
|
'try',
|
|
|
|
'while',
|
2006-02-28 18:50:17 -04:00
|
|
|
'with',
|
2001-06-18 21:26:25 -03:00
|
|
|
'yield',
|
1997-03-20 15:45:51 -04:00
|
|
|
#--end keywords--
|
|
|
|
]
|
|
|
|
|
2003-12-02 03:48:15 -04:00
|
|
|
iskeyword = frozenset(kwlist).__contains__
|
1997-03-20 15:45:51 -04:00
|
|
|
|
|
|
|
def main():
|
2001-02-09 05:10:35 -04:00
|
|
|
import sys, re
|
1997-03-20 15:45:51 -04:00
|
|
|
|
|
|
|
args = sys.argv[1:]
|
|
|
|
iptfile = args and args[0] or "Python/graminit.c"
|
|
|
|
if len(args) > 1: optfile = args[1]
|
|
|
|
else: optfile = "Lib/keyword.py"
|
|
|
|
|
|
|
|
# scan the source file for keywords
|
2010-09-03 16:52:03 -03:00
|
|
|
with open(iptfile) as fp:
|
|
|
|
strprog = re.compile('"([^"]+)"')
|
|
|
|
lines = []
|
|
|
|
for line in fp:
|
|
|
|
if '{1, "' in line:
|
|
|
|
match = strprog.search(line)
|
|
|
|
if match:
|
|
|
|
lines.append(" '" + match.group(1) + "',\n")
|
1997-03-20 16:40:45 -04:00
|
|
|
lines.sort()
|
1997-03-20 15:45:51 -04:00
|
|
|
|
|
|
|
# load the output skeleton from the target
|
2010-09-03 16:52:03 -03:00
|
|
|
with open(optfile) as fp:
|
|
|
|
format = fp.readlines()
|
1997-03-20 15:45:51 -04:00
|
|
|
|
1997-03-20 16:40:45 -04:00
|
|
|
# insert the lines of keywords
|
1997-03-20 15:45:51 -04:00
|
|
|
try:
|
|
|
|
start = format.index("#--start keywords--\n") + 1
|
|
|
|
end = format.index("#--end keywords--\n")
|
1997-03-20 16:40:45 -04:00
|
|
|
format[start:end] = lines
|
1997-03-20 15:45:51 -04:00
|
|
|
except ValueError:
|
|
|
|
sys.stderr.write("target does not contain format markers\n")
|
1997-03-20 16:40:45 -04:00
|
|
|
sys.exit(1)
|
1997-03-20 15:45:51 -04:00
|
|
|
|
|
|
|
# write the output file
|
1997-03-20 16:40:45 -04:00
|
|
|
fp = open(optfile, 'w')
|
2001-02-09 05:10:35 -04:00
|
|
|
fp.write(''.join(format))
|
1997-03-20 15:45:51 -04:00
|
|
|
fp.close()
|
|
|
|
|
1997-10-22 18:00:49 -03:00
|
|
|
if __name__ == "__main__":
|
|
|
|
main()
|