cpython-withatomic / Lib / keyword.py

#! /usr/bin/env python

"""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:

    python Lib/keyword.py

__all__ = ["iskeyword", "kwlist"]

kwlist = [
#--start keywords--
#--end keywords--

kwdict = {}
for keyword in kwlist:
    kwdict[keyword] = 1

iskeyword = kwdict.has_key

def main():
    import sys, re

    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
    fp = open(iptfile)
    strprog = re.compile('"([^"]+)"')
    lines = []
    while 1:
        line = fp.readline()
        if not line: break
        if line.find('{1, "') > -1:
            match = strprog.search(line)
            if match:
                lines.append("        '" + match.group(1) + "',\n")

    # load the output skeleton from the target
    fp = open(optfile)
    format = fp.readlines()

    # insert the lines of keywords
        start = format.index("#--start keywords--\n") + 1
        end = format.index("#--end keywords--\n")
        format[start:end] = lines
    except ValueError:
        sys.stderr.write("target does not contain format markers\n")

    # write the output file
    fp = open(optfile, 'w')

if __name__ == "__main__":
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.