home *** CD-ROM | disk | FTP | other *** search
/ Mac Easy 2010 May / Mac Life Ubuntu.iso / casper / filesystem.squashfs / var / lib / python-support / python2.6 / glchess / chess / fics / style12.pyc (.txt) < prev    next >
Encoding:
Python Compiled Bytecode  |  2009-04-20  |  4.4 KB  |  142 lines

  1. # Source Generated with Decompyle++
  2. # File: in.pyc (Python 2.6)
  3.  
  4. import re
  5. COLOUR_BLACK = 'B'
  6. COLOUR_WHITE = 'W'
  7. RELATIONSHIP_PLAYING_OPPONENT_MOVE = '-1'
  8. RELATIONSHIP_PLAYING_MY_MOVE = '1'
  9. RELATIONSHIP_OBSERVER_EXAMINED = '-2'
  10. RELATIONSHIP_OBSERVER = '0'
  11. RELATIONSHIP_EXAMINER = '2'
  12. movePattern = re.compile('<12> ' + '([prnbqkPRNBQK-]{8}) ' + '([prnbqkPRNBQK-]{8}) ' + '([prnbqkPRNBQK-]{8}) ' + '([prnbqkPRNBQK-]{8}) ' + '([prnbqkPRNBQK-]{8}) ' + '([prnbqkPRNBQK-]{8}) ' + '([prnbqkPRNBQK-]{8}) ' + '([prnbqkPRNBQK-]{8}) ' + '([BW]{1}) ' + '([-]?\\d+) ' + '([01]{1}) ' + '([01]{1}) ' + '([01]{1}) ' + '([01]{1}) ' + '(\\d+) ' + '(\\d+) ' + '(.+) ' + '(.+) ' + '([-]?\\d+) ' + '(\\d+) ' + '(\\d+) ' + '(\\d+) ' + '(\\d+) ' + '(\\d+) ' + '(\\d+) ' + '(\\d+) ' + '(.+) ' + '[(](\\d+)[:](\\d+)[)] ' + '(.+) ' + '([01]{1})' + '([01]{1})' + '([01]{1})')
  13.  
  14. def _decodeFile(string):
  15.     return string
  16.  
  17.  
  18. def _decodeColour(string):
  19.     if string == 'B' or string == 'W':
  20.         return string
  21.     raise ValueError()
  22.  
  23.  
  24. def _decodeInteger(string):
  25.     return int(string)
  26.  
  27.  
  28. def _decodeUInteger(string):
  29.     i = int(string)
  30.     if i < 0:
  31.         raise ValueError()
  32.     i < 0
  33.     return i
  34.  
  35.  
  36. def _decodeTime(string):
  37.     return 0
  38.  
  39.  
  40. def _decodeString(string):
  41.     return string
  42.  
  43.  
  44. def _decodeBoolean(string):
  45.     if string == '0':
  46.         return False
  47.     if string == '1':
  48.         return True
  49.     raise ValueError()
  50.  
  51. fields = [
  52.     _decodeFile,
  53.     _decodeFile,
  54.     _decodeFile,
  55.     _decodeFile,
  56.     _decodeFile,
  57.     _decodeFile,
  58.     _decodeFile,
  59.     _decodeFile,
  60.     _decodeColour,
  61.     _decodeInteger,
  62.     _decodeBoolean,
  63.     _decodeBoolean,
  64.     _decodeBoolean,
  65.     _decodeBoolean,
  66.     _decodeUInteger,
  67.     _decodeUInteger,
  68.     _decodeString,
  69.     _decodeString,
  70.     _decodeInteger,
  71.     _decodeUInteger,
  72.     _decodeUInteger,
  73.     _decodeUInteger,
  74.     _decodeUInteger,
  75.     _decodeUInteger,
  76.     _decodeUInteger,
  77.     _decodeUInteger,
  78.     _decodeString,
  79.     _decodeTime,
  80.     _decodeString,
  81.     _decodeBoolean]
  82.  
  83. class Player:
  84.     '''
  85.     '''
  86.     name = ''
  87.     canCastleShort = False
  88.     canCastleLong = False
  89.     strength = 0
  90.     remaining = 0
  91.  
  92.  
  93. class Move:
  94.     '''
  95.     '''
  96.     board = None
  97.     relationship = None
  98.     gameNumber = 0
  99.     startTime = 0
  100.     increment = 0
  101.     nReversibleMoves = 0
  102.     white = None
  103.     black = None
  104.     move = ''
  105.     movePretty = ''
  106.     marchFile = -1
  107.     moveTime = 0
  108.     moveNumber = 0
  109.     colourToMove = None
  110.     flip = None
  111.     
  112.     def __init__(self):
  113.         self.white = Player()
  114.         self.black = Player()
  115.  
  116.  
  117.  
  118. def decode(line):
  119.     '''
  120.     '''
  121.     tokens = line.split()[1:]
  122.     if len(tokens) < len(fields):
  123.         raise ValueError('Too few fields')
  124.     len(tokens) < len(fields)
  125.     out = []
  126.     for i in xrange(len(fields)):
  127.         
  128.         try:
  129.             out.append(fields[i](tokens[i]))
  130.         continue
  131.         except ValueError:
  132.             raise ValueError('Invalid field: %s' % tokens[i])
  133.             continue
  134.         
  135.  
  136.     
  137.     m = Move()
  138.     (file1, file2, file3, file4, file5, file6, file7, file8, moveColour, pushFile, whiteCastleShort, whiteCastleLong, blackCastleShort, blackCastleLong, nIrreversableMoves, m.gameNumber, m.white.name, m.black.name, m.relationship, initialTime, incrementTime, m.white.strength, m.black.strength, m.white.remaining, m.black.remaining, m.moveNumber, m.move, m.moveTime, m.movePretty, orientation) = out
  139.     m.board = (file1, file2, file3, file4, file5, file6, file7, file8)
  140.     return m
  141.  
  142.