diff --git a/lib/py/src/protocol/TBase.py b/lib/py/src/protocol/TBase.py
index d106f4e..87caf0d 100644
--- a/lib/py/src/protocol/TBase.py
+++ b/lib/py/src/protocol/TBase.py
@@ -21,78 +21,79 @@
 from thrift.transport import TTransport
 
 try:
-  from thrift.protocol import fastbinary
+    from thrift.protocol import fastbinary
 except:
-  fastbinary = None
+    fastbinary = None
 
 
 class TBase(object):
-  __slots__ = ()
+    __slots__ = ()
 
-  def __repr__(self):
-    L = ['%s=%r' % (key, getattr(self, key)) for key in self.__slots__]
-    return '%s(%s)' % (self.__class__.__name__, ', '.join(L))
+    def __repr__(self):
+        L = ['%s=%r' % (key, getattr(self, key)) for key in self.__slots__]
+        return '%s(%s)' % (self.__class__.__name__, ', '.join(L))
 
-  def __eq__(self, other):
-    if not isinstance(other, self.__class__):
-      return False
-    for attr in self.__slots__:
-      my_val = getattr(self, attr)
-      other_val = getattr(other, attr)
-      if my_val != other_val:
-        return False
-    return True
+    def __eq__(self, other):
+        if not isinstance(other, self.__class__):
+            return False
+        for attr in self.__slots__:
+            my_val = getattr(self, attr)
+            other_val = getattr(other, attr)
+            if my_val != other_val:
+                return False
+        return True
 
-  def __ne__(self, other):
-    return not (self == other)
+    def __ne__(self, other):
+        return not (self == other)
 
-  def read(self, iprot):
-    if (iprot.__class__ == TBinaryProtocol.TBinaryProtocolAccelerated and
-       isinstance(iprot.trans, TTransport.CReadableTransport) and
-       self.thrift_spec is not None and
-       fastbinary is not None):
-      fastbinary.decode_binary(self,
-                               iprot.trans,
-                               (self.__class__, self.thrift_spec),
-                               iprot.string_length_limit,
-                               iprot.container_length_limit)
-      return
-    iprot.readStruct(self, self.thrift_spec)
+    def read(self, iprot):
+        if (iprot.__class__ == TBinaryProtocol.TBinaryProtocolAccelerated and
+                isinstance(iprot.trans, TTransport.CReadableTransport) and
+                self.thrift_spec is not None and
+                fastbinary is not None):
+            fastbinary.decode_binary(self,
+                                     iprot.trans,
+                                     (self.__class__, self.thrift_spec),
+                                     iprot.string_length_limit,
+                                     iprot.container_length_limit)
+            return
+        iprot.readStruct(self, self.thrift_spec)
 
-  def write(self, oprot):
-    if (oprot.__class__ == TBinaryProtocol.TBinaryProtocolAccelerated and
-       self.thrift_spec is not None and
-       fastbinary is not None):
-      oprot.trans.write(
-        fastbinary.encode_binary(self, (self.__class__, self.thrift_spec)))
-      return
-    oprot.writeStruct(self, self.thrift_spec)
+    def write(self, oprot):
+        if (oprot.__class__ == TBinaryProtocol.TBinaryProtocolAccelerated and
+                self.thrift_spec is not None and
+                fastbinary is not None):
+            oprot.trans.write(
+                fastbinary.encode_binary(
+                    self, (self.__class__, self.thrift_spec)))
+            return
+        oprot.writeStruct(self, self.thrift_spec)
 
 
 class TExceptionBase(TBase, Exception):
-  pass
+    pass
 
 
 class TFrozenBase(TBase):
-  def __setitem__(self, *args):
-    raise TypeError("Can't modify frozen struct")
+    def __setitem__(self, *args):
+        raise TypeError("Can't modify frozen struct")
 
-  def __delitem__(self, *args):
-    raise TypeError("Can't modify frozen struct")
+    def __delitem__(self, *args):
+        raise TypeError("Can't modify frozen struct")
 
-  def __hash__(self, *args):
-    return hash(self.__class__) ^ hash(self.__slots__)
+    def __hash__(self, *args):
+        return hash(self.__class__) ^ hash(self.__slots__)
 
-  @classmethod
-  def read(cls, iprot):
-    if (iprot.__class__ == TBinaryProtocol.TBinaryProtocolAccelerated and
-       isinstance(iprot.trans, TTransport.CReadableTransport) and
-       cls.thrift_spec is not None and
-       fastbinary is not None):
-      self = cls()
-      return fastbinary.decode_binary(None,
-                                      iprot.trans,
-                                      (self.__class__, self.thrift_spec),
-                                      iprot.string_length_limit,
-                                      iprot.container_length_limit)
-    return iprot.readStruct(cls, cls.thrift_spec, True)
+    @classmethod
+    def read(cls, iprot):
+        if (iprot.__class__ == TBinaryProtocol.TBinaryProtocolAccelerated and
+                isinstance(iprot.trans, TTransport.CReadableTransport) and
+                cls.thrift_spec is not None and
+                fastbinary is not None):
+            self = cls()
+            return fastbinary.decode_binary(None,
+                                            iprot.trans,
+                                            (self.__class__, self.thrift_spec),
+                                            iprot.string_length_limit,
+                                            iprot.container_length_limit)
+        return iprot.readStruct(cls, cls.thrift_spec, True)
diff --git a/lib/py/src/protocol/TBinaryProtocol.py b/lib/py/src/protocol/TBinaryProtocol.py
index db4ea31..7fce12f 100644
--- a/lib/py/src/protocol/TBinaryProtocol.py
+++ b/lib/py/src/protocol/TBinaryProtocol.py
@@ -22,264 +22,264 @@
 
 
 class TBinaryProtocol(TProtocolBase):
-  """Binary implementation of the Thrift protocol driver."""
+    """Binary implementation of the Thrift protocol driver."""
 
-  # NastyHaxx. Python 2.4+ on 32-bit machines forces hex constants to be
-  # positive, converting this into a long. If we hardcode the int value
-  # instead it'll stay in 32 bit-land.
+    # NastyHaxx. Python 2.4+ on 32-bit machines forces hex constants to be
+    # positive, converting this into a long. If we hardcode the int value
+    # instead it'll stay in 32 bit-land.
 
-  # VERSION_MASK = 0xffff0000
-  VERSION_MASK = -65536
+    # VERSION_MASK = 0xffff0000
+    VERSION_MASK = -65536
 
-  # VERSION_1 = 0x80010000
-  VERSION_1 = -2147418112
+    # VERSION_1 = 0x80010000
+    VERSION_1 = -2147418112
 
-  TYPE_MASK = 0x000000ff
+    TYPE_MASK = 0x000000ff
 
-  def __init__(self, trans, strictRead=False, strictWrite=True, **kwargs):
-    TProtocolBase.__init__(self, trans)
-    self.strictRead = strictRead
-    self.strictWrite = strictWrite
-    self.string_length_limit = kwargs.get('string_length_limit', None)
-    self.container_length_limit = kwargs.get('container_length_limit', None)
+    def __init__(self, trans, strictRead=False, strictWrite=True, **kwargs):
+        TProtocolBase.__init__(self, trans)
+        self.strictRead = strictRead
+        self.strictWrite = strictWrite
+        self.string_length_limit = kwargs.get('string_length_limit', None)
+        self.container_length_limit = kwargs.get('container_length_limit', None)
 
-  def _check_string_length(self, length):
-    self._check_length(self.string_length_limit, length)
+    def _check_string_length(self, length):
+        self._check_length(self.string_length_limit, length)
 
-  def _check_container_length(self, length):
-    self._check_length(self.container_length_limit, length)
+    def _check_container_length(self, length):
+        self._check_length(self.container_length_limit, length)
 
-  def writeMessageBegin(self, name, type, seqid):
-    if self.strictWrite:
-      self.writeI32(TBinaryProtocol.VERSION_1 | type)
-      self.writeString(name)
-      self.writeI32(seqid)
-    else:
-      self.writeString(name)
-      self.writeByte(type)
-      self.writeI32(seqid)
+    def writeMessageBegin(self, name, type, seqid):
+        if self.strictWrite:
+            self.writeI32(TBinaryProtocol.VERSION_1 | type)
+            self.writeString(name)
+            self.writeI32(seqid)
+        else:
+            self.writeString(name)
+            self.writeByte(type)
+            self.writeI32(seqid)
 
-  def writeMessageEnd(self):
-    pass
+    def writeMessageEnd(self):
+        pass
 
-  def writeStructBegin(self, name):
-    pass
+    def writeStructBegin(self, name):
+        pass
 
-  def writeStructEnd(self):
-    pass
+    def writeStructEnd(self):
+        pass
 
-  def writeFieldBegin(self, name, type, id):
-    self.writeByte(type)
-    self.writeI16(id)
+    def writeFieldBegin(self, name, type, id):
+        self.writeByte(type)
+        self.writeI16(id)
 
-  def writeFieldEnd(self):
-    pass
+    def writeFieldEnd(self):
+        pass
 
-  def writeFieldStop(self):
-    self.writeByte(TType.STOP)
+    def writeFieldStop(self):
+        self.writeByte(TType.STOP)
 
-  def writeMapBegin(self, ktype, vtype, size):
-    self.writeByte(ktype)
-    self.writeByte(vtype)
-    self.writeI32(size)
+    def writeMapBegin(self, ktype, vtype, size):
+        self.writeByte(ktype)
+        self.writeByte(vtype)
+        self.writeI32(size)
 
-  def writeMapEnd(self):
-    pass
+    def writeMapEnd(self):
+        pass
 
-  def writeListBegin(self, etype, size):
-    self.writeByte(etype)
-    self.writeI32(size)
+    def writeListBegin(self, etype, size):
+        self.writeByte(etype)
+        self.writeI32(size)
 
-  def writeListEnd(self):
-    pass
+    def writeListEnd(self):
+        pass
 
-  def writeSetBegin(self, etype, size):
-    self.writeByte(etype)
-    self.writeI32(size)
+    def writeSetBegin(self, etype, size):
+        self.writeByte(etype)
+        self.writeI32(size)
 
-  def writeSetEnd(self):
-    pass
+    def writeSetEnd(self):
+        pass
 
-  def writeBool(self, bool):
-    if bool:
-      self.writeByte(1)
-    else:
-      self.writeByte(0)
+    def writeBool(self, bool):
+        if bool:
+            self.writeByte(1)
+        else:
+            self.writeByte(0)
 
-  def writeByte(self, byte):
-    buff = pack("!b", byte)
-    self.trans.write(buff)
+    def writeByte(self, byte):
+        buff = pack("!b", byte)
+        self.trans.write(buff)
 
-  def writeI16(self, i16):
-    buff = pack("!h", i16)
-    self.trans.write(buff)
+    def writeI16(self, i16):
+        buff = pack("!h", i16)
+        self.trans.write(buff)
 
-  def writeI32(self, i32):
-    buff = pack("!i", i32)
-    self.trans.write(buff)
+    def writeI32(self, i32):
+        buff = pack("!i", i32)
+        self.trans.write(buff)
 
-  def writeI64(self, i64):
-    buff = pack("!q", i64)
-    self.trans.write(buff)
+    def writeI64(self, i64):
+        buff = pack("!q", i64)
+        self.trans.write(buff)
 
-  def writeDouble(self, dub):
-    buff = pack("!d", dub)
-    self.trans.write(buff)
+    def writeDouble(self, dub):
+        buff = pack("!d", dub)
+        self.trans.write(buff)
 
-  def writeBinary(self, str):
-    self.writeI32(len(str))
-    self.trans.write(str)
+    def writeBinary(self, str):
+        self.writeI32(len(str))
+        self.trans.write(str)
 
-  def readMessageBegin(self):
-    sz = self.readI32()
-    if sz < 0:
-      version = sz & TBinaryProtocol.VERSION_MASK
-      if version != TBinaryProtocol.VERSION_1:
-        raise TProtocolException(
-          type=TProtocolException.BAD_VERSION,
-          message='Bad version in readMessageBegin: %d' % (sz))
-      type = sz & TBinaryProtocol.TYPE_MASK
-      name = self.readString()
-      seqid = self.readI32()
-    else:
-      if self.strictRead:
-        raise TProtocolException(type=TProtocolException.BAD_VERSION,
-                                 message='No protocol version header')
-      name = self.trans.readAll(sz)
-      type = self.readByte()
-      seqid = self.readI32()
-    return (name, type, seqid)
+    def readMessageBegin(self):
+        sz = self.readI32()
+        if sz < 0:
+            version = sz & TBinaryProtocol.VERSION_MASK
+            if version != TBinaryProtocol.VERSION_1:
+                raise TProtocolException(
+                    type=TProtocolException.BAD_VERSION,
+                    message='Bad version in readMessageBegin: %d' % (sz))
+            type = sz & TBinaryProtocol.TYPE_MASK
+            name = self.readString()
+            seqid = self.readI32()
+        else:
+            if self.strictRead:
+                raise TProtocolException(type=TProtocolException.BAD_VERSION,
+                                         message='No protocol version header')
+            name = self.trans.readAll(sz)
+            type = self.readByte()
+            seqid = self.readI32()
+        return (name, type, seqid)
 
