]> git.proxmox.com Git - mirror_edk2.git/blame - AppPkg/Applications/Python/Python-2.7.10/Lib/keyword.py
AppPkg/Applications/Python/Python-2.7.10: Initial Checkin part 4/5.
[mirror_edk2.git] / AppPkg / Applications / Python / Python-2.7.10 / Lib / keyword.py
CommitLineData
3257aa99
DM
1#! /usr/bin/env python\r
2\r
3"""Keywords (from "graminit.c")\r
4\r
5This file is automatically generated; please don't muck it up!\r
6\r
7To update the symbols in this file, 'cd' to the top directory of\r
8the python source tree after building the interpreter and run:\r
9\r
10 ./python Lib/keyword.py\r
11"""\r
12\r
13__all__ = ["iskeyword", "kwlist"]\r
14\r
15kwlist = [\r
16#--start keywords--\r
17 'and',\r
18 'as',\r
19 'assert',\r
20 'break',\r
21 'class',\r
22 'continue',\r
23 'def',\r
24 'del',\r
25 'elif',\r
26 'else',\r
27 'except',\r
28 'exec',\r
29 'finally',\r
30 'for',\r
31 'from',\r
32 'global',\r
33 'if',\r
34 'import',\r
35 'in',\r
36 'is',\r
37 'lambda',\r
38 'not',\r
39 'or',\r
40 'pass',\r
41 'print',\r
42 'raise',\r
43 'return',\r
44 'try',\r
45 'while',\r
46 'with',\r
47 'yield',\r
48#--end keywords--\r
49 ]\r
50\r
51iskeyword = frozenset(kwlist).__contains__\r
52\r
53def main():\r
54 import sys, re\r
55\r
56 args = sys.argv[1:]\r
57 iptfile = args and args[0] or "Python/graminit.c"\r
58 if len(args) > 1: optfile = args[1]\r
59 else: optfile = "Lib/keyword.py"\r
60\r
61 # scan the source file for keywords\r
62 fp = open(iptfile)\r
63 strprog = re.compile('"([^"]+)"')\r
64 lines = []\r
65 for line in fp:\r
66 if '{1, "' in line:\r
67 match = strprog.search(line)\r
68 if match:\r
69 lines.append(" '" + match.group(1) + "',\n")\r
70 fp.close()\r
71 lines.sort()\r
72\r
73 # load the output skeleton from the target\r
74 fp = open(optfile)\r
75 format = fp.readlines()\r
76 fp.close()\r
77\r
78 # insert the lines of keywords\r
79 try:\r
80 start = format.index("#--start keywords--\n") + 1\r
81 end = format.index("#--end keywords--\n")\r
82 format[start:end] = lines\r
83 except ValueError:\r
84 sys.stderr.write("target does not contain format markers\n")\r
85 sys.exit(1)\r
86\r
87 # write the output file\r
88 fp = open(optfile, 'w')\r
89 fp.write(''.join(format))\r
90 fp.close()\r
91\r
92if __name__ == "__main__":\r
93 main()\r