0001 #! /usr/bin/env python 0002 0003 """Keywords (from "graminit.c") 0004 0005 This file is automatically generated; please don't muck it up! 0006 0007 To update the symbols in this file, 'cd' to the top directory of 0008 the python source tree after building the interpreter and run: 0009 0010 python Lib/keyword.py 0011 """ 0012 0013 __all__ = ["iskeyword", "kwlist"] 0014 0015 kwlist = [ 0016 #--start keywords-- 0017 'and', 0018 'assert', 0019 'break', 0020 'class', 0021 'continue', 0022 'def', 0023 'del', 0024 'elif', 0025 'else', 0026 'except', 0027 'exec', 0028 'finally', 0029 'for', 0030 'from', 0031 'global', 0032 'if', 0033 'import', 0034 'in', 0035 'is', 0036 'lambda', 0037 'not', 0038 'or', 0039 'pass', 0040 'print', 0041 'raise', 0042 'return', 0043 'try', 0044 'while', 0045 'yield', 0046 #--end keywords-- 0047 ] 0048 0049 iskeyword = frozenset(kwlist).__contains__ 0050 0051 def main(): 0052 import sys, re 0053 0054 args = sys.argv[1:] 0055 iptfile = args and args[0] or "Python/graminit.c" 0056 if len(args) > 1: optfile = args[1] 0057 else: optfile = "Lib/keyword.py" 0058 0059 # scan the source file for keywords 0060 fp = open(iptfile) 0061 strprog = re.compile('"([^"]+)"') 0062 lines = [] 0063 while 1: 0064 line = fp.readline() 0065 if not line: break 0066 if '{1, "' in line: 0067 match = strprog.search(line) 0068 if match: 0069 lines.append(" '" + match.group(1) + "',\n") 0070 fp.close() 0071 lines.sort() 0072 0073 # load the output skeleton from the target 0074 fp = open(optfile) 0075 format = fp.readlines() 0076 fp.close() 0077 0078 # insert the lines of keywords 0079 try: 0080 start = format.index("#--start keywords--\n") + 1 0081 end = format.index("#--end keywords--\n") 0082 format[start:end] = lines 0083 except ValueError: 0084 sys.stderr.write("target does not contain format markers\n") 0085 sys.exit(1) 0086 0087 # write the output file 0088 fp = open(optfile, 'w') 0089 fp.write(''.join(format)) 0090 fp.close() 0091 0092 if __name__ == "__main__": 0093 main() 0094
Generated by PyXR 0.9.4