-  def readMessageEnd(self):
-    pass
+    def readMessageEnd(self):
+        pass
 
-  def readStructBegin(self):
-    pass
+    def readStructBegin(self):
+        pass
 
-  def readStructEnd(self):
-    pass
+    def readStructEnd(self):
+        pass
 
-  def readFieldBegin(self):
-    type = self.readByte()
-    if type == TType.STOP:
-      return (None, type, 0)
-    id = self.readI16()
-    return (None, type, id)
+    def readFieldBegin(self):
+        type = self.readByte()
+        if type == TType.STOP:
+            return (None, type, 0)
+        id = self.readI16()
+        return (None, type, id)
 
-  def readFieldEnd(self):
-    pass
+    def readFieldEnd(self):
+        pass
 
-  def readMapBegin(self):
-    ktype = self.readByte()
-    vtype = self.readByte()
-    size = self.readI32()
-    self._check_container_length(size)
-    return (ktype, vtype, size)
+    def readMapBegin(self):
+        ktype = self.readByte()
+        vtype = self.readByte()
+        size = self.readI32()
+        self._check_container_length(size)
+        return (ktype, vtype, size)
 
-  def readMapEnd(self):
-    pass
+    def readMapEnd(self):
+        pass
 
-  def readListBegin(self):
-    etype = self.readByte()
-    size = self.readI32()
-    self._check_container_length(size)
-    return (etype, size)
+    def readListBegin(self):
+        etype = self.readByte()
+        size = self.readI32()
+        self._check_container_length(size)
+        return (etype, size)
 
-  def readListEnd(self):
-    pass
+    def readListEnd(self):
+        pass
 
-  def readSetBegin(self):
-    etype = self.readByte()
-    size = self.readI32()
-    self._check_container_length(size)
-    return (etype, size)
+    def readSetBegin(self):
+        etype = self.readByte()
+        size = self.readI32()
+        self._check_container_length(size)
+        return (etype, size)
 
-  def readSetEnd(self):
-    pass
+    def readSetEnd(self):
+        pass
 
-  def readBool(self):
-    byte = self.readByte()
-    if byte == 0:
-      return False
-    return True
+    def readBool(self):
+        byte = self.readByte()
+        if byte == 0:
+            return False
+        return True
 
-  def readByte(self):
-    buff = self.trans.readAll(1)
-    val, = unpack('!b', buff)
-    return val
+    def readByte(self):
+        buff = self.trans.readAll(1)
+        val, = unpack('!b', buff)
+        return val
 
-  def readI16(self):
-    buff = self.trans.readAll(2)
-    val, = unpack('!h', buff)
-    return val
+    def readI16(self):
+        buff = self.trans.readAll(2)
+        val, = unpack('!h', buff)
+        return val
 
-  def readI32(self):
-    buff = self.trans.readAll(4)
-    val, = unpack('!i', buff)
-    return val
+    def readI32(self):
+        buff = self.trans.readAll(4)
+        val, = unpack('!i', buff)
+        return val
 
-  def readI64(self):
-    buff = self.trans.readAll(8)
-    val, = unpack('!q', buff)
-    return val
+    def readI64(self):
+        buff = self.trans.readAll(8)
+        val, = unpack('!q', buff)
+        return val
 
-  def readDouble(self):
-    buff = self.trans.readAll(8)
-    val, = unpack('!d', buff)
-    return val
+    def readDouble(self):
+        buff = self.trans.readAll(8)
+        val, = unpack('!d', buff)
+        return val
 
-  def readBinary(self):
-    size = self.readI32()
-    self._check_string_length(size)
-    s = self.trans.readAll(size)
-    return s
+    def readBinary(self):
+        size = self.readI32()
+        self._check_string_length(size)
+        s = self.trans.readAll(size)
+        return s
 
 
 class TBinaryProtocolFactory(object):
-  def __init__(self, strictRead=False, strictWrite=True, **kwargs):
-    self.strictRead = strictRead
-    self.strictWrite = strictWrite
-    self.string_length_limit = kwargs.get('string_length_limit', None)
-    self.container_length_limit = kwargs.get('container_length_limit', None)
+    def __init__(self, strictRead=False, strictWrite=True, **kwargs):
+        self.strictRead = strictRead
+        self.strictWrite = strictWrite
+        self.string_length_limit = kwargs.get('string_length_limit', None)
+        self.container_length_limit = kwargs.get('container_length_limit', None)
 
-  def getProtocol(self, trans):
-    prot = TBinaryProtocol(trans, self.strictRead, self.strictWrite,
-                           string_length_limit=self.string_length_limit,
-                           container_length_limit=self.container_length_limit)
-    return prot
+    def getProtocol(self, trans):
+        prot = TBinaryProtocol(trans, self.strictRead, self.strictWrite,
+                               string_length_limit=self.string_length_limit,
+                               container_length_limit=self.container_length_limit)
+        return prot
 
 
 class TBinaryProtocolAccelerated(TBinaryProtocol):
-  """C-Accelerated version of TBinaryProtocol.
+    """C-Accelerated version of TBinaryProtocol.
 
-  This class does not override any of TBinaryProtocol's methods,
-  but the generated code recognizes it directly and will call into
-  our C module to do the encoding, bypassing this object entirely.
-  We inherit from TBinaryProtocol so that the normal TBinaryProtocol
-  encoding can happen if the fastbinary module doesn't work for some
-  reason.  (TODO(dreiss): Make this happen sanely in more cases.)
+    This class does not override any of TBinaryProtocol's methods,
+    but the generated code recognizes it directly and will call into
+    our C module to do the encoding, bypassing this object entirely.
+    We inherit from TBinaryProtocol so that the normal TBinaryProtocol
+    encoding can happen if the fastbinary module doesn't work for some
+    reason.  (TODO(dreiss): Make this happen sanely in more cases.)
 
-  In order to take advantage of the C module, just use
-  TBinaryProtocolAccelerated instead of TBinaryProtocol.
+    In order to take advantage of the C module, just use
+    TBinaryProtocolAccelerated instead of TBinaryProtocol.
 
-  NOTE:  This code was contributed by an external developer.
-         The internal Thrift team has reviewed and tested it,
-         but we cannot guarantee that it is production-ready.
-         Please feel free to report bugs and/or success stories
-         to the public mailing list.
-  """
-  pass
+    NOTE:  This code was contributed by an external developer.
+           The internal Thrift team has reviewed and tested it,
+           but we cannot guarantee that it is production-ready.
+           Please feel free to report bugs and/or success stories
+           to the public mailing list.
+    """
+    pass
 
 
 class TBinaryProtocolAcceleratedFactory(object):
-  def __init__(self,
-               string_length_limit=None,
-               container_length_limit=None):
-    self.string_length_limit = string_length_limit
-    self.container_length_limit = container_length_limit
+    def __init__(self,
+                 string_length_limit=None,
+                 container_length_limit=None):
+        self.string_length_limit = string_length_limit
+        self.container_length_limit = container_length_limit
 
-  def getProtocol(self, trans):
-    return TBinaryProtocolAccelerated(
-        trans,
-        string_length_limit=self.string_length_limit,
-        container_length_limit=self.container_length_limit)
+    def getProtocol(self, trans):
+        return TBinaryProtocolAccelerated(
+            trans,
+            string_length_limit=self.string_length_limit,
+            container_length_limit=self.container_length_limit)
diff --git a/lib/py/src/protocol/TCompactProtocol.py b/lib/py/src/protocol/TCompactProtocol.py
index 3d9c0e6..8d3db1a 100644
--- a/lib/py/src/protocol/TCompactProtocol.py
+++ b/lib/py/src/protocol/TCompactProtocol.py
@@ -36,390 +36,391 @@
 
 
 def make_helper(v_from, container):
-  def helper(func):
-    def nested(self, *args, **kwargs):
-      assert self.state in (v_from, container), (self.state, v_from, container)
-      return func(self, *args, **kwargs)
-    return nested
-  return helper
+    def helper(func):
+        def nested(self, *args, **kwargs):
+            assert self.state in (v_from, container), (self.state, v_from, container)
+            return func(self, *args, **kwargs)
+        return nested
+    return helper
 writer = make_helper(VALUE_WRITE, CONTAINER_WRITE)
 reader = make_helper(VALUE_READ, CONTAINER_READ)
 
 
 def makeZigZag(n, bits):
-  checkIntegerLimits(n, bits)
-  return (n << 1) ^ (n >> (bits - 1))
+    checkIntegerLimits(n, bits)
+    return (n << 1) ^ (n >> (bits - 1))
 
 
 def fromZigZag(n):
-  return (n >> 1) ^ -(n & 1)
+    return (n >> 1) ^ -(n & 1)
 
 
 def writeVarint(trans, n):
-  out = bytearray()
-  while True:
-    if n & ~0x7f == 0:
-      out.append(n)
-      break
-    else:
-      out.append((n & 0xff) | 0x80)
-      n = n >> 7
-  trans.write(bytes(out))
+    out = bytearray()
+    while True:
+        if n & ~0x7f == 0:
+            out.append(n)
+            break
+        else:
+            out.append((n & 0xff) | 0x80)
+            n = n >> 7
+    trans.write(bytes(out))
 
 
 def readVarint(trans):
-  result = 0
-  shift = 0
-  while True:
-    x = trans.readAll(1)
-    byte = ord(x)
-    result |= (byte & 0x7f) << shift
-    if byte >> 7 == 0:
-      return result
-    shift += 7
+    result = 0
+    shift = 0
+    while True:
+        x = trans.readAll(1)
+        byte = ord(x)
+        result |= (byte & 0x7f) << shift
+        if byte >> 7 == 0:
+            return result
+        shift += 7
 
 
 class CompactType(object):
-  STOP = 0x00
-  TRUE = 0x01
-  FALSE = 0x02
-  BYTE = 0x03
-  I16 = 0x04
-  I32 = 0x05
-  I64 = 0x06
-  DOUBLE = 0x07
-  BINARY = 0x08
-  LIST = 0x09
-  SET = 0x0A
-  MAP = 0x0B
-  STRUCT = 0x0C
+    STOP = 0x00
+    TRUE = 0x01
+    FALSE = 0x02
+    BYTE = 0x03
+    I16 = 0x04
+    I32 = 0x05
+    I64 = 0x06
+    DOUBLE = 0x07
+    BINARY = 0x08
+    LIST = 0x09
+    SET = 0x0A
+    MAP = 0x0B
+    STRUCT = 0x0C
 
-CTYPES = {TType.STOP: CompactType.STOP,
-          TType.BOOL: CompactType.TRUE,  # used for collection
-          TType.BYTE: CompactType.BYTE,
-          TType.I16: CompactType.I16,
-          TType.I32: CompactType.I32,
-          TType.I64: CompactType.I64,
-          TType.DOUBLE: CompactType.DOUBLE,
-          TType.STRING: CompactType.BINARY,
-          TType.STRUCT: CompactType.STRUCT,
-          TType.LIST: CompactType.LIST,
-          TType.SET: CompactType.SET,
-          TType.MAP: CompactType.MAP
-          }
+CTYPES = {
+    TType.STOP: CompactType.STOP,
+    TType.BOOL: CompactType.TRUE,  # used for collection
+    TType.BYTE: CompactType.BYTE,
+    TType.I16: CompactType.I16,
+    TType.I32: CompactType.I32,
+    TType.I64: CompactType.I64,
+    TType.DOUBLE: CompactType.DOUBLE,
+    TType.STRING: CompactType.BINARY,
+    TType.STRUCT: CompactType.STRUCT,
+    TType.LIST: CompactType.LIST,
+    TType.SET: CompactType.SET,
+    TType.MAP: CompactType.MAP,
+}
 
 TTYPES = {}
 for k, v in CTYPES.items():
-  TTYPES[v] = k
+    TTYPES[v] = k
 TTYPES[CompactType.FALSE] = TType.BOOL
 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
-  VERSION_MASK = 0x1f
-  TYPE_MASK = 0xe0
-  TYPE_BITS = 0x07
-  TYPE_SHIFT_AMOUNT = 5
+    PROTOCOL_ID = 0x82
+    VERSION = 1
+    VERSION_MASK = 0x1f
+    TYPE_MASK = 0xe0
+    TYPE_BITS = 0x07
+    TYPE_SHIFT_AMOUNT = 5
 
-  def __init__(self, trans,
-               string_length_limit=None,
-               container_length_limit=None):
-    TProtocolBase.__init__(self, trans)
-    self.state = CLEAR
-    self.__last_fid = 0
-    self.__bool_fid = None
-    self.__bool_value = None
-    self.__structs = []
-    self.__containers = []
-    self.string_length_limit = string_length_limit
-    self.container_length_limit = container_length_limit
+    def __init__(self, trans,
+                 string_length_limit=None,
+                 container_length_limit=None):
+        TProtocolBase.__init__(self, trans)
+        self.state = CLEAR
+        self.__last_fid = 0
+        self.__bool_fid = None
+        self.__bool_value = None
+        self.__structs = []
+        self.__containers = []
+        self.string_length_limit = string_length_limit
+        self.container_length_limit = container_length_limit
 
