2010-03-12 06:53:45 +08:00
|
|
|
#! /usr/bin/env python3
|
2000-02-04 23:10:34 +08: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 23:45:34 +08:00
|
|
|
./python Lib/keyword.py
|
2000-02-04 23:10:34 +08:00
|
|
|
"""
|
1997-03-21 03:45:51 +08:00
|
|
|
|
2002-10-30 13:17:22 +08:00
|
|
|
__all__ = ["iskeyword", "kwlist"]
|
2001-01-24 14:27:27 +08:00
|
|
|
|
1997-03-21 03:45:51 +08: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 13:01:58 +08:00
|
|
|
'False',
|
|
|
|
'None',
|
|
|
|
'True',
|
1997-03-21 03:45:51 +08:00
|
|
|
'and',
|
2006-03-01 06:50:17 +08:00
|
|
|
'as',
|
1997-07-24 02:10:52 +08:00
|
|
|
'assert',
|
2017-10-06 11:24:46 +08:00
|
|
|
'async',
|
|
|
|
'await',
|
1997-03-21 03:45:51 +08:00
|
|
|
'break',
|
|
|
|
'class',
|
|
|
|
'continue',
|
|
|
|
'def',
|
|
|
|
'del',
|
|
|
|
'elif',
|
|
|
|
'else',
|
|
|
|
'except',
|
|
|
|
'finally',
|
|
|
|
'for',
|
|
|
|
'from',
|
|
|
|
'global',
|
|
|
|
'if',
|
|
|
|
'import',
|
|
|
|
'in',
|
|
|
|
'is',
|
|
|
|
'lambda',
|
2007-03-01 04:21:30 +08:00
|
|
|
'nonlocal',
|
1997-03-21 03:45:51 +08:00
|
|
|
'not',
|
|
|
|
'or',
|
|
|
|
'pass',
|
|
|
|
'raise',
|
|
|
|
'return',
|
|
|
|
'try',
|
|
|
|
'while',
|
2006-03-01 06:50:17 +08:00
|
|
|
'with',
|
2001-06-19 08:26:25 +08:00
|
|
|
'yield',
|
1997-03-21 03:45:51 +08:00
|
|
|
#--end keywords--
|
|
|
|
]
|
|
|
|
|
2003-12-02 15:48:15 +08:00
|
|
|
iskeyword = frozenset(kwlist).__contains__
|
1997-03-21 03:45:51 +08:00
|
|
|
|
|
|
|
def main():
|
2001-02-09 17:10:35 +08:00
|
|
|
import sys, re
|
1997-03-21 03:45:51 +08: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"
|
|
|
|
|
2013-04-26 00:01:36 +08:00
|
|
|
# load the output skeleton from the target, taking care to preserve its
|
|
|
|
# newline convention.
|
|
|
|
with open(optfile, newline='') as fp:
|
|
|
|
format = fp.readlines()
|
|
|
|
nl = format[0][len(format[0].strip()):] if format else '\n'
|
|
|
|
|
1997-03-21 03:45:51 +08:00
|
|
|
# scan the source file for keywords
|
2010-09-04 03:52:03 +08:00
|
|
|
with open(iptfile) as fp:
|
|
|
|
strprog = re.compile('"([^"]+)"')
|
|
|
|
lines = []
|
|
|
|
for line in fp:
|
|
|
|
if '{1, "' in line:
|
|
|
|
match = strprog.search(line)
|
|
|
|
if match:
|
2013-04-26 00:01:36 +08:00
|
|
|
lines.append(" '" + match.group(1) + "'," + nl)
|
1997-03-21 04:40:45 +08:00
|
|
|
lines.sort()
|
1997-03-21 03:45:51 +08:00
|
|
|
|
2013-04-26 00:01:36 +08:00
|
|
|
# insert the lines of keywords into the skeleton
|
1997-03-21 03:45:51 +08:00
|
|
|
try:
|
2013-04-26 00:01:36 +08:00
|
|
|
start = format.index("#--start keywords--" + nl) + 1
|
|
|
|
end = format.index("#--end keywords--" + nl)
|
1997-03-21 04:40:45 +08:00
|
|
|
format[start:end] = lines
|
1997-03-21 03:45:51 +08:00
|
|
|
except ValueError:
|
|
|
|
sys.stderr.write("target does not contain format markers\n")
|
1997-03-21 04:40:45 +08:00
|
|
|
sys.exit(1)
|
1997-03-21 03:45:51 +08:00
|
|
|
|
|
|
|
# write the output file
|
2013-04-26 00:01:36 +08:00
|
|
|
with open(optfile, 'w', newline='') as fp:
|
|
|
|
fp.writelines(format)
|
1997-03-21 03:45:51 +08:00
|
|
|
|
1997-10-23 05:00:49 +08:00
|
|
|
if __name__ == "__main__":
|
|
|
|
main()
|