Supervisor/supervisor — pull request #174 by scottkmaxwell (2012-11-27 23:34:15+00:00)
Title: Py3 support

Simple compatibility layer in supervisor.py3compat.py allows use of long, basestring, unichr, raw_input and unicode.
Compatibility layer exports PY3 variable, print_function for fixing print statements, and as_bytes/as_strings functions for converting between Py3 bytes and strings where necessary.
Provide a supervisor.medusa.text_socket to automatically translate to bytes for send and back to str on receive.
Fix most print statements by simple adding parenthesis. Use print_function where that doesn't suffice.
Some syntax changes just to my PyLint happy like using +=.
Remove virtually all use of the string library and use the built-in str instead.
Replace string.atoi with int.
Enhance the __init__ method of most classes to call the super class __init__.
Replace many map and filter usages with list comprehensions.
Replace most cases of "container.has_key(key)" with "key in container".
Use io.StringIO instead of StringIO.StringIO for Py3.
Change raise syntax to Exception(msg) instead of Exception, msg.
Change "except Exception, e" to "except Exception" with e=sys.exc_info()[1] since that works on Py2.x and Py3 and change e[0] to e.args[0] since the former is no longer supported on Py3.
Change all local import statements to be fully qualified since local imports no longer work on Py3.
Implement __bool__, __lt__ and __contains__ where necessary to support sorting and 'in' usage on Py3.
Change all doc strings to use """ instead of ".
Remove unnecessary parenthesis to make PyLint happy.
Replace all tuple params with a single param, then explode later since expanding tuples in the function definition is removed in Py3.
Use string.ascii_letters instead of string.letters on Py3.
Replace apply with using the func directly.
Fix a few bugs in error handling exposed by PyLint.
Add a few methods and members to base classes to make PyLint happy.
Wrap many uses of dict.keys(), dict.items() and dict.values() in list() since they are generators on Py3.
Replace all octal values with decimal, plus a comment about what the octal value was. This really sucks but the format of octal values changed in Py3.
Get sys.maxint from sys.maxsize on Py3.
Replace assert_ and failUnless with assertTrue, failIf with assertFalse, assertEquals with assertEqual.
Add supervisor.read_file function to open a file as text, read the contents, and close the file. This avoids ResourceWarnings when running the tests.
Change the repr tests to look for a smaller fragment of the string since the repr output for classes has changed.
Add many close statements to avoid ResourceWarnings when running tests.
Comment out several unicode tests since the u'' form disappeared from Python 3.0 through Python 3.2.x.
Replace all back ticks with repr().
Change dispatchers and loggers a use super-class __init__ instead of doing the work again.
Add upgraded meld3 directly into the project so we don't need an external dependency for it.
Use '__func__' instead of 'im_func' on Py3.
Use sys.exc_info()[0] and sys.exc_info()[1] instead of sys.exc_type and sys.exc_value since those don't exist on Py3.
Remove dependency on meld3 and limit to Py2 in setup.py.