-  def _check_string_length(self, length):
-    self._check_length(self.string_length_limit, length)
+    def _check_string_length(self, length):
+        self._check_length(self.string_length_limit, length)
 
-  def _check_container_length(self, length):
-    self._check_length(self.container_length_limit, length)
+    def _check_container_length(self, length):
+        self._check_length(self.container_length_limit, length)
 
-  def __writeVarint(self, n):
-    writeVarint(self.trans, n)
+    def __writeVarint(self, n):
+        writeVarint(self.trans, n)
 
-  def writeMessageBegin(self, name, type, seqid):
-    assert self.state == CLEAR
-    self.__writeUByte(self.PROTOCOL_ID)
-    self.__writeUByte(self.VERSION | (type << self.TYPE_SHIFT_AMOUNT))
-    self.__writeVarint(seqid)
-    self.__writeBinary(str_to_binary(name))
-    self.state = VALUE_WRITE
+    def writeMessageBegin(self, name, type, seqid):
+        assert self.state == CLEAR
+        self.__writeUByte(self.PROTOCOL_ID)
+        self.__writeUByte(self.VERSION | (type << self.TYPE_SHIFT_AMOUNT))
+        self.__writeVarint(seqid)
+        self.__writeBinary(str_to_binary(name))
+        self.state = VALUE_WRITE
 
-  def writeMessageEnd(self):
-    assert self.state == VALUE_WRITE
-    self.state = CLEAR
+    def writeMessageEnd(self):
+        assert self.state == VALUE_WRITE
+        self.state = CLEAR
 
-  def writeStructBegin(self, name):
-    assert self.state in (CLEAR, CONTAINER_WRITE, VALUE_WRITE), self.state
-    self.__structs.append((self.state, self.__last_fid))
-    self.state = FIELD_WRITE
-    self.__last_fid = 0
+    def writeStructBegin(self, name):
+        assert self.state in (CLEAR, CONTAINER_WRITE, VALUE_WRITE), self.state
+        self.__structs.append((self.state, self.__last_fid))
+        self.state = FIELD_WRITE
+        self.__last_fid = 0
 
-  def writeStructEnd(self):
-    assert self.state == FIELD_WRITE
-    self.state, self.__last_fid = self.__structs.pop()
+    def writeStructEnd(self):
+        assert self.state == FIELD_WRITE
+        self.state, self.__last_fid = self.__structs.pop()
 
-  def writeFieldStop(self):
-    self.__writeByte(0)
+    def writeFieldStop(self):
+        self.__writeByte(0)
 
-  def __writeFieldHeader(self, type, fid):
-    delta = fid - self.__last_fid
-    if 0 < delta <= 15:
-      self.__writeUByte(delta << 4 | type)
-    else:
-      self.__writeByte(type)
-      self.__writeI16(fid)
-    self.__last_fid = fid
+    def __writeFieldHeader(self, type, fid):
+        delta = fid - self.__last_fid
+        if 0 < delta <= 15:
+            self.__writeUByte(delta << 4 | type)
+        else:
+            self.__writeByte(type)
+            self.__writeI16(fid)
+        self.__last_fid = fid
 
-  def writeFieldBegin(self, name, type, fid):
-    assert self.state == FIELD_WRITE, self.state
-    if type == TType.BOOL:
-      self.state = BOOL_WRITE
-      self.__bool_fid = fid
-    else:
-      self.state = VALUE_WRITE
-      self.__writeFieldHeader(CTYPES[type], fid)
+    def writeFieldBegin(self, name, type, fid):
+        assert self.state == FIELD_WRITE, self.state
+        if type == TType.BOOL:
+            self.state = BOOL_WRITE
+            self.__bool_fid = fid
+        else:
+            self.state = VALUE_WRITE
+            self.__writeFieldHeader(CTYPES[type], fid)
 
-  def writeFieldEnd(self):
-    assert self.state in (VALUE_WRITE, BOOL_WRITE), self.state
-    self.state = FIELD_WRITE
+    def writeFieldEnd(self):
+        assert self.state in (VALUE_WRITE, BOOL_WRITE), self.state
+        self.state = FIELD_WRITE
 
-  def __writeUByte(self, byte):
-    self.trans.write(pack('!B', byte))
+    def __writeUByte(self, byte):
+        self.trans.write(pack('!B', byte))
 
-  def __writeByte(self, byte):
-    self.trans.write(pack('!b', byte))
+    def __writeByte(self, byte):
+        self.trans.write(pack('!b', byte))
 
-  def __writeI16(self, i16):
-    self.__writeVarint(makeZigZag(i16, 16))
+    def __writeI16(self, i16):
+        self.__writeVarint(makeZigZag(i16, 16))
 
-  def __writeSize(self, i32):
-    self.__writeVarint(i32)
+    def __writeSize(self, i32):
+        self.__writeVarint(i32)
 
-  def writeCollectionBegin(self, etype, size):
-    assert self.state in (VALUE_WRITE, CONTAINER_WRITE), self.state
-    if size <= 14:
-      self.__writeUByte(size << 4 | CTYPES[etype])
-    else:
-      self.__writeUByte(0xf0 | CTYPES[etype])
-      self.__writeSize(size)
-    self.__containers.append(self.state)
-    self.state = CONTAINER_WRITE
-  writeSetBegin = writeCollectionBegin
-  writeListBegin = writeCollectionBegin
+    def writeCollectionBegin(self, etype, size):
+        assert self.state in (VALUE_WRITE, CONTAINER_WRITE), self.state
+        if size <= 14:
+            self.__writeUByte(size << 4 | CTYPES[etype])
+        else:
+            self.__writeUByte(0xf0 | CTYPES[etype])
+            self.__writeSize(size)
+        self.__containers.append(self.state)
+        self.state = CONTAINER_WRITE
+    writeSetBegin = writeCollectionBegin
+    writeListBegin = writeCollectionBegin
 
-  def writeMapBegin(self, ktype, vtype, size):
-    assert self.state in (VALUE_WRITE, CONTAINER_WRITE), self.state
-    if size == 0:
-      self.__writeByte(0)
-    else:
-      self.__writeSize(size)
-      self.__writeUByte(CTYPES[ktype] << 4 | CTYPES[vtype])
-    self.__containers.append(self.state)
-    self.state = CONTAINER_WRITE
+    def writeMapBegin(self, ktype, vtype, size):
+        assert self.state in (VALUE_WRITE, CONTAINER_WRITE), self.state
+        if size == 0:
+            self.__writeByte(0)
+        else:
+            self.__writeSize(size)
+            self.__writeUByte(CTYPES[ktype] << 4 | CTYPES[vtype])
+        self.__containers.append(self.state)
+        self.state = CONTAINER_WRITE
 
-  def writeCollectionEnd(self):
-    assert self.state == CONTAINER_WRITE, self.state
-    self.state = self.__containers.pop()
-  writeMapEnd = writeCollectionEnd
-  writeSetEnd = writeCollectionEnd
-  writeListEnd = writeCollectionEnd
+    def writeCollectionEnd(self):
+        assert self.state == CONTAINER_WRITE, self.state
+        self.state = self.__containers.pop()
+    writeMapEnd = writeCollectionEnd
+    writeSetEnd = writeCollectionEnd
+    writeListEnd = writeCollectionEnd
 
-  def writeBool(self, bool):
-    if self.state == BOOL_WRITE:
-      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)
-    else:
-      raise AssertionError("Invalid state in compact protocol")
+    def writeBool(self, bool):
+        if self.state == BOOL_WRITE:
+            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)
+        else:
+            raise AssertionError("Invalid state in compact protocol")
 
-  writeByte = writer(__writeByte)
-  writeI16 = writer(__writeI16)
+    writeByte = writer(__writeByte)
+    writeI16 = writer(__writeI16)
 
-  @writer
-  def writeI32(self, i32):
-    self.__writeVarint(makeZigZag(i32, 32))
+    @writer
+    def writeI32(self, i32):
+        self.__writeVarint(makeZigZag(i32, 32))
 
-  @writer
-  def writeI64(self, i64):
-    self.__writeVarint(makeZigZag(i64, 64))
+    @writer
+    def writeI64(self, i64):
+        self.__writeVarint(makeZigZag(i64, 64))
 
-  @writer
-  def writeDouble(self, dub):
-    self.trans.write(pack('<d', dub))
+    @writer
+    def writeDouble(self, dub):
+        self.trans.write(pack('<d', dub))
 
-  def __writeBinary(self, s):
-    self.__writeSize(len(s))
-    self.trans.write(s)
-  writeBinary = writer(__writeBinary)
+    def __writeBinary(self, s):
+        self.__writeSize(len(s))
+        self.trans.write(s)
+    writeBinary = writer(__writeBinary)
 
-  def readFieldBegin(self):
-    assert self.state == FIELD_READ, self.state
-    type = self.__readUByte()
-    if type & 0x0f == TType.STOP:
-      return (None, 0, 0)
-    delta = type >> 4
-    if delta == 0:
-      fid = self.__readI16()
-    else:
-      fid = self.__last_fid + delta
-    self.__last_fid = fid
-    type = type & 0x0f
-    if type == CompactType.TRUE:
-      self.state = BOOL_READ
-      self.__bool_value = True
-    elif type == CompactType.FALSE:
-      self.state = BOOL_READ
-      self.__bool_value = False
-    else:
-      self.state = VALUE_READ
-    return (None, self.__getTType(type), fid)
+    def readFieldBegin(self):
+        assert self.state == FIELD_READ, self.state
+        type = self.__readUByte()
+        if type & 0x0f == TType.STOP:
+            return (None, 0, 0)
+        delta = type >> 4
+        if delta == 0:
+            fid = self.__readI16()
+        else:
+            fid = self.__last_fid + delta
+        self.__last_fid = fid
+        type = type & 0x0f
+        if type == CompactType.TRUE:
+            self.state = BOOL_READ
+            self.__bool_value = True
+        elif type == CompactType.FALSE:
+            self.state = BOOL_READ
+            self.__bool_value = False
+        else:
+            self.state = VALUE_READ
+        return (None, self.__getTType(type), fid)
 
-  def readFieldEnd(self):
-    assert self.state in (VALUE_READ, BOOL_READ), self.state
-    self.state = FIELD_READ
+    def readFieldEnd(self):
+        assert self.state in (VALUE_READ, BOOL_READ), self.state
+        self.state = FIELD_READ
 
-  def __readUByte(self):
-    result, = unpack('!B', self.trans.readAll(1))
-    return result
+    def __readUByte(self):
+        result, = unpack('!B', self.trans.readAll(1))
+        return result
 
-  def __readByte(self):
-    result, = unpack('!b', self.trans.readAll(1))
-    return result
+    def __readByte(self):
+        result, = unpack('!b', self.trans.readAll(1))
+        return result
 
-  def __readVarint(self):
-    return readVarint(self.trans)
+    def __readVarint(self):
+        return readVarint(self.trans)
 
-  def __readZigZag(self):
-    return fromZigZag(self.__readVarint())
+    def __readZigZag(self):
+        return fromZigZag(self.__readVarint())
 
-  def __readSize(self):
-    result = self.__readVarint()
-    if result < 0:
-      raise TProtocolException("Length < 0")
-    return result
+    def __readSize(self):
+        result = self.__readVarint()
+        if result < 0:
+            raise TProtocolException("Length < 0")
+        return result
 
-  def readMessageBegin(self):
-    assert self.state == CLEAR
-    proto_id = self.__readUByte()
-    if proto_id != self.PROTOCOL_ID:
-      raise TProtocolException(TProtocolException.BAD_VERSION,
-                               'Bad protocol id in the message: %d' % proto_id)
-    ver_type = self.__readUByte()
-    type = (ver_type >> self.TYPE_SHIFT_AMOUNT) & self.TYPE_BITS
-    version = ver_type & self.VERSION_MASK
-    if version != self.VERSION:
-      raise TProtocolException(TProtocolException.BAD_VERSION,
-                               'Bad version: %d (expect %d)' % (version, self.VERSION))
-    seqid = self.__readVarint()
-    name = binary_to_str(self.__readBinary())
-    return (name, type, seqid)
+    def readMessageBegin(self):
+        assert self.state == CLEAR
+        proto_id = self.__readUByte()
+        if proto_id != self.PROTOCOL_ID:
+            raise TProtocolException(TProtocolException.BAD_VERSION,
+                                     'Bad protocol id in the message: %d' % proto_id)
+        ver_type = self.__readUByte()
+        type = (ver_type >> self.TYPE_SHIFT_AMOUNT) & self.TYPE_BITS
+        version = ver_type & self.VERSION_MASK
+        if version != self.VERSION:
+            raise TProtocolException(TProtocolException.BAD_VERSION,
+                                     'Bad version: %d (expect %d)' % (version, self.VERSION))
+        seqid = self.__readVarint()
+        name = binary_to_str(self.__readBinary())
+        return (name, type, seqid)
 
-  def readMessageEnd(self):
-    assert self.state == CLEAR
-    assert len(self.__structs) == 0
+    def readMessageEnd(self):
+        assert self.state == CLEAR
+        assert len(self.__structs) == 0
 
