home *** CD-ROM | disk | FTP | other *** search
/ Chip 2011 November / CHIP_2011_11.iso / Programy / Narzedzia / Calibre / calibre-0.8.18.msi / file_262 / keyword.pyo (.txt) < prev    next >
Encoding:
Python Compiled Bytecode  |  2011-09-09  |  1.7 KB  |  81 lines

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