THRIFT-1480. py: remove tabs, adjust whitespace and address PEP8 warnings

This patch addresses a host of PEP8 lint problems.

Patch: Will Pierce

git-svn-id: https://svn.apache.org/repos/asf/thrift/trunk@1226890 13f79535-47bb-0310-9956-ffa450edef68
diff --git a/lib/py/src/protocol/TCompactProtocol.py b/lib/py/src/protocol/TCompactProtocol.py
index 016a331..cdec607 100644
--- a/lib/py/src/protocol/TCompactProtocol.py
+++ b/lib/py/src/protocol/TCompactProtocol.py
@@ -32,6 +32,7 @@
 VALUE_READ = 7
 BOOL_READ = 8
 
+
 def make_helper(v_from, container):
   def helper(func):
     def nested(self, *args, **kwargs):
@@ -42,12 +43,15 @@
 writer = make_helper(VALUE_WRITE, CONTAINER_WRITE)
 reader = make_helper(VALUE_READ, CONTAINER_READ)
 
+
 def makeZigZag(n, bits):
   return (n << 1) ^ (n >> (bits - 1))
 
+
 def fromZigZag(n):
   return (n >> 1) ^ -(n & 1)
 
+
 def writeVarint(trans, n):
   out = []
   while True:
@@ -59,6 +63,7 @@
       n = n >> 7
   trans.write(''.join(map(chr, out)))
 
+
 def readVarint(trans):
   result = 0
   shift = 0
@@ -70,6 +75,7 @@
       return result
     shift += 7
 
+
 class CompactType:
   STOP = 0x00
   TRUE = 0x01
@@ -86,7 +92,7 @@
   STRUCT = 0x0C
 
 CTYPES = {TType.STOP: CompactType.STOP,
-          TType.BOOL: CompactType.TRUE, # used for collection
+          TType.BOOL: CompactType.TRUE,  # used for collection
           TType.BYTE: CompactType.BYTE,
           TType.I16: CompactType.I16,
           TType.I32: CompactType.I32,
@@ -106,8 +112,9 @@
 del k
 del v
 
+
 class TCompactProtocol(TProtocolBase):
-  "Compact implementation of the Thrift protocol driver."
+  """Compact implementation of the Thrift protocol driver."""
 
   PROTOCOL_ID = 0x82
   VERSION = 1
@@ -217,18 +224,18 @@
 
   def writeBool(self, bool):
     if self.state == BOOL_WRITE:
-        if bool:
-            ctype = CompactType.TRUE
-        else:
-            ctype = CompactType.FALSE
-        self.__writeFieldHeader(ctype, self.__bool_fid)
+      if bool:
+        ctype = CompactType.TRUE
+      else:
+        ctype = CompactType.FALSE
+      self.__writeFieldHeader(ctype, self.__bool_fid)
     elif self.state == CONTAINER_WRITE:
-       if bool:
-           self.__writeByte(CompactType.TRUE)
-       else:
-           self.__writeByte(CompactType.FALSE)
+      if bool:
+        self.__writeByte(CompactType.TRUE)
+      else:
+        self.__writeByte(CompactType.FALSE)
     else:
-      raise AssertionError, "Invalid state in compact protocol"
+      raise AssertionError("Invalid state in compact protocol")
 
   writeByte = writer(__writeByte)
   writeI16 = writer(__writeI16)
@@ -364,7 +371,8 @@
     elif self.state == CONTAINER_READ:
       return self.__readByte() == CompactType.TRUE
     else:
-      raise AssertionError, "Invalid state in compact protocol: %d" % self.state
+      raise AssertionError("Invalid state in compact protocol: %d" %
+                           self.state)
 
   readByte = reader(__readByte)
   __readI16 = __readZigZag