home *** CD-ROM | disk | FTP | other *** search
/ PC Extra 07 & 08 / pca1507.iso / Software / psp8 / Data1.cab / keyword.pyc (.txt) < prev    next >
Encoding:
Python Compiled Bytecode  |  2003-04-22  |  2.4 KB  |  97 lines

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