Moving executable code under '__main__'.

It is a common idiom for keeping executable part of code from
executing if this file is imported as a module somewhere.
Context managers for terminal setup/restore.

A context manager is a common idiom to define blocks with
guaranteed resource release. They can be defined as classes but
there's a nicer syntax using contextlib.contextmanager that lets
you define a function with a single `yield` in the middle, so you
can acquire resources before that and release them after.

Also after extracting those it seems that the thing with termios
attrs is not needed as you don't set anything before doing the work,
so there's probably nothing to restore. But I'm not the judge here.
Moving run() out of TetrisInputProcessor.

This is going to be the main theme of the refactoring. Since it's
not Java, there's no need to define everything as classes. It makes
Python code less readable with all those millions of `self.` and it
encourages usage of class attributes instead of simple local vars.
A rule of thumb is: if you're creating an single instance of a class
that lives through the whole program lifetime it shouldn't be a
class. Same goes for classes with a single public method.

Here's what's changed here:

- run() has been moved out of the class and lost its `self`
- instead run() creates an instance of the TetrisInputProcessor,
  which in turn will probably go away in the future as having a
  whole class to hold a single var looks like an overkill.
Simpler TetrisController.move and piece position.

Instead of doing "move - check position - unmove - move again if
ok" it's easier to teach a TetrisPiece to return its cells at the
new position, check that and then move if ok.

Also, replacing separate x, y, z attributes with a tuple reduces a
few lines of code.
TetrisPlayField.position_ok should only take cells.
Useful TetrisPiece constructor.

Unlike C++, Python has no problem with having useful object
constructors that do whatever initialization needed. So calling a
trivial constructor and setting up attributes one by one after that
is an anti-pattern.

Also, there's no point in having setters and getters for plain
data fields.
Removed set_visible.
Destructuring cells in position_ok
Using "all" in position_ok.

- Conditions are reverted to use shorter 0 <= x < PLAYFIELD_H syntax
- "all" is used to check conditions for all cells of a piece.
Store piece configuration directly.

- The set of available configurations is moved up to the class
  level, as it is constant across instances
- The instance keeps the configuration directly in self.data
  instead of getting it indirectly with an index.
- Also, `random.choice` is simpler than messing with indices.
Merge pull request #2 from isagalaev/master

Python refactoring