Vega strike Python Modules doc  0.5.1
Documentation of the " Modules " folder of Vega strike
 All Data Structures Namespaces Files Functions Variables
keyword Namespace Reference

Functions

def main
 

Variables

list __all__ = ["iskeyword"]
 
list kwlist
 
dictionary kwdict = {}
 
 iskeyword = kwdict.has_key
 

Function Documentation

def keyword.main ( )

Definition at line 55 of file keyword.py.

References dospath.join(), and aifc.open().

55 
56 def main():
57  import sys, re
58 
59  args = sys.argv[1:]
60  iptfile = args and args[0] or "Python/graminit.c"
61  if len(args) > 1: optfile = args[1]
62  else: optfile = "Lib/keyword.py"
63 
64  # scan the source file for keywords
65  fp = open(iptfile)
66  strprog = re.compile('"([^"]+)"')
67  lines = []
68  while 1:
69  line = fp.readline()
70  if not line: break
71  if line.find('{1, "') > -1:
72  match = strprog.search(line)
73  if match:
74  lines.append(" '" + match.group(1) + "',\n")
75  fp.close()
76  lines.sort()
77 
78  # load the output skeleton from the target
79  fp = open(optfile)
80  format = fp.readlines()
81  fp.close()
82 
83  # insert the lines of keywords
84  try:
85  start = format.index("#--start keywords--\n") + 1
86  end = format.index("#--end keywords--\n")
87  format[start:end] = lines
88  except ValueError:
89  sys.stderr.write("target does not contain format markers\n")
90  sys.exit(1)
91 
92  # write the output file
93  fp = open(optfile, 'w')
94  fp.write(''.join(format))
95  fp.close()

Variable Documentation

list __all__ = ["iskeyword"]

Definition at line 13 of file keyword.py.

iskeyword = kwdict.has_key

Definition at line 53 of file keyword.py.

dictionary kwdict = {}

Definition at line 49 of file keyword.py.

list kwlist

Definition at line 15 of file keyword.py.