THRIFT-1480. py: remove tabs, adjust whitespace and address PEP8 warnings
This patch addresses a host of PEP8 lint problems.
Patch: Will Pierce
git-svn-id: https://svn.apache.org/repos/asf/thrift/trunk@1226890 13f79535-47bb-0310-9956-ffa450edef68
diff --git a/lib/py/src/Thrift.py b/lib/py/src/Thrift.py
index 1d271fc..707a8cc 100644
--- a/lib/py/src/Thrift.py
+++ b/lib/py/src/Thrift.py
@@ -19,6 +19,7 @@
import sys
+
class TType:
STOP = 0
VOID = 1
@@ -38,7 +39,7 @@
UTF8 = 16
UTF16 = 17
- _VALUES_TO_NAMES = ( 'STOP',
+ _VALUES_TO_NAMES = ('STOP',
'VOID',
'BOOL',
'BYTE',
@@ -48,46 +49,48 @@
None,
'I32',
None,
- 'I64',
- 'STRING',
- 'STRUCT',
- 'MAP',
- 'SET',
- 'LIST',
- 'UTF8',
- 'UTF16' )
+ 'I64',
+ 'STRING',
+ 'STRUCT',
+ 'MAP',
+ 'SET',
+ 'LIST',
+ 'UTF8',
+ 'UTF16')
+
class TMessageType:
- CALL = 1
+ CALL = 1
REPLY = 2
EXCEPTION = 3
ONEWAY = 4
-class TProcessor:
+class TProcessor:
"""Base class for procsessor, which works on two streams."""
def process(iprot, oprot):
pass
-class TException(Exception):
+class TException(Exception):
"""Base class for all thrift exceptions."""
# BaseException.message is deprecated in Python v[2.6,3.0)
- if (2,6,0) <= sys.version_info < (3,0):
+ if (2, 6, 0) <= sys.version_info < (3, 0):
def _get_message(self):
- return self._message
+ return self._message
+
def _set_message(self, message):
- self._message = message
+ self._message = message
message = property(_get_message, _set_message)
def __init__(self, message=None):
Exception.__init__(self, message)
self.message = message
-class TApplicationException(TException):
+class TApplicationException(TException):
"""Application level thrift exceptions."""
UNKNOWN = 0
@@ -127,12 +130,12 @@
break
if fid == 1:
if ftype == TType.STRING:
- self.message = iprot.readString();
+ self.message = iprot.readString()
else:
iprot.skip(ftype)
elif fid == 2:
if ftype == TType.I32:
- self.type = iprot.readI32();
+ self.type = iprot.readI32()
else:
iprot.skip(ftype)
else:
@@ -142,11 +145,11 @@
def write(self, oprot):
oprot.writeStructBegin('TApplicationException')
- if self.message != None:
+ if self.message is not None:
oprot.writeFieldBegin('message', TType.STRING, 1)
oprot.writeString(self.message)
oprot.writeFieldEnd()
- if self.type != None:
+ if self.type is not None:
oprot.writeFieldBegin('type', TType.I32, 2)
oprot.writeI32(self.type)
oprot.writeFieldEnd()