#!/usr/bin/env python

import sys

from game import Game


class Operator(object):

    def display(self):

        game.set_board('lower')

        game.grid.draw_board()

    def spawn(self):

        game.set_board('upper')
        game.grid.draw_board()

    def new_line(self):
        print

    def signal_parser(self, signal):
        
        if signal == '?s' or signal == '?n':
            signals = [signal]

        else:
            signals = [s for s in signal if s != ' ']

        for s in signals:

            commands = {'p' : self.display,
                        'q' : sys.exit, 
                        'g' : game.grid.given, 
                        'c' : game.grid.clear,
                        '?s': game.grid.show_score,
                        '?n': game.grid.show_clear_lines,
                        's' : game.grid.step,
                        't' : game.active_tet.print_tet,
                        ')' : game.active_tet.rotate_clockwise,
                        '(' : game.active_tet.rotate_counter_clockwise,
                        ';' : self.new_line,
                        'P' : self.spawn,
                        '<' : game.move_tet_west,
                        '>' : game.move_tet_east,
                        'v' : game.move_tet_south,
                        'V' : game.hard_drop}

            if s.isupper() and not (s == 'V' or s == 'P'):
                game.active_tet = game.set_active_tet(s)
            else:
                commands[s]()


    def receive_signal(self):

        a = "cT vvvv vvvv vvvv vvvv vvvv vvvv Pq"
        b = "TVpq"
        c = "T)V pq"
        d = "cL >>>> ( >> <>>>< ( > )>>< vvpq"
        e = "cT <<< Pq"
        f = "TV Zv Pq"
        g = "c O P q"
        h = "T ( >>>> > Pq"
        i = "cTvPq"
        j = "TV Z)<V pq"
        k = "J ) << V Z )(vvvvvvvvvvvvvvvvvvvPq"
        l = "I)>V I)>V I)>V I)>V T)>vvvv>>>< Pq"
        m = "T)<<<<<>>>>>>>>>><<<<<<<<V I vvvvvvvvvvvvvvvvvvvv<<<>< O>V O>>>V I)>>>>Vp s pq"
        n = "?s"
        o = "?n"
        
        while True:

            received = raw_input()

            self.signal_parser(received)
        


if __name__ == '__main__':
    game = Game()
    main = Operator()
    main.receive_signal()
@@ -1525,513 +1525,8 @@
 ):%0A%0A
-        a = %22cT vvvv vvvv vvvv vvvv vvvv vvvv Pq%22%0A        b = %22TVpq%22%0A        c = %22T)V pq%22%0A        d = %22cL %3E%3E%3E%3E ( %3E%3E %3C%3E%3E%3E%3C ( %3E )%3E%3E%3C vvpq%22%0A        e = %22cT %3C%3C%3C Pq%22%0A        f = %22TV Zv Pq%22%0A        g = %22c O P q%22%0A        h = %22T ( %3E%3E%3E%3E %3E Pq%22%0A        i = %22cTvPq%22%0A        j = %22TV Z)%3CV pq%22%0A        k = %22J ) %3C%3C V Z )(vvvvvvvvvvvvvvvvvvvPq%22%0A        l = %22I)%3EV I)%3EV I)%3EV I)%3EV T)%3Evvvv%3E%3E%3E%3C Pq%22%0A        m = %22T)%3C%3C%3C%3C%3C%3E%3E%3E%3E%3E%3E%3E%3E%3E%3E%3C%3C%3C%3C%3C%3C%3C%3CV I vvvvvvvvvvvvvvvvvvvv%3C%3C%3C%3E%3C O%3EV O%3E%3E%3EV I)%3E%3E%3E%3EVp s pq%22%0A        n = %22?s%22%0A        o = %22?n%22%0A 
     

Delete scratch tests from Operator.receive_signal()