-  def readStructBegin(self):
-    assert self.state in (CLEAR, CONTAINER_READ, VALUE_READ), self.state
-    self.__structs.append((self.state, self.__last_fid))
-    self.state = FIELD_READ
-    self.__last_fid = 0
+    def readStructBegin(self):
+        assert self.state in (CLEAR, CONTAINER_READ, VALUE_READ), self.state
+        self.__structs.append((self.state, self.__last_fid))
+        self.state = FIELD_READ
+        self.__last_fid = 0
 
-  def readStructEnd(self):
-    assert self.state == FIELD_READ
-    self.state, self.__last_fid = self.__structs.pop()
+    def readStructEnd(self):
+        assert self.state == FIELD_READ
+        self.state, self.__last_fid = self.__structs.pop()
 
-  def readCollectionBegin(self):
-    assert self.state in (VALUE_READ, CONTAINER_READ), self.state
-    size_type = self.__readUByte()
-    size = size_type >> 4
-    type = self.__getTType(size_type)
-    if size == 15:
-      size = self.__readSize()
-    self._check_container_length(size)
-    self.__containers.append(self.state)
-    self.state = CONTAINER_READ
-    return type, size
-  readSetBegin = readCollectionBegin
-  readListBegin = readCollectionBegin
+    def readCollectionBegin(self):
+        assert self.state in (VALUE_READ, CONTAINER_READ), self.state
+        size_type = self.__readUByte()
+        size = size_type >> 4
+        type = self.__getTType(size_type)
+        if size == 15:
+            size = self.__readSize()
+        self._check_container_length(size)
+        self.__containers.append(self.state)
+        self.state = CONTAINER_READ
+        return type, size
+    readSetBegin = readCollectionBegin
+    readListBegin = readCollectionBegin
 
-  def readMapBegin(self):
-    assert self.state in (VALUE_READ, CONTAINER_READ), self.state
-    size = self.__readSize()
-    self._check_container_length(size)
-    types = 0
-    if size > 0:
-      types = self.__readUByte()
-    vtype = self.__getTType(types)
-    ktype = self.__getTType(types >> 4)
-    self.__containers.append(self.state)
-    self.state = CONTAINER_READ
-    return (ktype, vtype, size)
+    def readMapBegin(self):
+        assert self.state in (VALUE_READ, CONTAINER_READ), self.state
+        size = self.__readSize()
+        self._check_container_length(size)
+        types = 0
+        if size > 0:
+            types = self.__readUByte()
+        vtype = self.__getTType(types)
+        ktype = self.__getTType(types >> 4)
+        self.__containers.append(self.state)
+        self.state = CONTAINER_READ
+        return (ktype, vtype, size)
 
-  def readCollectionEnd(self):
-    assert self.state == CONTAINER_READ, self.state
-    self.state = self.__containers.pop()
-  readSetEnd = readCollectionEnd
-  readListEnd = readCollectionEnd
-  readMapEnd = readCollectionEnd
+    def readCollectionEnd(self):
+        assert self.state == CONTAINER_READ, self.state
+        self.state = self.__containers.pop()
+    readSetEnd = readCollectionEnd
+    readListEnd = readCollectionEnd
+    readMapEnd = readCollectionEnd
 
-  def readBool(self):
-    if self.state == BOOL_READ:
-      return self.__bool_value == CompactType.TRUE
-    elif self.state == CONTAINER_READ:
-      return self.__readByte() == CompactType.TRUE
-    else:
-      raise AssertionError("Invalid state in compact protocol: %d" %
-                           self.state)
+    def readBool(self):
+        if self.state == BOOL_READ:
+            return self.__bool_value == CompactType.TRUE
+        elif self.state == CONTAINER_READ:
+            return self.__readByte() == CompactType.TRUE
+        else:
+            raise AssertionError("Invalid state in compact protocol: %d" %
+                                 self.state)
 
-  readByte = reader(__readByte)
-  __readI16 = __readZigZag
-  readI16 = reader(__readZigZag)
-  readI32 = reader(__readZigZag)
-  readI64 = reader(__readZigZag)
+    readByte = reader(__readByte)
+    __readI16 = __readZigZag
+    readI16 = reader(__readZigZag)
+    readI32 = reader(__readZigZag)
+    readI64 = reader(__readZigZag)
 
-  @reader
-  def readDouble(self):
-    buff = self.trans.readAll(8)
-    val, = unpack('<d', buff)
-    return val
+    @reader
+    def readDouble(self):
+        buff = self.trans.readAll(8)
+        val, = unpack('<d', buff)
+        return val
 
-  def __readBinary(self):
-    size = self.__readSize()
-    self._check_string_length(size)
-    return self.trans.readAll(size)
-  readBinary = reader(__readBinary)
+    def __readBinary(self):
+        size = self.__readSize()
+        self._check_string_length(size)
+        return self.trans.readAll(size)
+    readBinary = reader(__readBinary)
 
-  def __getTType(self, byte):
-    return TTYPES[byte & 0x0f]
+    def __getTType(self, byte):
+        return TTYPES[byte & 0x0f]
 
 
 class TCompactProtocolFactory(object):
-  def __init__(self,
-               string_length_limit=None,
-               container_length_limit=None):
-    self.string_length_limit = string_length_limit
-    self.container_length_limit = container_length_limit
+    def __init__(self,
+                 string_length_limit=None,
+                 container_length_limit=None):
+        self.string_length_limit = string_length_limit
+        self.container_length_limit = container_length_limit
 
-  def getProtocol(self, trans):
-    return TCompactProtocol(trans,
-                            self.string_length_limit,
-                            self.container_length_limit)
+    def getProtocol(self, trans):
+        return TCompactProtocol(trans,
+                                self.string_length_limit,
+                                self.container_length_limit)
diff --git a/lib/py/src/protocol/TJSONProtocol.py b/lib/py/src/protocol/TJSONProtocol.py
index f9e65fb..db2099a 100644
--- a/lib/py/src/protocol/TJSONProtocol.py
+++ b/lib/py/src/protocol/TJSONProtocol.py
@@ -17,7 +17,8 @@
 # under the License.
 #
 
-from .TProtocol import TType, TProtocolBase, TProtocolException, checkIntegerLimits
+from .TProtocol import (TType, TProtocolBase, TProtocolException,
+                        checkIntegerLimits)
 import base64
 import math
 import sys
@@ -45,14 +46,14 @@
 ESCSEQ0 = ord('\\')
 ESCSEQ1 = ord('u')
 ESCAPE_CHAR_VALS = {
-  '"': '\\"',
-  '\\': '\\\\',
-  '\b': '\\b',
-  '\f': '\\f',
-  '\n': '\\n',
-  '\r': '\\r',
-  '\t': '\\t',
-  # '/': '\\/',
+    '"': '\\"',
+    '\\': '\\\\',
+    '\b': '\\b',
+    '\f': '\\f',
+    '\n': '\\n',
+    '\r': '\\r',
+    '\t': '\\t',
+    # '/': '\\/',
 }
 ESCAPE_CHARS = {
     b'"': '"',
@@ -66,519 +67,527 @@
 }
 NUMERIC_CHAR = b'+-.0123456789Ee'
 
-CTYPES = {TType.BOOL:       'tf',
-          TType.BYTE:       'i8',
-          TType.I16:        'i16',
-          TType.I32:        'i32',
-          TType.I64:        'i64',
-          TType.DOUBLE:     'dbl',
-          TType.STRING:     'str',
-          TType.STRUCT:     'rec',
-          TType.LIST:       'lst',
-          TType.SET:        'set',
-          TType.MAP:        'map'}
+CTYPES = {
+    TType.BOOL: 'tf',
+    TType.BYTE: 'i8',
+    TType.I16: 'i16',
+    TType.I32: 'i32',
+    TType.I64: 'i64',
+    TType.DOUBLE: 'dbl',
+    TType.STRING: 'str',
+    TType.STRUCT: 'rec',
+    TType.LIST: 'lst',
+    TType.SET: 'set',
+    TType.MAP: 'map',
+}
 
 JTYPES = {}
 for key in CTYPES.keys():
-  JTYPES[CTYPES[key]] = key
+    JTYPES[CTYPES[key]] = key
 
 
 class JSONBaseContext(object):
 
-  def __init__(self, protocol):
-    self.protocol = protocol
-    self.first = True
+    def __init__(self, protocol):
+        self.protocol = protocol
+        self.first = True
 
-  def doIO(self, function):
-    pass
+    def doIO(self, function):
+        pass
 
-  def write(self):
-    pass
+    def write(self):
+        pass
 
-  def read(self):
-    pass
+    def read(self):
+        pass
 
-  def escapeNum(self):
-    return False
+    def escapeNum(self):
+        return False
 
-  def __str__(self):
-    return self.__class__.__name__
+    def __str__(self):
+        return self.__class__.__name__
 
 
 class JSONListContext(JSONBaseContext):
 
-  def doIO(self, function):
-    if self.first is True:
-      self.first = False
-    else:
-      function(COMMA)
+    def doIO(self, function):
+        if self.first is True:
+            self.first = False
+        else:
+            function(COMMA)
 
-  def write(self):
-    self.doIO(self.protocol.trans.write)
+    def write(self):
+        self.doIO(self.protocol.trans.write)
 
-  def read(self):
-    self.doIO(self.protocol.readJSONSyntaxChar)
+    def read(self):
+        self.doIO(self.protocol.readJSONSyntaxChar)
 
 
 class JSONPairContext(JSONBaseContext):
 
-  def __init__(self, protocol):
-    super(JSONPairContext, self).__init__(protocol)
-    self.colon = True
+    def __init__(self, protocol):
+        super(JSONPairContext, self).__init__(protocol)
+        self.colon = True
 
-  def doIO(self, function):
-    if self.first:
-      self.first = False
-      self.colon = True
-    else:
-      function(COLON if self.colon else COMMA)
-      self.colon = not self.colon
+    def doIO(self, function):
+        if self.first:
+            self.first = False
+            self.colon = True
+        else:
+            function(COLON if self.colon else COMMA)
+            self.colon = not self.colon
 
-  def write(self):
-    self.doIO(self.protocol.trans.write)
+    def write(self):
+        self.doIO(self.protocol.trans.write)
 
-  def read(self):
-    self.doIO(self.protocol.readJSONSyntaxChar)
+    def read(self):
+        self.doIO(self.protocol.readJSONSyntaxChar)
 
-  def escapeNum(self):
-    return self.colon
+    def escapeNum(self):
+        return self.colon
 
-  def __str__(self):
-    return '%s, colon=%s' % (self.__class__.__name__, self.colon)
+    def __str__(self):
+        return '%s, colon=%s' % (self.__class__.__name__, self.colon)
 
 
 class LookaheadReader():
-  hasData = False
-  data = ''
+    hasData = False
+    data = ''
 
-  def __init__(self, protocol):
-    self.protocol = protocol
+    def __init__(self, protocol):
+        self.protocol = protocol
 
-  def read(self):
-    if self.hasData is True:
-      self.hasData = False
-    else:
-      self.data = self.protocol.trans.read(1)
-    return self.data
+    def read(self):
+        if self.hasData is True:
+            self.hasData = False
+        else:
+            self.data = self.protocol.trans.read(1)
+        return self.data
 
-  def peek(self):
-    if self.hasData is False:
-      self.data = self.protocol.trans.read(1)
-    self.hasData = True
-    return self.data
+    def peek(self):
+        if self.hasData is False:
+            self.data = self.protocol.trans.read(1)
+        self.hasData = True
+        return self.data
 
 
 class TJSONProtocolBase(TProtocolBase):
 
-  def __init__(self, trans):
-    TProtocolBase.__init__(self, trans)
-    self.resetWriteContext()
-    self.resetReadContext()
+    def __init__(self, trans):
+        TProtocolBase.__init__(self, trans)
+        self.resetWriteContext()
+        self.resetReadContext()
 
-  # We don't have length limit implementation for JSON protocols
-  @property
-  def string_length_limit(senf):
-    return None
+    # We don't have length limit implementation for JSON protocols
+    @property
+    def string_length_limit(senf):
+        return None
 
-  @property
-  def container_length_limit(senf):
-    return None
+    @property
+    def container_length_limit(senf):
+        return None
 
-  def resetWriteContext(self):
-    self.context = JSONBaseContext(self)
-    self.contextStack = [self.context]
+    def resetWriteContext(self):
+        self.context = JSONBaseContext(self)
+        self.contextStack = [self.context]
 
-  def resetReadContext(self):
-    self.resetWriteContext()
-    self.reader = LookaheadReader(self)
+    def resetReadContext(self):
+        self.resetWriteContext()
+        self.reader = LookaheadReader(self)
 
-  def pushContext(self, ctx):
-    self.contextStack.append(ctx)
-    self.context = ctx
+    def pushContext(self, ctx):
+        self.contextStack.append(ctx)
+        self.context = ctx
 
