<s> from SipGenericHF import SipGenericHF <EOL> class SipReason ( SipGenericHF ) : <EOL> '''<STR_LIT>''' <EOL> hf_names = ( '<STR_LIT>' , ) <EOL> protocol = None <EOL> cause = None <EOL> reason = None <EOL> def __init__ ( self , body = None , protocol = None , cause = None , reason = None ) : <EOL> SipGenericHF . __init__ ( self , body ) <EOL> if body == None : <EOL> self . parsed = True <EOL> self . protocol = protocol <EOL> self . cause = cause <EOL> self . reason = reason <EOL> def parse ( self ) : <EOL> protocol , reason_params = self . body . split ( '<STR_LIT:;>' , <NUM_LIT:1> ) <EOL> self . protocol = protocol . strip ( ) <EOL> for reason_param in reason_params . split ( '<STR_LIT:;>' ) : <EOL> rp_name , rp_value = [ x . strip ( ) for x in reason_param . split ( '<STR_LIT:=>' , <NUM_LIT:1> ) ] <EOL> if rp_name == '<STR_LIT>' : <EOL> self . cause = int ( rp_value ) <EOL> elif rp_name == '<STR_LIT:text>' : <EOL> self . reason = rp_value . strip ( '<STR_LIT:">' ) <EOL> assert ( self . cause != None ) <EOL> self . parsed = True <EOL> def __str__ ( self ) : <EOL> if not self . parsed : <EOL> return self . body <EOL> if self . reason == None : <EOL> return '<STR_LIT>' % ( self . protocol , self . cause ) <EOL> return '<STR_LIT>' % ( self . protocol , self . cause , self . reason ) <EOL> def getCopy ( self ) : <EOL> if not self . parsed : <EOL> return SipReason ( self . body ) <EOL> return SipReason ( protocol = self . protocol , cause = self . cause , reason = self . reason ) </s>
