<s> from thrift . Thrift import TType , TMessageType , TException , TApplicationException <EOL> from thrift . transport import TTransport <EOL> from thrift . protocol import TBinaryProtocol , TProtocol <EOL> try : <EOL> from thrift . protocol import fastbinary <EOL> except : <EOL> fastbinary = None <EOL> class TestEnum ( object ) : <EOL> ENUM_ONE = <NUM_LIT:0> <EOL> ENUM_TWO = <NUM_LIT:1> <EOL> ENUM_THREE = <NUM_LIT:2> <EOL> _VALUES_TO_NAMES = { <EOL> <NUM_LIT:0> : "<STR_LIT>" , <EOL> <NUM_LIT:1> : "<STR_LIT>" , <EOL> <NUM_LIT:2> : "<STR_LIT>" , <EOL> } <EOL> _NAMES_TO_VALUES = { <EOL> "<STR_LIT>" : <NUM_LIT:0> , <EOL> "<STR_LIT>" : <NUM_LIT:1> , <EOL> "<STR_LIT>" : <NUM_LIT:2> , <EOL> } <EOL> class TestStruct ( object ) : <EOL> """<STR_LIT>""" <EOL> thrift_spec = ( <EOL> None , <EOL> ( <NUM_LIT:1> , TType . STRING , '<STR_LIT:a>' , None , None , ) , <EOL> ( <NUM_LIT:2> , TType . I32 , '<STR_LIT:b>' , None , None , ) , <EOL> ) <EOL> def __init__ ( self , a = None , b = None , ) : <EOL> self . a = a <EOL> self . b = b <EOL> def read ( self , iprot ) : <EOL> if iprot . __class__ == TBinaryProtocol . TBinaryProtocolAccelerated and isinstance ( iprot . trans , TTransport . CReadableTransport ) and self . thrift_spec is not None and fastbinary is not None : <EOL> fastbinary . decode_binary ( self , iprot . trans , ( self . __class__ , self . thrift_spec ) ) <EOL> return <EOL> iprot . readStructBegin ( ) <EOL> while True : <EOL> ( fname , ftype , fid ) = iprot . readFieldBegin ( ) <EOL> if ftype == TType . STOP : <EOL> break <EOL> if fid == <NUM_LIT:1> : <EOL> if ftype == TType . STRING : <EOL> self . a = iprot . readString ( ) ; <EOL> else : <EOL> iprot . skip ( ftype ) <EOL> elif fid == <NUM_LIT:2> : <EOL> if ftype == TType . I32 : <EOL> self . b = iprot . readI32 ( ) ; <EOL> else : <EOL> iprot . skip ( ftype ) <EOL> else : <EOL> iprot . skip ( ftype ) <EOL> iprot . readFieldEnd ( ) <EOL> iprot . readStructEnd ( ) <EOL> def write ( self , oprot ) : <EOL> if oprot . __class__ == TBinaryProtocol . TBinaryProtocolAccelerated and self . thrift_spec is not None and fastbinary is not None : <EOL> oprot . trans . write ( fastbinary . encode_binary ( self , ( self . __class__ , self . thrift_spec ) ) ) <EOL> return <EOL> oprot . writeStructBegin ( '<STR_LIT>' ) <EOL> if self . a is not None : <EOL> oprot . writeFieldBegin ( '<STR_LIT:a>' , TType . STRING , <NUM_LIT:1> ) <EOL> oprot . writeString ( self . a ) <EOL> oprot . writeFieldEnd ( ) <EOL> if self . b is not None : <EOL> oprot . writeFieldBegin ( '<STR_LIT:b>' , TType . I32 , <NUM_LIT:2> ) <EOL> oprot . writeI32 ( self . b ) <EOL> oprot . writeFieldEnd ( ) <EOL> oprot . writeFieldStop ( ) <EOL> oprot . writeStructEnd ( ) <EOL> def validate ( self ) : <EOL> return <EOL> def __repr__ ( self ) : <EOL> L = [ '<STR_LIT>' % ( key , value ) <EOL> for key , value in self . __dict__ . iteritems ( ) ] <EOL> return '<STR_LIT>' % ( self . __class__ . __name__ , '<STR_LIT:U+002CU+0020>' . join ( L ) ) <EOL> def __eq__ ( self , other ) : <EOL> return isinstance ( other , self . __class__ ) and self . __dict__ == other . __dict__ <EOL> def __ne__ ( self , other ) : <EOL> return not ( self == other ) <EOL> class TestNesting ( object ) : <EOL> """<STR_LIT>""" <EOL> thrift_spec = ( <EOL> None , <EOL> ( <NUM_LIT:1> , TType . STRUCT , '<STR_LIT>' , ( TestStruct , TestStruct . thrift_spec ) , None , ) , <EOL> ( <NUM_LIT:2> , TType . I32 , '<STR_LIT:b>' , None , None , ) , <EOL> ) <EOL> def __init__ ( self , nested_struct = None , b = None , ) : <EOL> self . nested_struct = nested_struct <EOL> self . b = b <EOL> def read ( self , iprot ) : <EOL> if iprot . __class__ == TBinaryProtocol . TBinaryProtocolAccelerated and isinstance ( iprot . trans , TTransport . CReadableTransport ) and self . thrift_spec is not None and fastbinary is not None : <EOL> fastbinary . decode_binary ( self , iprot . trans , ( self . __class__ , self . thrift_spec ) ) <EOL> return <EOL> iprot . readStructBegin ( ) <EOL> while True : <EOL> ( fname , ftype , fid ) = iprot . readFieldBegin ( ) <EOL> if ftype == TType . STOP : <EOL> break <EOL> if fid == <NUM_LIT:1> : <EOL> if ftype == TType . STRUCT : <EOL> self . nested_struct = TestStruct ( ) <EOL> self . nested_struct . read ( iprot ) <EOL> else : <EOL> iprot . skip ( ftype ) <EOL> elif fid == <NUM_LIT:2> : <EOL> if ftype == TType . I32 : <EOL> self . b = iprot . readI32 ( ) ; <EOL> else : <EOL> iprot . skip ( ftype ) <EOL> else : <EOL> iprot . skip ( ftype ) <EOL> iprot . readFieldEnd ( ) <EOL> iprot . readStructEnd ( ) <EOL> def write ( self , oprot ) : <EOL> if oprot . __class__ == TBinaryProtocol . TBinaryProtocolAccelerated and self . thrift_spec is not None and fastbinary is not None : <EOL> oprot . trans . write ( fastbinary . encode_binary ( self , ( self . __class__ , self . thrift_spec ) ) ) <EOL> return <EOL> oprot . writeStructBegin ( '<STR_LIT>' ) <EOL> if self . nested_struct is not None : <EOL> oprot . writeFieldBegin ( '<STR_LIT>' , TType . STRUCT , <NUM_LIT:1> ) <EOL> self . nested_struct . write ( oprot ) <EOL> oprot . writeFieldEnd ( ) <EOL> if self . b is not None : <EOL> oprot . writeFieldBegin ( '<STR_LIT:b>' , TType . I32 , <NUM_LIT:2> ) <EOL> oprot . writeI32 ( self . b ) <EOL> oprot . writeFieldEnd ( ) <EOL> oprot . writeFieldStop ( ) <EOL> oprot . writeStructEnd ( ) <EOL> def validate ( self ) : <EOL> return <EOL> def __repr__ ( self ) : <EOL> L = [ '<STR_LIT>' % ( key , value ) <EOL> for key , value in self . __dict__ . iteritems ( ) ] <EOL> return '<STR_LIT>' % ( self . __class__ . __name__ , '<STR_LIT:U+002CU+0020>' . join ( L ) ) <EOL> def __eq__ ( self , other ) : <EOL> return isinstance ( other , self . __class__ ) and self . __dict__ == other . __dict__ <EOL> def __ne__ ( self , other ) : <EOL> return not ( self == other ) <EOL> class TestManyTypes ( object ) : <EOL> """<STR_LIT>""" <EOL> thrift_spec = ( <EOL> None , <EOL> ( <NUM_LIT:1> , TType . BOOL , '<STR_LIT>' , None , None , ) , <EOL> ( <NUM_LIT:2> , TType . BYTE , '<STR_LIT>' , None , None , ) , <EOL> ( <NUM_LIT:3> , TType . I16 , '<STR_LIT>' , None , None , ) , <EOL> ( <NUM_LIT:4> , TType . I32 , '<STR_LIT>' , None , None , ) , <EOL> ( <NUM_LIT:5> , TType . I64 , '<STR_LIT>' , None , None , ) , <EOL> ( <NUM_LIT:6> , TType . DOUBLE , '<STR_LIT>' , None , None , ) , <EOL> ( <NUM_LIT:7> , TType . STRING , '<STR_LIT>' , None , None , ) , <EOL> ( <NUM_LIT:8> , TType . STRING , '<STR_LIT>' , None , None , ) , <EOL> ( <NUM_LIT:9> , TType . I32 , '<STR_LIT>' , None , None , ) , <EOL> ( <NUM_LIT:10> , TType . STRUCT , '<STR_LIT>' , ( TestStruct , TestStruct . thrift_spec ) , None , ) , <EOL> ( <NUM_LIT:11> , TType . SET , '<STR_LIT>' , ( TType . I32 , None ) , None , ) , <EOL> ( <NUM_LIT:12> , TType . LIST , '<STR_LIT>' , ( TType . STRUCT , ( TestStruct , TestStruct . thrift_spec ) ) , None , ) , <EOL> ( <NUM_LIT> , TType . MAP , '<STR_LIT>' , ( TType . I32 , None , TType . STRUCT , ( TestStruct , TestStruct . thrift_spec ) ) , None , ) , <EOL> ( <NUM_LIT> , TType . STRING , '<STR_LIT>' , None , "<STR_LIT>" , ) , <EOL> ( <NUM_LIT:15> , TType . LIST , '<STR_LIT>' , ( TType . STRING , None ) , None , ) , <EOL> ) <EOL> def __init__ ( self , a_bool = None , a_byte = None , a_i16 = None , a_i32 = None , a_i64 = None , a_double = None , a_string = None , a_binary = None , a_enum = None , a_struct = None , a_set = None , a_list = None , a_map = None , a_string_with_default = thrift_spec [ <NUM_LIT> ] [ <NUM_LIT:4> ] , a_string_list = None , ) : <EOL> self . a_bool = a_bool <EOL> self . a_byte = a_byte <EOL> self . a_i16 = a_i16 <EOL> self . a_i32 = a_i32 <EOL> self . a_i64 = a_i64 <EOL> self . a_double = a_double <EOL> self . a_string = a_string <EOL> self . a_binary = a_binary <EOL> self . a_enum = a_enum <EOL> self . a_struct = a_struct <EOL> self . a_set = a_set <EOL> self . a_list = a_list <EOL> self . a_map = a_map <EOL> self . a_string_with_default = a_string_with_default <EOL> self . a_string_list = a_string_list <EOL> def read ( self , iprot ) : <EOL> if iprot . __class__ == TBinaryProtocol . TBinaryProtocolAccelerated and isinstance ( iprot . trans , TTransport . CReadableTransport ) and self . thrift_spec is not None and fastbinary is not None : <EOL> fastbinary . decode_binary ( self , iprot . trans , ( self . __class__ , self . thrift_spec ) ) <EOL> return <EOL> iprot . readStructBegin ( ) <EOL> while True : <EOL> ( fname , ftype , fid ) = iprot . readFieldBegin ( ) <EOL> if ftype == TType . STOP : <EOL> break <EOL> if fid == <NUM_LIT:1> : <EOL> if ftype == TType . BOOL : <EOL> self . a_bool = iprot . readBool ( ) ; <EOL> else : <EOL> iprot . skip ( ftype ) <EOL> elif fid == <NUM_LIT:2> : <EOL> if ftype == TType . BYTE : <EOL> self . a_byte = iprot . readByte ( ) ; <EOL> else : <EOL> iprot . skip ( ftype ) <EOL> elif fid == <NUM_LIT:3> : <EOL> if ftype == TType . I16 : <EOL> self . a_i16 = iprot . readI16 ( ) ; <EOL> else : <EOL> iprot . skip ( ftype ) <EOL> elif fid == <NUM_LIT:4> : <EOL> if ftype == TType . I32 : <EOL> self . a_i32 = iprot . readI32 ( ) ; <EOL> else : <EOL> iprot . skip ( ftype ) <EOL> elif fid == <NUM_LIT:5> : <EOL> if ftype == TType . I64 : <EOL> self . a_i64 = iprot . readI64 ( ) ; <EOL> else : <EOL> iprot . skip ( ftype ) <EOL> elif fid == <NUM_LIT:6> : <EOL> if ftype == TType . DOUBLE : <EOL> self . a_double = iprot . readDouble ( ) ; <EOL> else : <EOL> iprot . skip ( ftype ) <EOL> elif fid == <NUM_LIT:7> : <EOL> if ftype == TType . STRING : <EOL> self . a_string = iprot . readString ( ) ; <EOL> else : <EOL> iprot . skip ( ftype ) <EOL> elif fid == <NUM_LIT:8> : <EOL> if ftype == TType . STRING : <EOL> self . a_binary = iprot . readString ( ) ; <EOL> else : <EOL> iprot . skip ( ftype ) <EOL> elif fid == <NUM_LIT:9> : <EOL> if ftype == TType . I32 : <EOL> self . a_enum = iprot . readI32 ( ) ; <EOL> else : <EOL> iprot . skip ( ftype ) <EOL> elif fid == <NUM_LIT:10> : <EOL> if ftype == TType . STRUCT : <EOL> self . a_struct = TestStruct ( ) <EOL> self . a_struct . read ( iprot ) <EOL> else : <EOL> iprot . skip ( ftype ) <EOL> elif fid == <NUM_LIT:11> : <EOL> if ftype == TType . SET : <EOL> self . a_set = set ( ) <EOL> ( _etype3 , _size0 ) = iprot . readSetBegin ( ) <EOL> for _i4 in xrange ( _size0 ) : <EOL> _elem5 = iprot . readI32 ( ) ; <EOL> self . a_set . add ( _elem5 ) <EOL> iprot . readSetEnd ( ) <EOL> else : <EOL> iprot . skip ( ftype ) <EOL> elif fid == <NUM_LIT:12> : <EOL> if ftype == TType . LIST : <EOL> self . a_list = [ ] <EOL> ( _etype9 , _size6 ) = iprot . readListBegin ( ) <EOL> for _i10 in xrange ( _size6 ) : <EOL> _elem11 = TestStruct ( ) <EOL> _elem11 . read ( iprot ) <EOL> self . a_list . append ( _elem11 ) <EOL> iprot . readListEnd ( ) <EOL> else : <EOL> iprot . skip ( ftype ) <EOL> elif fid == <NUM_LIT> : <EOL> if ftype == TType . MAP : <EOL> self . a_map = { } <EOL> ( _ktype13 , _vtype14 , _size12 ) = iprot . readMapBegin ( ) <EOL> for _i16 in xrange ( _size12 ) : <EOL> _key17 = iprot . readI32 ( ) ; <EOL> _val18 = TestStruct ( ) <EOL> _val18 . read ( iprot ) <EOL> self . a_map [ _key17 ] = _val18 <EOL> iprot . readMapEnd ( ) <EOL> else : <EOL> iprot . skip ( ftype ) <EOL> elif fid == <NUM_LIT> : <EOL> if ftype == TType . STRING : <EOL> self . a_string_with_default = iprot . readString ( ) ; <EOL> else : <EOL> iprot . skip ( ftype ) <EOL> elif fid == <NUM_LIT:15> : <EOL> if ftype == TType . LIST : <EOL> self . a_string_list = [ ] <EOL> ( _etype22 , _size19 ) = iprot . readListBegin ( ) <EOL> for _i23 in xrange ( _size19 ) : <EOL> _elem24 = iprot . readString ( ) ; <EOL> self . a_string_list . append ( _elem24 ) <EOL> iprot . readListEnd ( ) <EOL> else : <EOL> iprot . skip ( ftype ) <EOL> else : <EOL> iprot . skip ( ftype ) <EOL> iprot . readFieldEnd ( ) <EOL> iprot . readStructEnd ( ) <EOL> def write ( self , oprot ) : <EOL> if oprot . __class__ == TBinaryProtocol . TBinaryProtocolAccelerated and self . thrift_spec is not None and fastbinary is not None : <EOL> oprot . trans . write ( fastbinary . encode_binary ( self , ( self . __class__ , self . thrift_spec ) ) ) <EOL> return <EOL> oprot . writeStructBegin ( '<STR_LIT>' ) <EOL> if self . a_bool is not None : <EOL> oprot . writeFieldBegin ( '<STR_LIT>' , TType . BOOL , <NUM_LIT:1> ) <EOL> oprot . writeBool ( self . a_bool ) <EOL> oprot . writeFieldEnd ( ) <EOL> if self . a_byte is not None : <EOL> oprot . writeFieldBegin ( '<STR_LIT>' , TType . BYTE , <NUM_LIT:2> ) <EOL> oprot . writeByte ( self . a_byte ) <EOL> oprot . writeFieldEnd ( ) <EOL> if self . a_i16 is not None : <EOL> oprot . writeFieldBegin ( '<STR_LIT>' , TType . I16 , <NUM_LIT:3> ) <EOL> oprot . writeI16 ( self . a_i16 ) <EOL> oprot . writeFieldEnd ( ) <EOL> if self . a_i32 is not None : <EOL> oprot . writeFieldBegin ( '<STR_LIT>' , TType . I32 , <NUM_LIT:4> ) <EOL> oprot . writeI32 ( self . a_i32 ) <EOL> oprot . writeFieldEnd ( ) <EOL> if self . a_i64 is not None : <EOL> oprot . writeFieldBegin ( '<STR_LIT>' , TType . I64 , <NUM_LIT:5> ) <EOL> oprot . writeI64 ( self . a_i64 ) <EOL> oprot . writeFieldEnd ( ) <EOL> if self . a_double is not None : <EOL> oprot . writeFieldBegin ( '<STR_LIT>' , TType . DOUBLE , <NUM_LIT:6> ) <EOL> oprot . writeDouble ( self . a_double ) <EOL> oprot . writeFieldEnd ( ) <EOL> if self . a_string is not None : <EOL> oprot . writeFieldBegin ( '<STR_LIT>' , TType . STRING , <NUM_LIT:7> ) <EOL> oprot . writeString ( self . a_string ) <EOL> oprot . writeFieldEnd ( ) <EOL> if self . a_binary is not None : <EOL> oprot . writeFieldBegin ( '<STR_LIT>' , TType . STRING , <NUM_LIT:8> ) <EOL> oprot . writeString ( self . a_binary ) <EOL> oprot . writeFieldEnd ( ) <EOL> if self . a_enum is not None : <EOL> oprot . writeFieldBegin ( '<STR_LIT>' , TType . I32 , <NUM_LIT:9> ) <EOL> oprot . writeI32 ( self . a_enum ) <EOL> oprot . writeFieldEnd ( ) <EOL> if self . a_struct is not None : <EOL> oprot . writeFieldBegin ( '<STR_LIT>' , TType . STRUCT , <NUM_LIT:10> ) <EOL> self . a_struct . write ( oprot ) <EOL> oprot . writeFieldEnd ( ) <EOL> if self . a_set is not None : <EOL> oprot . writeFieldBegin ( '<STR_LIT>' , TType . SET , <NUM_LIT:11> ) <EOL> oprot . writeSetBegin ( TType . I32 , len ( self . a_set ) ) <EOL> for iter25 in self . a_set : <EOL> oprot . writeI32 ( iter25 ) <EOL> oprot . writeSetEnd ( ) <EOL> oprot . writeFieldEnd ( ) <EOL> if self . a_list is not None : <EOL> oprot . writeFieldBegin ( '<STR_LIT>' , TType . LIST , <NUM_LIT:12> ) <EOL> oprot . writeListBegin ( TType . STRUCT , len ( self . a_list ) ) <EOL> for iter26 in self . a_list : <EOL> iter26 . write ( oprot ) <EOL> oprot . writeListEnd ( ) <EOL> oprot . writeFieldEnd ( ) <EOL> if self . a_map is not None : <EOL> oprot . writeFieldBegin ( '<STR_LIT>' , TType . MAP , <NUM_LIT> ) <EOL> oprot . writeMapBegin ( TType . I32 , TType . STRUCT , len ( self . a_map ) ) <EOL> for kiter27 , viter28 in self . a_map . items ( ) : <EOL> oprot . writeI32 ( kiter27 ) <EOL> viter28 . write ( oprot ) <EOL> oprot . writeMapEnd ( ) <EOL> oprot . writeFieldEnd ( ) <EOL> if self . a_string_with_default is not None : <EOL> oprot . writeFieldBegin ( '<STR_LIT>' , TType . STRING , <NUM_LIT> ) <EOL> oprot . writeString ( self . a_string_with_default ) <EOL> oprot . writeFieldEnd ( ) <EOL> if self . a_string_list is not None : <EOL> oprot . writeFieldBegin ( '<STR_LIT>' , TType . LIST , <NUM_LIT:15> ) <EOL> oprot . writeListBegin ( TType . STRING , len ( self . a_string_list ) ) <EOL> for iter29 in self . a_string_list : <EOL> oprot . writeString ( iter29 ) <EOL> oprot . writeListEnd ( ) <EOL> oprot . writeFieldEnd ( ) <EOL> oprot . writeFieldStop ( ) <EOL> oprot . writeStructEnd ( ) <EOL> def validate ( self ) : <EOL> return <EOL> def __repr__ ( self ) : <EOL> L = [ '<STR_LIT>' % ( key , value ) <EOL> for key , value in self . __dict__ . iteritems ( ) ] <EOL> return '<STR_LIT>' % ( self . __class__ . __name__ , '<STR_LIT:U+002CU+0020>' . join ( L ) ) <EOL> def __eq__ ( self , other ) : <EOL> return isinstance ( other , self . __class__ ) and self . __dict__ == other . __dict__ <EOL> def __ne__ ( self , other ) : <EOL> return not ( self == other ) </s>
