home *** CD-ROM | disk | FTP | other *** search
/ Chip 2003 January / Chip_2003-01_cd2.bin / convert / eJayMp3Pro / mp3pro_demo.exe / KEYWORD.PYC (.txt) < prev    next >
Encoding:
Python Compiled Bytecode  |  2000-06-05  |  2.0 KB  |  83 lines

  1. # Source Generated with Decompyle++
  2. # File: in.pyc (Python 1.5)
  3.  
  4. kwlist = [
  5.     'and',
  6.     'assert',
  7.     'break',
  8.     'class',
  9.     'continue',
  10.     'def',
  11.     'del',
  12.     'elif',
  13.     'else',
  14.     'except',
  15.     'exec',
  16.     'finally',
  17.     'for',
  18.     'from',
  19.     'global',
  20.     'if',
  21.     'import',
  22.     'in',
  23.     'is',
  24.     'lambda',
  25.     'not',
  26.     'or',
  27.     'pass',
  28.     'print',
  29.     'raise',
  30.     'return',
  31.     'try',
  32.     'while']
  33. kwdict = { }
  34. for keyword in kwlist:
  35.     kwdict[keyword] = 1
  36.  
  37. iskeyword = kwdict.has_key
  38.  
  39. def main():
  40.     import sys
  41.     import re
  42.     import string
  43.     args = sys.argv[1:]
  44.     if not args and args[0]:
  45.         pass
  46.     iptfile = 'Python/graminit.c'
  47.     if len(args) > 1:
  48.         optfile = args[1]
  49.     else:
  50.         optfile = 'Lib/keyword.py'
  51.     fp = open(iptfile)
  52.     strprog = re.compile('"([^"]+)"')
  53.     lines = []
  54.     while 1:
  55.         line = fp.readline()
  56.         if not line:
  57.             break
  58.         
  59.         if string.find(line, '{1, "') > -1:
  60.             match = strprog.search(line)
  61.             if match:
  62.                 lines.append("        '" + match.group(1) + "',\n")
  63.             
  64.         
  65.     fp.close()
  66.     lines.sort()
  67.     fp = open(optfile)
  68.     format = fp.readlines()
  69.     fp.close()
  70.     
  71.     try:
  72.         start = format.index('#--start keywords--\n') + 1
  73.         end = format.index('#--end keywords--\n')
  74.         format[start:end] = lines
  75.     except ValueError:
  76.         sys.stderr.write('target does not contain format markers\n')
  77.         sys.exit(1)
  78.  
  79.     fp = open(optfile, 'w')
  80.     fp.write(string.join(format, ''))
  81.     fp.close()
  82.  
  83.