<s> '''<STR_LIT>''' <EOL> from haigha . frames . frame import Frame <EOL> from haigha . reader import Reader <EOL> from haigha . writer import Writer <EOL> class MethodFrame ( Frame ) : <EOL> '''<STR_LIT>''' <EOL> @ classmethod <EOL> def type ( cls ) : <EOL> return <NUM_LIT:1> <EOL> @ property <EOL> def class_id ( self ) : <EOL> return self . _class_id <EOL> @ property <EOL> def method_id ( self ) : <EOL> return self . _method_id <EOL> @ property <EOL> def args ( self ) : <EOL> return self . _args <EOL> @ classmethod <EOL> def parse ( self , channel_id , payload ) : <EOL> class_id = payload . read_short ( ) <EOL> method_id = payload . read_short ( ) <EOL> return MethodFrame ( channel_id , class_id , method_id , payload ) <EOL> def __init__ ( self , channel_id , class_id , method_id , args = None ) : <EOL> Frame . __init__ ( self , channel_id ) <EOL> self . _class_id = class_id <EOL> self . _method_id = method_id <EOL> self . _args = args <EOL> def __str__ ( self ) : <EOL> if isinstance ( self . args , ( Reader , Writer ) ) : <EOL> return "<STR_LIT>" % ( self . __class__ . __name__ , self . channel_id , <EOL> self . class_id , self . method_id , str ( self . args ) ) <EOL> else : <EOL> return "<STR_LIT>" % ( self . __class__ . __name__ , self . channel_id , <EOL> self . class_id , self . method_id ) <EOL> def write_frame ( self , buf ) : <EOL> writer = Writer ( buf ) <EOL> writer . write_octet ( self . type ( ) ) <EOL> writer . write_short ( self . channel_id ) <EOL> stream_args_len_pos = len ( buf ) <EOL> writer . write_long ( <NUM_LIT:0> ) <EOL> stream_method_pos = len ( buf ) <EOL> writer . write_short ( self . class_id ) <EOL> writer . write_short ( self . method_id ) <EOL> if self . _args is not None : <EOL> writer . write ( self . _args . buffer ( ) ) <EOL> stream_len = len ( buf ) - stream_method_pos <EOL> writer . write_long_at ( stream_len , stream_args_len_pos ) <EOL> writer . write_octet ( <NUM_LIT> ) <EOL> MethodFrame . register ( ) </s>