-  def popContext(self):
-    self.contextStack.pop()
-    if self.contextStack:
-      self.context = self.contextStack[-1]
-    else:
-      self.context = JSONBaseContext(self)
-
-  def writeJSONString(self, string):
-    self.context.write()
-    json_str = ['"']
-    for s in string:
-      escaped = ESCAPE_CHAR_VALS.get(s, s)
-      json_str.append(escaped)
-    json_str.append('"')
-    self.trans.write(str_to_binary(''.join(json_str)))
-
-  def writeJSONNumber(self, number, formatter='{0}'):
-    self.context.write()
-    jsNumber = str(formatter.format(number)).encode('ascii')
-    if self.context.escapeNum():
-      self.trans.write(QUOTE)
-      self.trans.write(jsNumber)
-      self.trans.write(QUOTE)
-    else:
-      self.trans.write(jsNumber)
-
-  def writeJSONBase64(self, binary):
-    self.context.write()
-    self.trans.write(QUOTE)
-    self.trans.write(base64.b64encode(binary))
-    self.trans.write(QUOTE)
-
-  def writeJSONObjectStart(self):
-    self.context.write()
-    self.trans.write(LBRACE)
-    self.pushContext(JSONPairContext(self))
-
-  def writeJSONObjectEnd(self):
-    self.popContext()
-    self.trans.write(RBRACE)
-
-  def writeJSONArrayStart(self):
-    self.context.write()
-    self.trans.write(LBRACKET)
-    self.pushContext(JSONListContext(self))
-
-  def writeJSONArrayEnd(self):
-    self.popContext()
-    self.trans.write(RBRACKET)
-
-  def readJSONSyntaxChar(self, character):
-    current = self.reader.read()
-    if character != current:
-      raise TProtocolException(TProtocolException.INVALID_DATA,
-                               "Unexpected character: %s" % current)
-
-  def _isHighSurrogate(self, codeunit):
-    return codeunit >= 0xd800 and codeunit <= 0xdbff
-
-  def _isLowSurrogate(self, codeunit):
-    return codeunit >= 0xdc00 and codeunit <= 0xdfff
-
-  def _toChar(self, high, low=None):
-    if not low:
-      if sys.version_info[0] == 2:
-        return ("\\u%04x" % high).decode('unicode-escape').encode('utf-8')
-      else:
-        return chr(high)
-    else:
-      codepoint = (1 << 16) + ((high & 0x3ff) << 10)
-      codepoint += low & 0x3ff
-      if sys.version_info[0] == 2:
-        s = "\\U%08x" % codepoint
-        return s.decode('unicode-escape').encode('utf-8')
-      else:
-        return chr(codepoint)
-
-  def readJSONString(self, skipContext):
-    highSurrogate = None
-    string = []
-    if skipContext is False:
-      self.context.read()
-    self.readJSONSyntaxChar(QUOTE)
-    while True:
-      character = self.reader.read()
-      if character == QUOTE:
-        break
-      if ord(character) == ESCSEQ0:
-        character = self.reader.read()
-        if ord(character) == ESCSEQ1:
-          character = self.trans.read(4).decode('ascii')
-          codeunit = int(character, 16)
-          if self._isHighSurrogate(codeunit):
-            if highSurrogate:
-              raise TProtocolException(TProtocolException.INVALID_DATA,
-                                       "Expected low surrogate char")
-            highSurrogate = codeunit
-            continue
-          elif self._isLowSurrogate(codeunit):
-            if not highSurrogate:
-              raise TProtocolException(TProtocolException.INVALID_DATA,
-                                       "Expected high surrogate char")
-            character = self._toChar(highSurrogate, codeunit)
-            highSurrogate = None
-          else:
-            character = self._toChar(codeunit)
+    def popContext(self):
+        self.contextStack.pop()
+        if self.contextStack:
+            self.context = self.contextStack[-1]
         else:
-          if character not in ESCAPE_CHARS:
+            self.context = JSONBaseContext(self)
+
+    def writeJSONString(self, string):
+        self.context.write()
+        json_str = ['"']
+        for s in string:
+            escaped = ESCAPE_CHAR_VALS.get(s, s)
+            json_str.append(escaped)
+        json_str.append('"')
+        self.trans.write(str_to_binary(''.join(json_str)))
+
+    def writeJSONNumber(self, number, formatter='{0}'):
+        self.context.write()
+        jsNumber = str(formatter.format(number)).encode('ascii')
+        if self.context.escapeNum():
+            self.trans.write(QUOTE)
+            self.trans.write(jsNumber)
+            self.trans.write(QUOTE)
+        else:
+            self.trans.write(jsNumber)
+
+    def writeJSONBase64(self, binary):
+        self.context.write()
+        self.trans.write(QUOTE)
+        self.trans.write(base64.b64encode(binary))
+        self.trans.write(QUOTE)
+
+    def writeJSONObjectStart(self):
+        self.context.write()
+        self.trans.write(LBRACE)
+        self.pushContext(JSONPairContext(self))
+
+    def writeJSONObjectEnd(self):
+        self.popContext()
+        self.trans.write(RBRACE)
+
+    def writeJSONArrayStart(self):
+        self.context.write()
+        self.trans.write(LBRACKET)
+        self.pushContext(JSONListContext(self))
+
+    def writeJSONArrayEnd(self):
+        self.popContext()
+        self.trans.write(RBRACKET)
+
+    def readJSONSyntaxChar(self, character):
+        current = self.reader.read()
+        if character != current:
             raise TProtocolException(TProtocolException.INVALID_DATA,
-                                     "Expected control char")
-          character = ESCAPE_CHARS[character]
-      elif character in ESCAPE_CHAR_VALS:
-        raise TProtocolException(TProtocolException.INVALID_DATA,
-                                 "Unescaped control char")
-      elif sys.version_info[0] > 2:
-        utf8_bytes = bytearray([ord(character)])
-        while ord(self.reader.peek()) >= 0x80:
-          utf8_bytes.append(ord(self.reader.read()))
-        character = utf8_bytes.decode('utf8')
-      string.append(character)
+                                     "Unexpected character: %s" % current)
 
-      if highSurrogate:
-        raise TProtocolException(TProtocolException.INVALID_DATA,
-                                 "Expected low surrogate char")
-    return ''.join(string)
+    def _isHighSurrogate(self, codeunit):
+        return codeunit >= 0xd800 and codeunit <= 0xdbff
 
-  def isJSONNumeric(self, character):
-    return (True if NUMERIC_CHAR.find(character) != - 1 else False)
+    def _isLowSurrogate(self, codeunit):
+        return codeunit >= 0xdc00 and codeunit <= 0xdfff
 
-  def readJSONQuotes(self):
-    if (self.context.escapeNum()):
-      self.readJSONSyntaxChar(QUOTE)
+    def _toChar(self, high, low=None):
+        if not low:
+            if sys.version_info[0] == 2:
+                return ("\\u%04x" % high).decode('unicode-escape') \
+                                         .encode('utf-8')
+            else:
+                return chr(high)
+        else:
+            codepoint = (1 << 16) + ((high & 0x3ff) << 10)
+            codepoint += low & 0x3ff
+            if sys.version_info[0] == 2:
+                s = "\\U%08x" % codepoint
+                return s.decode('unicode-escape').encode('utf-8')
+            else:
+                return chr(codepoint)
 
-  def readJSONNumericChars(self):
-    numeric = []
-    while True:
-      character = self.reader.peek()
-      if self.isJSONNumeric(character) is False:
-        break
-      numeric.append(self.reader.read())
-    return b''.join(numeric).decode('ascii')
-
-  def readJSONInteger(self):
-    self.context.read()
-    self.readJSONQuotes()
-    numeric = self.readJSONNumericChars()
-    self.readJSONQuotes()
-    try:
-      return int(numeric)
-    except ValueError:
-      raise TProtocolException(TProtocolException.INVALID_DATA,
-                               "Bad data encounted in numeric data")
-
-  def readJSONDouble(self):
-    self.context.read()
-    if self.reader.peek() == QUOTE:
-      string = self.readJSONString(True)
-      try:
-        double = float(string)
-        if (self.context.escapeNum is False and
-           not math.isinf(double) and
-           not math.isnan(double)):
-          raise TProtocolException(TProtocolException.INVALID_DATA,
-                                   "Numeric data unexpectedly quoted")
-        return double
-      except ValueError:
-        raise TProtocolException(TProtocolException.INVALID_DATA,
-                                 "Bad data encounted in numeric data")
-    else:
-      if self.context.escapeNum() is True:
+    def readJSONString(self, skipContext):
+        highSurrogate = None
+        string = []
+        if skipContext is False:
+            self.context.read()
         self.readJSONSyntaxChar(QUOTE)
-      try:
-        return float(self.readJSONNumericChars())
-      except ValueError:
-        raise TProtocolException(TProtocolException.INVALID_DATA,
-                                 "Bad data encounted in numeric data")
+        while True:
+            character = self.reader.read()
+            if character == QUOTE:
+                break
+            if ord(character) == ESCSEQ0:
+                character = self.reader.read()
+                if ord(character) == ESCSEQ1:
+                    character = self.trans.read(4).decode('ascii')
+                    codeunit = int(character, 16)
+                    if self._isHighSurrogate(codeunit):
+                        if highSurrogate:
+                            raise TProtocolException(
+                                TProtocolException.INVALID_DATA,
+                                "Expected low surrogate char")
+                        highSurrogate = codeunit
+                        continue
+                    elif self._isLowSurrogate(codeunit):
+                        if not highSurrogate:
+                            raise TProtocolException(
+                                TProtocolException.INVALID_DATA,
+                                "Expected high surrogate char")
+                        character = self._toChar(highSurrogate, codeunit)
+                        highSurrogate = None
+                    else:
+                        character = self._toChar(codeunit)
+                else:
+                    if character not in ESCAPE_CHARS:
+                        raise TProtocolException(
+                            TProtocolException.INVALID_DATA,
+                            "Expected control char")
+                    character = ESCAPE_CHARS[character]
+            elif character in ESCAPE_CHAR_VALS:
+                raise TProtocolException(TProtocolException.INVALID_DATA,
+                                         "Unescaped control char")
+            elif sys.version_info[0] > 2:
+                utf8_bytes = bytearray([ord(character)])
+                while ord(self.reader.peek()) >= 0x80:
+                    utf8_bytes.append(ord(self.reader.read()))
+                character = utf8_bytes.decode('utf8')
+            string.append(character)
 
-  def readJSONBase64(self):
-    string = self.readJSONString(False)
-    size = len(string)
-    m = size % 4
-    # Force padding since b64encode method does not allow it
-    if m != 0:
-      for i in range(4 - m):
-        string += '='
-    return base64.b64decode(string)
+            if highSurrogate:
+                raise TProtocolException(TProtocolException.INVALID_DATA,
+                                         "Expected low surrogate char")
+        return ''.join(string)
 
-  def readJSONObjectStart(self):
-    self.context.read()
-    self.readJSONSyntaxChar(LBRACE)
-    self.pushContext(JSONPairContext(self))
+    def isJSONNumeric(self, character):
+        return (True if NUMERIC_CHAR.find(character) != - 1 else False)
 
-  def readJSONObjectEnd(self):
-    self.readJSONSyntaxChar(RBRACE)
-    self.popContext()
+    def readJSONQuotes(self):
+        if (self.context.escapeNum()):
+            self.readJSONSyntaxChar(QUOTE)
 
-  def readJSONArrayStart(self):
-    self.context.read()
-    self.readJSONSyntaxChar(LBRACKET)
-    self.pushContext(JSONListContext(self))
+    def readJSONNumericChars(self):
+        numeric = []
+        while True:
+            character = self.reader.peek()
+            if self.isJSONNumeric(character) is False:
+                break
+            numeric.append(self.reader.read())
+        return b''.join(numeric).decode('ascii')
 
-  def readJSONArrayEnd(self):
-    self.readJSONSyntaxChar(RBRACKET)
-    self.popContext()
+    def readJSONInteger(self):
+        self.context.read()
+        self.readJSONQuotes()
+        numeric = self.readJSONNumericChars()
+        self.readJSONQuotes()
+        try:
+            return int(numeric)
+        except ValueError:
+            raise TProtocolException(TProtocolException.INVALID_DATA,
+                                     "Bad data encounted in numeric data")
+
+    def readJSONDouble(self):
+        self.context.read()
+        if self.reader.peek() == QUOTE:
+            string = self.readJSONString(True)
+            try:
+                double = float(string)
+                if (self.context.escapeNum is False and
+                        not math.isinf(double) and
+                        not math.isnan(double)):
+                    raise TProtocolException(
+                        TProtocolException.INVALID_DATA,
+                        "Numeric data unexpectedly quoted")
+                return double
+            except ValueError:
+                raise TProtocolException(TProtocolException.INVALID_DATA,
+                                         "Bad data encounted in numeric data")
+        else:
+            if self.context.escapeNum() is True:
+                self.readJSONSyntaxChar(QUOTE)
+            try:
+                return float(self.readJSONNumericChars())
+            except ValueError:
+                raise TProtocolException(TProtocolException.INVALID_DATA,
+                                         "Bad data encounted in numeric data")
+
+    def readJSONBase64(self):
+        string = self.readJSONString(False)
+        size = len(string)
+        m = size % 4
+        # Force padding since b64encode method does not allow it
+        if m != 0:
+            for i in range(4 - m):
+                string += '='
+        return base64.b64decode(string)
+
+    def readJSONObjectStart(self):
+        self.context.read()
+        self.readJSONSyntaxChar(LBRACE)
+        self.pushContext(JSONPairContext(self))
+
+    def readJSONObjectEnd(self):
+        self.readJSONSyntaxChar(RBRACE)
+        self.popContext()
+
+    def readJSONArrayStart(self):
+        self.context.read()
+        self.readJSONSyntaxChar(LBRACKET)
+        self.pushContext(JSONListContext(self))
+
+    def readJSONArrayEnd(self):
+        self.readJSONSyntaxChar(RBRACKET)
+        self.popContext()
 
 
 class TJSONProtocol(TJSONProtocolBase):
 
