<s> from SipGenericHF import SipGenericHF <EOL> class SipReplaces ( SipGenericHF ) : <EOL> hf_names = ( '<STR_LIT>' , ) <EOL> call_id = None <EOL> from_tag = None <EOL> to_tag = None <EOL> early_only = False <EOL> params = None <EOL> def __init__ ( self , body = None , call_id = None , from_tag = None , to_tag = None , early_only = False , params = None ) : <EOL> SipGenericHF . __init__ ( self , body ) <EOL> if body != None : <EOL> return <EOL> self . parsed = True <EOL> self . params = [ ] <EOL> self . call_id = call_id <EOL> self . from_tag = from_tag <EOL> self . to_tag = to_tag <EOL> self . early_only = early_only <EOL> if params != None : <EOL> self . params = params [ : ] <EOL> def parse ( self ) : <EOL> self . parsed = True <EOL> self . params = [ ] <EOL> params = self . body . split ( '<STR_LIT:;>' ) <EOL> self . call_id = params . pop ( <NUM_LIT:0> ) <EOL> for param in params : <EOL> if param . startswith ( '<STR_LIT>' ) : <EOL> self . from_tag = param [ len ( '<STR_LIT>' ) : ] <EOL> elif param . startswith ( '<STR_LIT>' ) : <EOL> self . to_tag = param [ len ( '<STR_LIT>' ) : ] <EOL> elif param == '<STR_LIT>' : <EOL> self . early_only = True <EOL> else : <EOL> self . params . append ( param ) <EOL> def __str__ ( self ) : <EOL> if not self . parsed : <EOL> return self . body <EOL> res = '<STR_LIT>' % ( self . call_id , self . from_tag , self . to_tag ) <EOL> if self . early_only : <EOL> res += '<STR_LIT>' <EOL> for param in self . params : <EOL> res += '<STR_LIT:;>' + param <EOL> return res <EOL> def getCopy ( self ) : <EOL> if not self . parsed : <EOL> return SipReplaces ( self . body ) <EOL> return SipReplaces ( call_id = self . call_id , from_tag = self . from_tag , to_tag = self . to_tag , early_only = self . early_only , params = self . params ) </s>
