Back to index

python3.2  3.2.2
Functions | Variables
keyword Namespace Reference

Functions

def main

Variables

list __all__ = ["iskeyword", "kwlist"]
list kwlist
tuple iskeyword = frozenset(kwlist)

Function Documentation

def keyword.main ( void  )

Definition at line 55 of file keyword.py.

00055 
00056 def main():
00057     import sys, re
00058 
00059     args = sys.argv[1:]
00060     iptfile = args and args[0] or "Python/graminit.c"
00061     if len(args) > 1: optfile = args[1]
00062     else: optfile = "Lib/keyword.py"
00063 
00064     # scan the source file for keywords
00065     with open(iptfile) as fp:
00066         strprog = re.compile('"([^"]+)"')
00067         lines = []
00068         for line in fp:
00069             if '{1, "' in line:
00070                 match = strprog.search(line)
00071                 if match:
00072                     lines.append("        '" + match.group(1) + "',\n")
00073     lines.sort()
00074 
00075     # load the output skeleton from the target
00076     with open(optfile) as fp:
00077         format = fp.readlines()
00078 
00079     # insert the lines of keywords
00080     try:
00081         start = format.index("#--start keywords--\n") + 1
00082         end = format.index("#--end keywords--\n")
00083         format[start:end] = lines
00084     except ValueError:
00085         sys.stderr.write("target does not contain format markers\n")
00086         sys.exit(1)
00087 
00088     # write the output file
00089     fp = open(optfile, 'w')
00090     fp.write(''.join(format))
00091     fp.close()

Here is the call graph for this function:


Variable Documentation

list keyword.__all__ = ["iskeyword", "kwlist"]

Definition at line 13 of file keyword.py.

tuple keyword.iskeyword = frozenset(kwlist)

Definition at line 53 of file keyword.py.

Definition at line 15 of file keyword.py.