-  def readMessageBegin(self):
-    self.resetReadContext()
-    self.readJSONArrayStart()
-    if self.readJSONInteger() != VERSION:
-      raise TProtocolException(TProtocolException.BAD_VERSION,
-                               "Message contained bad version.")
-    name = self.readJSONString(False)
-    typen = self.readJSONInteger()
-    seqid = self.readJSONInteger()
-    return (name, typen, seqid)
+    def readMessageBegin(self):
+        self.resetReadContext()
+        self.readJSONArrayStart()
+        if self.readJSONInteger() != VERSION:
+            raise TProtocolException(TProtocolException.BAD_VERSION,
+                                     "Message contained bad version.")
+        name = self.readJSONString(False)
+        typen = self.readJSONInteger()
+        seqid = self.readJSONInteger()
+        return (name, typen, seqid)
 
-  def readMessageEnd(self):
-    self.readJSONArrayEnd()
+    def readMessageEnd(self):
+        self.readJSONArrayEnd()
 
-  def readStructBegin(self):
-    self.readJSONObjectStart()
+    def readStructBegin(self):
+        self.readJSONObjectStart()
 
-  def readStructEnd(self):
-    self.readJSONObjectEnd()
+    def readStructEnd(self):
+        self.readJSONObjectEnd()
 
-  def readFieldBegin(self):
-    character = self.reader.peek()
-    ttype = 0
-    id = 0
-    if character == RBRACE:
-      ttype = TType.STOP
-    else:
-      id = self.readJSONInteger()
-      self.readJSONObjectStart()
-      ttype = JTYPES[self.readJSONString(False)]
-    return (None, ttype, id)
+    def readFieldBegin(self):
+        character = self.reader.peek()
+        ttype = 0
+        id = 0
+        if character == RBRACE:
+            ttype = TType.STOP
+        else:
+            id = self.readJSONInteger()
+            self.readJSONObjectStart()
+            ttype = JTYPES[self.readJSONString(False)]
+        return (None, ttype, id)
 
-  def readFieldEnd(self):
-    self.readJSONObjectEnd()
+    def readFieldEnd(self):
+        self.readJSONObjectEnd()
 
-  def readMapBegin(self):
-    self.readJSONArrayStart()
-    keyType = JTYPES[self.readJSONString(False)]
-    valueType = JTYPES[self.readJSONString(False)]
-    size = self.readJSONInteger()
-    self.readJSONObjectStart()
-    return (keyType, valueType, size)
+    def readMapBegin(self):
+        self.readJSONArrayStart()
+        keyType = JTYPES[self.readJSONString(False)]
+        valueType = JTYPES[self.readJSONString(False)]
+        size = self.readJSONInteger()
+        self.readJSONObjectStart()
+        return (keyType, valueType, size)
 
-  def readMapEnd(self):
-    self.readJSONObjectEnd()
-    self.readJSONArrayEnd()
+    def readMapEnd(self):
+        self.readJSONObjectEnd()
+        self.readJSONArrayEnd()
 
-  def readCollectionBegin(self):
-    self.readJSONArrayStart()
-    elemType = JTYPES[self.readJSONString(False)]
-    size = self.readJSONInteger()
-    return (elemType, size)
-  readListBegin = readCollectionBegin
-  readSetBegin = readCollectionBegin
+    def readCollectionBegin(self):
+        self.readJSONArrayStart()
+        elemType = JTYPES[self.readJSONString(False)]
+        size = self.readJSONInteger()
+        return (elemType, size)
+    readListBegin = readCollectionBegin
+    readSetBegin = readCollectionBegin
 
-  def readCollectionEnd(self):
-    self.readJSONArrayEnd()
-  readSetEnd = readCollectionEnd
-  readListEnd = readCollectionEnd
+    def readCollectionEnd(self):
+        self.readJSONArrayEnd()
+    readSetEnd = readCollectionEnd
+    readListEnd = readCollectionEnd
 
-  def readBool(self):
-    return (False if self.readJSONInteger() == 0 else True)
+    def readBool(self):
+        return (False if self.readJSONInteger() == 0 else True)
 
-  def readNumber(self):
-    return self.readJSONInteger()
-  readByte = readNumber
-  readI16 = readNumber
-  readI32 = readNumber
-  readI64 = readNumber
+    def readNumber(self):
+        return self.readJSONInteger()
+    readByte = readNumber
+    readI16 = readNumber
+    readI32 = readNumber
+    readI64 = readNumber
 
-  def readDouble(self):
-    return self.readJSONDouble()
+    def readDouble(self):
+        return self.readJSONDouble()
 
-  def readString(self):
-    return self.readJSONString(False)
+    def readString(self):
+        return self.readJSONString(False)
 
-  def readBinary(self):
-    return self.readJSONBase64()
+    def readBinary(self):
+        return self.readJSONBase64()
 
-  def writeMessageBegin(self, name, request_type, seqid):
-    self.resetWriteContext()
-    self.writeJSONArrayStart()
-    self.writeJSONNumber(VERSION)
-    self.writeJSONString(name)
-    self.writeJSONNumber(request_type)
-    self.writeJSONNumber(seqid)
+    def writeMessageBegin(self, name, request_type, seqid):
+        self.resetWriteContext()
+        self.writeJSONArrayStart()
+        self.writeJSONNumber(VERSION)
+        self.writeJSONString(name)
+        self.writeJSONNumber(request_type)
+        self.writeJSONNumber(seqid)
 
-  def writeMessageEnd(self):
-    self.writeJSONArrayEnd()
+    def writeMessageEnd(self):
+        self.writeJSONArrayEnd()
 
-  def writeStructBegin(self, name):
-    self.writeJSONObjectStart()
+    def writeStructBegin(self, name):
+        self.writeJSONObjectStart()
 
-  def writeStructEnd(self):
-    self.writeJSONObjectEnd()
+    def writeStructEnd(self):
+        self.writeJSONObjectEnd()
 
-  def writeFieldBegin(self, name, ttype, id):
-    self.writeJSONNumber(id)
-    self.writeJSONObjectStart()
-    self.writeJSONString(CTYPES[ttype])
+    def writeFieldBegin(self, name, ttype, id):
+        self.writeJSONNumber(id)
+        self.writeJSONObjectStart()
+        self.writeJSONString(CTYPES[ttype])
 
-  def writeFieldEnd(self):
-    self.writeJSONObjectEnd()
+    def writeFieldEnd(self):
+        self.writeJSONObjectEnd()
 
-  def writeFieldStop(self):
-    pass
+    def writeFieldStop(self):
+        pass
 
-  def writeMapBegin(self, ktype, vtype, size):
-    self.writeJSONArrayStart()
-    self.writeJSONString(CTYPES[ktype])
-    self.writeJSONString(CTYPES[vtype])
-    self.writeJSONNumber(size)
-    self.writeJSONObjectStart()
+    def writeMapBegin(self, ktype, vtype, size):
+        self.writeJSONArrayStart()
+        self.writeJSONString(CTYPES[ktype])
+        self.writeJSONString(CTYPES[vtype])
+        self.writeJSONNumber(size)
+        self.writeJSONObjectStart()
 
-  def writeMapEnd(self):
-    self.writeJSONObjectEnd()
-    self.writeJSONArrayEnd()
+    def writeMapEnd(self):
+        self.writeJSONObjectEnd()
+        self.writeJSONArrayEnd()
 
-  def writeListBegin(self, etype, size):
-    self.writeJSONArrayStart()
-    self.writeJSONString(CTYPES[etype])
-    self.writeJSONNumber(size)
+    def writeListBegin(self, etype, size):
+        self.writeJSONArrayStart()
+        self.writeJSONString(CTYPES[etype])
+        self.writeJSONNumber(size)
 
-  def writeListEnd(self):
-    self.writeJSONArrayEnd()
+    def writeListEnd(self):
+        self.writeJSONArrayEnd()
 
-  def writeSetBegin(self, etype, size):
-    self.writeJSONArrayStart()
-    self.writeJSONString(CTYPES[etype])
-    self.writeJSONNumber(size)
+    def writeSetBegin(self, etype, size):
+        self.writeJSONArrayStart()
+        self.writeJSONString(CTYPES[etype])
+        self.writeJSONNumber(size)
 
-  def writeSetEnd(self):
-    self.writeJSONArrayEnd()
+    def writeSetEnd(self):
+        self.writeJSONArrayEnd()
 
-  def writeBool(self, boolean):
-    self.writeJSONNumber(1 if boolean is True else 0)
+    def writeBool(self, boolean):
+        self.writeJSONNumber(1 if boolean is True else 0)
 
-  def writeByte(self, byte):
-    checkIntegerLimits(byte, 8)
-    self.writeJSONNumber(byte)
+    def writeByte(self, byte):
+        checkIntegerLimits(byte, 8)
+        self.writeJSONNumber(byte)
 
-  def writeI16(self, i16):
-    checkIntegerLimits(i16, 16)
-    self.writeJSONNumber(i16)
+    def writeI16(self, i16):
+        checkIntegerLimits(i16, 16)
+        self.writeJSONNumber(i16)
 
-  def writeI32(self, i32):
-    checkIntegerLimits(i32, 32)
-    self.writeJSONNumber(i32)
+    def writeI32(self, i32):
+        checkIntegerLimits(i32, 32)
+        self.writeJSONNumber(i32)
 
-  def writeI64(self, i64):
-    checkIntegerLimits(i64, 64)
-    self.writeJSONNumber(i64)
+    def writeI64(self, i64):
+        checkIntegerLimits(i64, 64)
+        self.writeJSONNumber(i64)
 
-  def writeDouble(self, dbl):
-    # 17 significant digits should be just enough for any double precision value.
-    self.writeJSONNumber(dbl, '{0:.17g}')
+    def writeDouble(self, dbl):
+        # 17 significant digits should be just enough for any double precision
+        # value.
+        self.writeJSONNumber(dbl, '{0:.17g}')
 
-  def writeString(self, string):
-    self.writeJSONString(string)
+    def writeString(self, string):
+        self.writeJSONString(string)
 
-  def writeBinary(self, binary):
-    self.writeJSONBase64(binary)
+    def writeBinary(self, binary):
+        self.writeJSONBase64(binary)
 
 
 class TJSONProtocolFactory(object):
-  def getProtocol(self, trans):
-    return TJSONProtocol(trans)
+    def getProtocol(self, trans):
+        return TJSONProtocol(trans)
 
-  @property
-  def string_length_limit(senf):
-    return None
+    @property
+    def string_length_limit(senf):
+        return None
 
-  @property
-  def container_length_limit(senf):
-    return None
+    @property
+    def container_length_limit(senf):
+        return None
 
 
 class TSimpleJSONProtocol(TJSONProtocolBase):
diff --git a/lib/py/src/protocol/TMultiplexedProtocol.py b/lib/py/src/protocol/TMultiplexedProtocol.py
index d25f367..309f896 100644
--- a/lib/py/src/protocol/TMultiplexedProtocol.py
+++ b/lib/py/src/protocol/TMultiplexedProtocol.py
@@ -22,18 +22,19 @@
 
 SEPARATOR = ":"
 
-class TMultiplexedProtocol(TProtocolDecorator.TProtocolDecorator):
-  def __init__(self, protocol, serviceName):
-    TProtocolDecorator.TProtocolDecorator.__init__(self, protocol)
-    self.serviceName = serviceName
 
-  def writeMessageBegin(self, name, type, seqid):
-    if (type == TMessageType.CALL or
-        type == TMessageType.ONEWAY):
-      self.protocol.writeMessageBegin(
-        self.serviceName + SEPARATOR + name,
-        type,
-        seqid
-      )
-    else:
-      self.protocol.writeMessageBegin(name, type, seqid)
+class TMultiplexedProtocol(TProtocolDecorator.TProtocolDecorator):
+    def __init__(self, protocol, serviceName):
+        TProtocolDecorator.TProtocolDecorator.__init__(self, protocol)
+        self.serviceName = serviceName
+
+    def writeMessageBegin(self, name, type, seqid):
+        if (type == TMessageType.CALL or
+                type == TMessageType.ONEWAY):
+            self.protocol.writeMessageBegin(
+                self.serviceName + SEPARATOR + name,
+                type,
+                seqid
+            )
+        else:
+            self.protocol.writeMessageBegin(name, type, seqid)
diff --git a/lib/py/src/protocol/TProtocol.py b/lib/py/src/protocol/TProtocol.py
index d9aa2e8..ed6938b 100644
--- a/lib/py/src/protocol/TProtocol.py
+++ b/lib/py/src/protocol/TProtocol.py
@@ -28,373 +28,373 @@
 
 
 class TProtocolException(TException):
-  """Custom Protocol Exception class"""
+    """Custom Protocol Exception class"""
 
