def parseNextCommand():
 global s3gFile
 commandStr = s3gFile.read(1)
 if (len(commandStr) == 0):
  print 'EOF'
  return False
 sys.stdout.write((str(lineNumber) + ': '))
 command = struct.unpack('B', commandStr)
 (parse, disp) = commandTable[command[0]]
 if (type(parse) == type('')):
  packetLen = struct.calcsize(parse)
  packetData = s3gFile.read(packetLen)
  if (len(packetData) != packetLen):
   raise 'Packet incomplete'
  parsed = struct.unpack(parse, packetData)
 else:
  parsed = parse()
 if (type(disp) == type('')):
  print (disp % parsed)
 else:
  disp(parsed)
 return True

def parseNextCommand ( ) : global s3gFile commandStr = s3gFile . read ( 1 ) if ( len ( commandStr ) == 0 ) : print 'EOF' return False sys . stdout . write ( ( str ( lineNumber ) + ': ' ) ) command = struct . unpack ( 'B' , commandStr ) ( parse , disp ) = commandTable [ command [ 0 ] ] if ( type ( parse ) == type ( '' ) ) : packetLen = struct . calcsize ( parse ) packetData = s3gFile . read ( packetLen ) if ( len ( packetData ) != packetLen ) : raise 'Packet incomplete' parsed = struct . unpack ( parse , packetData ) else : parsed = parse ( ) if ( type ( disp ) == type ( '' ) ) : print ( disp % parsed ) else : disp ( parsed ) return True
parse and handle the next command .