Port tools/defs_gen to Python 3.

* .gitignore: Ignore /tools/defs_gen/__pycache__/.
* tools/defs_gen/*.py: Port to Python 3. These Python sources now run with
both Python 2 and Python 3. Tested with 2.7.3 and 3.2.3.
Bug #690969.