-  UNKNOWN = 0
-  INVALID_DATA = 1
-  NEGATIVE_SIZE = 2
-  SIZE_LIMIT = 3
-  BAD_VERSION = 4
-  NOT_IMPLEMENTED = 5
-  DEPTH_LIMIT = 6
+    UNKNOWN = 0
+    INVALID_DATA = 1
+    NEGATIVE_SIZE = 2
+    SIZE_LIMIT = 3
+    BAD_VERSION = 4
+    NOT_IMPLEMENTED = 5
+    DEPTH_LIMIT = 6
 
-  def __init__(self, type=UNKNOWN, message=None):
-    TException.__init__(self, message)
-    self.type = type
+    def __init__(self, type=UNKNOWN, message=None):
+        TException.__init__(self, message)
+        self.type = type
 
 
 class TProtocolBase(object):
-  """Base class for Thrift protocol driver."""
+    """Base class for Thrift protocol driver."""
 
-  def __init__(self, trans):
-    self.trans = trans
+    def __init__(self, trans):
+        self.trans = trans
 
-  @staticmethod
-  def _check_length(limit, length):
-    if length < 0:
-      raise TTransportException(TTransportException.NEGATIVE_SIZE,
-                                'Negative length: %d' % length)
-    if limit is not None and length > limit:
-      raise TTransportException(TTransportException.SIZE_LIMIT,
-                                'Length exceeded max allowed: %d' % limit)
+    @staticmethod
+    def _check_length(limit, length):
+        if length < 0:
+            raise TTransportException(TTransportException.NEGATIVE_SIZE,
+                                      'Negative length: %d' % length)
+        if limit is not None and length > limit:
+            raise TTransportException(TTransportException.SIZE_LIMIT,
+                                      'Length exceeded max allowed: %d' % limit)
 
-  def writeMessageBegin(self, name, ttype, seqid):
-    pass
+    def writeMessageBegin(self, name, ttype, seqid):
+        pass
 
-  def writeMessageEnd(self):
-    pass
+    def writeMessageEnd(self):
+        pass
 
-  def writeStructBegin(self, name):
-    pass
+    def writeStructBegin(self, name):
+        pass
 
-  def writeStructEnd(self):
-    pass
+    def writeStructEnd(self):
+        pass
 
-  def writeFieldBegin(self, name, ttype, fid):
-    pass
+    def writeFieldBegin(self, name, ttype, fid):
+        pass
 
-  def writeFieldEnd(self):
-    pass
+    def writeFieldEnd(self):
+        pass
 
-  def writeFieldStop(self):
-    pass
+    def writeFieldStop(self):
+        pass
 
-  def writeMapBegin(self, ktype, vtype, size):
-    pass
+    def writeMapBegin(self, ktype, vtype, size):
+        pass
 
-  def writeMapEnd(self):
-    pass
+    def writeMapEnd(self):
+        pass
 
-  def writeListBegin(self, etype, size):
-    pass
+    def writeListBegin(self, etype, size):
+        pass
 
-  def writeListEnd(self):
-    pass
+    def writeListEnd(self):
+        pass
 
-  def writeSetBegin(self, etype, size):
-    pass
+    def writeSetBegin(self, etype, size):
+        pass
 
-  def writeSetEnd(self):
-    pass
+    def writeSetEnd(self):
+        pass
 
-  def writeBool(self, bool_val):
-    pass
+    def writeBool(self, bool_val):
+        pass
 
-  def writeByte(self, byte):
-    pass
+    def writeByte(self, byte):
+        pass
 
-  def writeI16(self, i16):
-    pass
+    def writeI16(self, i16):
+        pass
 
-  def writeI32(self, i32):
-    pass
+    def writeI32(self, i32):
+        pass
 
-  def writeI64(self, i64):
-    pass
+    def writeI64(self, i64):
+        pass
 
-  def writeDouble(self, dub):
-    pass
+    def writeDouble(self, dub):
+        pass
 
-  def writeString(self, str_val):
-    self.writeBinary(str_to_binary(str_val))
+    def writeString(self, str_val):
+        self.writeBinary(str_to_binary(str_val))
 
-  def writeBinary(self, str_val):
-    pass
+    def writeBinary(self, str_val):
+        pass
 
-  def writeUtf8(self, str_val):
-    self.writeString(str_val.encode('utf8'))
+    def writeUtf8(self, str_val):
+        self.writeString(str_val.encode('utf8'))
 
-  def readMessageBegin(self):
-    pass
+    def readMessageBegin(self):
+        pass
 
-  def readMessageEnd(self):
-    pass
+    def readMessageEnd(self):
+        pass
 
-  def readStructBegin(self):
-    pass
+    def readStructBegin(self):
+        pass
 
-  def readStructEnd(self):
-    pass
+    def readStructEnd(self):
+        pass
 
-  def readFieldBegin(self):
-    pass
+    def readFieldBegin(self):
+        pass
 
-  def readFieldEnd(self):
-    pass
+    def readFieldEnd(self):
+        pass
 
-  def readMapBegin(self):
-    pass
+    def readMapBegin(self):
+        pass
 
-  def readMapEnd(self):
-    pass
+    def readMapEnd(self):
+        pass
 
-  def readListBegin(self):
-    pass
+    def readListBegin(self):
+        pass
 
-  def readListEnd(self):
-    pass
+    def readListEnd(self):
+        pass
 
-  def readSetBegin(self):
-    pass
+    def readSetBegin(self):
+        pass
 
-  def readSetEnd(self):
-    pass
+    def readSetEnd(self):
+        pass
 
-  def readBool(self):
-    pass
+    def readBool(self):
+        pass
 
-  def readByte(self):
-    pass
+    def readByte(self):
+        pass
 
-  def readI16(self):
-    pass
+    def readI16(self):
+        pass
 
-  def readI32(self):
-    pass
+    def readI32(self):
+        pass
 
-  def readI64(self):
-    pass
+    def readI64(self):
+        pass
 
-  def readDouble(self):
-    pass
+    def readDouble(self):
+        pass
 
-  def readString(self):
-    return binary_to_str(self.readBinary())
+    def readString(self):
+        return binary_to_str(self.readBinary())
 
-  def readBinary(self):
-    pass
+    def readBinary(self):
+        pass
 
-  def readUtf8(self):
-    return self.readString().decode('utf8')
+    def readUtf8(self):
+        return self.readString().decode('utf8')
 
-  def skip(self, ttype):
-    if ttype == TType.STOP:
-      return
-    elif ttype == TType.BOOL:
-      self.readBool()
-    elif ttype == TType.BYTE:
-      self.readByte()
-    elif ttype == TType.I16:
-      self.readI16()
-    elif ttype == TType.I32:
-      self.readI32()
-    elif ttype == TType.I64:
-      self.readI64()
-    elif ttype == TType.DOUBLE:
-      self.readDouble()
-    elif ttype == TType.STRING:
-      self.readString()
-    elif ttype == TType.STRUCT:
-      name = self.readStructBegin()
-      while True:
-        (name, ttype, id) = self.readFieldBegin()
+    def skip(self, ttype):
         if ttype == TType.STOP:
-          break
-        self.skip(ttype)
-        self.readFieldEnd()
-      self.readStructEnd()
-    elif ttype == TType.MAP:
-      (ktype, vtype, size) = self.readMapBegin()
-      for i in range(size):
-        self.skip(ktype)
-        self.skip(vtype)
-      self.readMapEnd()
-    elif ttype == TType.SET:
-      (etype, size) = self.readSetBegin()
-      for i in range(size):
-        self.skip(etype)
-      self.readSetEnd()
-    elif ttype == TType.LIST:
-      (etype, size) = self.readListBegin()
-      for i in range(size):
-        self.skip(etype)
-      self.readListEnd()
+            return
+        elif ttype == TType.BOOL:
+            self.readBool()
+        elif ttype == TType.BYTE:
+            self.readByte()
+        elif ttype == TType.I16:
+            self.readI16()
+        elif ttype == TType.I32:
+            self.readI32()
+        elif ttype == TType.I64:
+            self.readI64()
+        elif ttype == TType.DOUBLE:
+            self.readDouble()
+        elif ttype == TType.STRING:
+            self.readString()
+        elif ttype == TType.STRUCT:
+            name = self.readStructBegin()
+            while True:
+                (name, ttype, id) = self.readFieldBegin()
+                if ttype == TType.STOP:
+                    break
+                self.skip(ttype)
+                self.readFieldEnd()
+            self.readStructEnd()
+        elif ttype == TType.MAP:
+            (ktype, vtype, size) = self.readMapBegin()
+            for i in range(size):
+                self.skip(ktype)
+                self.skip(vtype)
+            self.readMapEnd()
+        elif ttype == TType.SET:
+            (etype, size) = self.readSetBegin()
+            for i in range(size):
+                self.skip(etype)
+            self.readSetEnd()
+        elif ttype == TType.LIST:
+            (etype, size) = self.readListBegin()
+            for i in range(size):
+                self.skip(etype)
+            self.readListEnd()
 
-  # tuple of: ( 'reader method' name, is_container bool, 'writer_method' name )
-  _TTYPE_HANDLERS = (
-       (None, None, False),  # 0 TType.STOP
-       (None, None, False),  # 1 TType.VOID # TODO: handle void?
-       ('readBool', 'writeBool', False),  # 2 TType.BOOL
-       ('readByte', 'writeByte', False),  # 3 TType.BYTE and I08
-       ('readDouble', 'writeDouble', False),  # 4 TType.DOUBLE
-       (None, None, False),  # 5 undefined
-       ('readI16', 'writeI16', False),  # 6 TType.I16
-       (None, None, False),  # 7 undefined
-       ('readI32', 'writeI32', False),  # 8 TType.I32
-       (None, None, False),  # 9 undefined
-       ('readI64', 'writeI64', False),  # 10 TType.I64
-       ('readString', 'writeString', False),  # 11 TType.STRING and UTF7
-       ('readContainerStruct', 'writeContainerStruct', True),  # 12 *.STRUCT
-       ('readContainerMap', 'writeContainerMap', True),  # 13 TType.MAP
-       ('readContainerSet', 'writeContainerSet', True),  # 14 TType.SET
-       ('readContainerList', 'writeContainerList', True),  # 15 TType.LIST
-       (None, None, False),  # 16 TType.UTF8 # TODO: handle utf8 types?
-       (None, None, False)  # 17 TType.UTF16 # TODO: handle utf16 types?
-      )
+    # tuple of: ( 'reader method' name, is_container bool, 'writer_method' name )
+    _TTYPE_HANDLERS = (
+        (None, None, False),  # 0 TType.STOP
+        (None, None, False),  # 1 TType.VOID # TODO: handle void?
+        ('readBool', 'writeBool', False),  # 2 TType.BOOL
+        ('readByte', 'writeByte', False),  # 3 TType.BYTE and I08
+        ('readDouble', 'writeDouble', False),  # 4 TType.DOUBLE
+        (None, None, False),  # 5 undefined
+        ('readI16', 'writeI16', False),  # 6 TType.I16
+        (None, None, False),  # 7 undefined
+        ('readI32', 'writeI32', False),  # 8 TType.I32
+        (None, None, False),  # 9 undefined
+        ('readI64', 'writeI64', False),  # 10 TType.I64
+        ('readString', 'writeString', False),  # 11 TType.STRING and UTF7
+        ('readContainerStruct', 'writeContainerStruct', True),  # 12 *.STRUCT
+        ('readContainerMap', 'writeContainerMap', True),  # 13 TType.MAP
+        ('readContainerSet', 'writeContainerSet', True),  # 14 TType.SET
+        ('readContainerList', 'writeContainerList', True),  # 15 TType.LIST
+        (None, None, False),  # 16 TType.UTF8 # TODO: handle utf8 types?
+        (None, None, False)  # 17 TType.UTF16 # TODO: handle utf16 types?
+    )
 
-  def _ttype_handlers(self, ttype, spec):
-    if spec == 'BINARY':
-      if ttype != TType.STRING:
-        raise TProtocolException(type=TProtocolException.INVALID_DATA,
-                                 message='Invalid binary field type %d' % ttype)
-      return ('readBinary', 'writeBinary', False)
-    if sys.version_info[0] == 2 and spec == 'UTF8':
-      if ttype != TType.STRING:
-        raise TProtocolException(type=TProtocolException.INVALID_DATA,
-                                 message='Invalid string field type %d' % ttype)
-      return ('readUtf8', 'writeUtf8', False)
-    return self._TTYPE_HANDLERS[ttype] if ttype < len(self._TTYPE_HANDLERS) else (None, None, False)
+    def _ttype_handlers(self, ttype, spec):
+        if spec == 'BINARY':
+            if ttype != TType.STRING:
+                raise TProtocolException(type=TProtocolException.INVALID_DATA,
+                                         message='Invalid binary field type %d' % ttype)
+            return ('readBinary', 'writeBinary', False)
+        if sys.version_info[0] == 2 and spec == 'UTF8':
+            if ttype != TType.STRING:
+                raise TProtocolException(type=TProtocolException.INVALID_DATA,
+                                         message='Invalid string field type %d' % ttype)
+            return ('readUtf8', 'writeUtf8', False)
+        return self._TTYPE_HANDLERS[ttype] if ttype < len(self._TTYPE_HANDLERS) else (None, None, False)
 
