<s> from thrift . Thrift import TType , TMessageType , TException , TApplicationException <EOL> from ttypes import * <EOL> from thrift . Thrift import TProcessor <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 Iface ( object ) : <EOL> def foo ( self ) : <EOL> pass <EOL> class Client ( Iface ) : <EOL> def __init__ ( self , iprot , oprot = None ) : <EOL> self . _iprot = self . _oprot = iprot <EOL> if oprot is not None : <EOL> self . _oprot = oprot <EOL> self . _seqid = <NUM_LIT:0> <EOL> def foo ( self ) : <EOL> self . send_foo ( ) <EOL> return self . recv_foo ( ) <EOL> def send_foo ( self ) : <EOL> self . _oprot . writeMessageBegin ( '<STR_LIT:foo>' , TMessageType . CALL , self . _seqid ) <EOL> args = foo_args ( ) <EOL> args . write ( self . _oprot ) <EOL> self . _oprot . writeMessageEnd ( ) <EOL> self . _oprot . trans . flush ( ) <EOL> def recv_foo ( self ) : <EOL> ( fname , mtype , rseqid ) = self . _iprot . readMessageBegin ( ) <EOL> if mtype == TMessageType . EXCEPTION : <EOL> x = TApplicationException ( ) <EOL> x . read ( self . _iprot ) <EOL> self . _iprot . readMessageEnd ( ) <EOL> raise x <EOL> result = foo_result ( ) <EOL> result . read ( self . _iprot ) <EOL> self . _iprot . readMessageEnd ( ) <EOL> if result . success is not None : <EOL> return result . success <EOL> raise TApplicationException ( TApplicationException . MISSING_RESULT , "<STR_LIT>" ) ; <EOL> class Processor ( Iface , TProcessor ) : <EOL> def __init__ ( self , handler ) : <EOL> self . _handler = handler <EOL> self . _processMap = { } <EOL> self . _processMap [ "<STR_LIT:foo>" ] = Processor . process_foo <EOL> def process ( self , iprot , oprot ) : <EOL> ( name , type , seqid ) = iprot . readMessageBegin ( ) <EOL> if name not in self . _processMap : <EOL> iprot . skip ( TType . STRUCT ) <EOL> iprot . readMessageEnd ( ) <EOL> x = TApplicationException ( TApplicationException . UNKNOWN_METHOD , '<STR_LIT>' % ( name ) ) <EOL> oprot . writeMessageBegin ( name , TMessageType . EXCEPTION , seqid ) <EOL> x . write ( oprot ) <EOL> oprot . writeMessageEnd ( ) <EOL> oprot . trans . flush ( ) <EOL> return <EOL> else : <EOL> self . _processMap [ name ] ( self , seqid , iprot , oprot ) <EOL> return True <EOL> def process_foo ( self , seqid , iprot , oprot ) : <EOL> args = foo_args ( ) <EOL> args . read ( iprot ) <EOL> iprot . readMessageEnd ( ) <EOL> result = foo_result ( ) <EOL> result . success = self . _handler . foo ( ) <EOL> oprot . writeMessageBegin ( "<STR_LIT:foo>" , TMessageType . REPLY , seqid ) <EOL> result . write ( oprot ) <EOL> oprot . writeMessageEnd ( ) <EOL> oprot . trans . flush ( ) <EOL> class foo_args ( object ) : <EOL> thrift_spec = ( <EOL> ) <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> 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> 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 foo_result ( object ) : <EOL> """<STR_LIT>""" <EOL> thrift_spec = ( <EOL> ( <NUM_LIT:0> , TType . STRING , '<STR_LIT:success>' , None , None , ) , <EOL> ) <EOL> def __init__ ( self , success = None , ) : <EOL> self . success = success <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:0> : <EOL> if ftype == TType . STRING : <EOL> self . success = iprot . readString ( ) ; <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 . success is not None : <EOL> oprot . writeFieldBegin ( '<STR_LIT:success>' , TType . STRING , <NUM_LIT:0> ) <EOL> oprot . writeString ( self . success ) <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>