-  def _read_by_ttype(self, ttype, spec, espec):
-    reader_name, _, is_container = self._ttype_handlers(ttype, spec)
-    if reader_name is None:
-      raise TProtocolException(type=TProtocolException.INVALID_DATA,
-                               message='Invalid type %d' % (ttype))
-    reader_func = getattr(self, reader_name)
-    read = (lambda: reader_func(espec)) if is_container else reader_func
-    while True:
-      yield read()
+    def _read_by_ttype(self, ttype, spec, espec):
+        reader_name, _, is_container = self._ttype_handlers(ttype, spec)
+        if reader_name is None:
+            raise TProtocolException(type=TProtocolException.INVALID_DATA,
+                                     message='Invalid type %d' % (ttype))
+        reader_func = getattr(self, reader_name)
+        read = (lambda: reader_func(espec)) if is_container else reader_func
+        while True:
+            yield read()
 
-  def readFieldByTType(self, ttype, spec):
-    return self._read_by_ttype(ttype, spec, spec).next()
+    def readFieldByTType(self, ttype, spec):
+        return self._read_by_ttype(ttype, spec, spec).next()
 
-  def readContainerList(self, spec):
-    ttype, tspec, is_immutable = spec
-    (list_type, list_len) = self.readListBegin()
-    # TODO: compare types we just decoded with thrift_spec
-    elems = islice(self._read_by_ttype(ttype, spec, tspec), list_len)
-    results = (tuple if is_immutable else list)(elems)
-    self.readListEnd()
-    return results
+    def readContainerList(self, spec):
+        ttype, tspec, is_immutable = spec
+        (list_type, list_len) = self.readListBegin()
+        # TODO: compare types we just decoded with thrift_spec
+        elems = islice(self._read_by_ttype(ttype, spec, tspec), list_len)
+        results = (tuple if is_immutable else list)(elems)
+        self.readListEnd()
+        return results
 
-  def readContainerSet(self, spec):
-    ttype, tspec, is_immutable = spec
-    (set_type, set_len) = self.readSetBegin()
-    # TODO: compare types we just decoded with thrift_spec
-    elems = islice(self._read_by_ttype(ttype, spec, tspec), set_len)
-    results = (frozenset if is_immutable else set)(elems)
-    self.readSetEnd()
-    return results
+    def readContainerSet(self, spec):
+        ttype, tspec, is_immutable = spec
+        (set_type, set_len) = self.readSetBegin()
+        # TODO: compare types we just decoded with thrift_spec
+        elems = islice(self._read_by_ttype(ttype, spec, tspec), set_len)
+        results = (frozenset if is_immutable else set)(elems)
+        self.readSetEnd()
+        return results
 
-  def readContainerStruct(self, spec):
-    (obj_class, obj_spec) = spec
-    obj = obj_class()
-    obj.read(self)
-    return obj
+    def readContainerStruct(self, spec):
+        (obj_class, obj_spec) = spec
+        obj = obj_class()
+        obj.read(self)
+        return obj
 
-  def readContainerMap(self, spec):
-    ktype, kspec, vtype, vspec, is_immutable = spec
-    (map_ktype, map_vtype, map_len) = self.readMapBegin()
-    # TODO: compare types we just decoded with thrift_spec and
-    # abort/skip if types disagree
-    keys = self._read_by_ttype(ktype, spec, kspec)
-    vals = self._read_by_ttype(vtype, spec, vspec)
-    keyvals = islice(zip(keys, vals), map_len)
-    results = (TFrozenDict if is_immutable else dict)(keyvals)
-    self.readMapEnd()
-    return results
+    def readContainerMap(self, spec):
+        ktype, kspec, vtype, vspec, is_immutable = spec
+        (map_ktype, map_vtype, map_len) = self.readMapBegin()
+        # TODO: compare types we just decoded with thrift_spec and
+        # abort/skip if types disagree
+        keys = self._read_by_ttype(ktype, spec, kspec)
+        vals = self._read_by_ttype(vtype, spec, vspec)
+        keyvals = islice(zip(keys, vals), map_len)
+        results = (TFrozenDict if is_immutable else dict)(keyvals)
+        self.readMapEnd()
+        return results
 
-  def readStruct(self, obj, thrift_spec, is_immutable=False):
-    if is_immutable:
-      fields = {}
-    self.readStructBegin()
-    while True:
-      (fname, ftype, fid) = self.readFieldBegin()
-      if ftype == TType.STOP:
-        break
-      try:
-        field = thrift_spec[fid]
-      except IndexError:
-        self.skip(ftype)
-      else:
-        if field is not None and ftype == field[1]:
-          fname = field[2]
-          fspec = field[3]
-          val = self.readFieldByTType(ftype, fspec)
-          if is_immutable:
-            fields[fname] = val
-          else:
-            setattr(obj, fname, val)
-        else:
-          self.skip(ftype)
-      self.readFieldEnd()
-    self.readStructEnd()
-    if is_immutable:
-      return obj(**fields)
+    def readStruct(self, obj, thrift_spec, is_immutable=False):
+        if is_immutable:
+            fields = {}
+        self.readStructBegin()
+        while True:
+            (fname, ftype, fid) = self.readFieldBegin()
+            if ftype == TType.STOP:
+                break
+            try:
+                field = thrift_spec[fid]
+            except IndexError:
+                self.skip(ftype)
+            else:
+                if field is not None and ftype == field[1]:
+                    fname = field[2]
+                    fspec = field[3]
+                    val = self.readFieldByTType(ftype, fspec)
+                    if is_immutable:
+                        fields[fname] = val
+                    else:
+                        setattr(obj, fname, val)
+                else:
+                    self.skip(ftype)
+            self.readFieldEnd()
+        self.readStructEnd()
+        if is_immutable:
+            return obj(**fields)
 
-  def writeContainerStruct(self, val, spec):
-    val.write(self)
+    def writeContainerStruct(self, val, spec):
+        val.write(self)
 
-  def writeContainerList(self, val, spec):
-    ttype, tspec, _ = spec
-    self.writeListBegin(ttype, len(val))
-    for _ in self._write_by_ttype(ttype, val, spec, tspec):
-      pass
-    self.writeListEnd()
+    def writeContainerList(self, val, spec):
+        ttype, tspec, _ = spec
+        self.writeListBegin(ttype, len(val))
+        for _ in self._write_by_ttype(ttype, val, spec, tspec):
+            pass
+        self.writeListEnd()
 
-  def writeContainerSet(self, val, spec):
-    ttype, tspec, _ = spec
-    self.writeSetBegin(ttype, len(val))
-    for _ in self._write_by_ttype(ttype, val, spec, tspec):
-      pass
-    self.writeSetEnd()
+    def writeContainerSet(self, val, spec):
+        ttype, tspec, _ = spec
+        self.writeSetBegin(ttype, len(val))
+        for _ in self._write_by_ttype(ttype, val, spec, tspec):
+            pass
+        self.writeSetEnd()
 
-  def writeContainerMap(self, val, spec):
-    ktype, kspec, vtype, vspec, _ = spec
-    self.writeMapBegin(ktype, vtype, len(val))
-    for _ in zip(self._write_by_ttype(ktype, six.iterkeys(val), spec, kspec),
-                 self._write_by_ttype(vtype, six.itervalues(val), spec, vspec)):
-      pass
-    self.writeMapEnd()
+    def writeContainerMap(self, val, spec):
+        ktype, kspec, vtype, vspec, _ = spec
+        self.writeMapBegin(ktype, vtype, len(val))
+        for _ in zip(self._write_by_ttype(ktype, six.iterkeys(val), spec, kspec),
+                     self._write_by_ttype(vtype, six.itervalues(val), spec, vspec)):
+            pass
+        self.writeMapEnd()
 
-  def writeStruct(self, obj, thrift_spec):
-    self.writeStructBegin(obj.__class__.__name__)
-    for field in thrift_spec:
-      if field is None:
-        continue
-      fname = field[2]
-      val = getattr(obj, fname)
-      if val is None:
-        # skip writing out unset fields
-        continue
-      fid = field[0]
-      ftype = field[1]
-      fspec = field[3]
-      self.writeFieldBegin(fname, ftype, fid)
-      self.writeFieldByTType(ftype, val, fspec)
-      self.writeFieldEnd()
-    self.writeFieldStop()
-    self.writeStructEnd()
+    def writeStruct(self, obj, thrift_spec):
+        self.writeStructBegin(obj.__class__.__name__)
+        for field in thrift_spec:
+            if field is None:
+                continue
+            fname = field[2]
+            val = getattr(obj, fname)
+            if val is None:
+                # skip writing out unset fields
+                continue
+            fid = field[0]
+            ftype = field[1]
+            fspec = field[3]
+            self.writeFieldBegin(fname, ftype, fid)
+            self.writeFieldByTType(ftype, val, fspec)
+            self.writeFieldEnd()
+        self.writeFieldStop()
+        self.writeStructEnd()
 
-  def _write_by_ttype(self, ttype, vals, spec, espec):
-    _, writer_name, is_container = self._ttype_handlers(ttype, spec)
-    writer_func = getattr(self, writer_name)
-    write = (lambda v: writer_func(v, espec)) if is_container else writer_func
-    for v in vals:
-      yield write(v)
+    def _write_by_ttype(self, ttype, vals, spec, espec):
+        _, writer_name, is_container = self._ttype_handlers(ttype, spec)
+        writer_func = getattr(self, writer_name)
+        write = (lambda v: writer_func(v, espec)) if is_container else writer_func
+        for v in vals:
+            yield write(v)
 
-  def writeFieldByTType(self, ttype, val, spec):
-    self._write_by_ttype(ttype, [val], spec, spec).next()
+    def writeFieldByTType(self, ttype, val, spec):
+        self._write_by_ttype(ttype, [val], spec, spec).next()
 
 
 def checkIntegerLimits(i, bits):
@@ -408,10 +408,10 @@
         raise TProtocolException(TProtocolException.INVALID_DATA,
                                  "i32 requires -2147483648 <= number <= 2147483647")
     elif bits == 64 and (i < -9223372036854775808 or i > 9223372036854775807):
-         raise TProtocolException(TProtocolException.INVALID_DATA,
-                                  "i64 requires -9223372036854775808 <= number <= 9223372036854775807")
+        raise TProtocolException(TProtocolException.INVALID_DATA,
+                                 "i64 requires -9223372036854775808 <= number <= 9223372036854775807")
 
 
 class TProtocolFactory(object):
-  def getProtocol(self, trans):
-    pass
+    def getProtocol(self, trans):
+        pass
diff --git a/lib/py/src/protocol/TProtocolDecorator.py b/lib/py/src/protocol/TProtocolDecorator.py
index bf50bfa..8b270a4 100644
--- a/lib/py/src/protocol/TProtocolDecorator.py
+++ b/lib/py/src/protocol/TProtocolDecorator.py
@@ -17,26 +17,34 @@
 # under the License.
 #
 
+import types
+
 from thrift.protocol.TProtocol import TProtocolBase
-from types import *
+
 
 class TProtocolDecorator():
-  def __init__(self, protocol):
-    TProtocolBase(protocol)
-    self.protocol = protocol
+    def __init__(self, protocol):
+        TProtocolBase(protocol)
+        self.protocol = protocol
 
-  def __getattr__(self, name):
-    if hasattr(self.protocol, name):
-      member = getattr(self.protocol, name)
-      if type(member) in [MethodType, FunctionType, LambdaType, BuiltinFunctionType, BuiltinMethodType]:
-        return lambda *args, **kwargs: self._wrap(member, args, kwargs)
-      else:
-        return member
-    raise AttributeError(name)
+    def __getattr__(self, name):
+        if hasattr(self.protocol, name):
+            member = getattr(self.protocol, name)
+            if type(member) in [
+                types.MethodType,
+                types.FunctionType,
+                types.LambdaType,
+                types.BuiltinFunctionType,
+                types.BuiltinMethodType,
+            ]:
+                return lambda *args, **kwargs: self._wrap(member, args, kwargs)
+            else:
+                return member
+        raise AttributeError(name)
 
-  def _wrap(self, func, args, kwargs):
-    if type(func) == MethodType:
-      result = func(*args, **kwargs)
-    else:
-      result = func(self.protocol, *args, **kwargs)
-    return result
+    def _wrap(self, func, args, kwargs):
+        if isinstance(func, types.MethodType):
+            result = func(*args, **kwargs)
+        else:
+            result = func(self.protocol, *args, **kwargs)
+        return result
diff --git a/lib/py/src/protocol/__init__.py b/lib/py/src/protocol/__init__.py
index 7eefb45..7148f66 100644
--- a/lib/py/src/protocol/__init__.py
+++ b/lib/py/src/protocol/__init__.py
@@ -17,4 +17,5 @@
 # under the License.
 #
 
-__all__ = ['fastbinary', 'TBase', 'TBinaryProtocol', 'TCompactProtocol', 'TJSONProtocol', 'TProtocol']
+__all__ = ['fastbinary', 'TBase', 'TBinaryProtocol', 'TCompactProtocol',
+           'TJSONProtocol', 'TProtocol']
