<s> from SipGenericHF import SipGenericHF <EOL> from SipAddress import SipAddress <EOL> from ESipHeaderCSV import ESipHeaderCSV <EOL> class SipAddressHF ( SipGenericHF ) : <EOL> address = None <EOL> def __init__ ( self , body = None , address = None ) : <EOL> SipGenericHF . __init__ ( self , body ) <EOL> if body != None : <EOL> csvs = [ ] <EOL> pidx = <NUM_LIT:0> <EOL> while <NUM_LIT:1> : <EOL> idx = body . find ( '<STR_LIT:U+002C>' , pidx ) <EOL> if idx == - <NUM_LIT:1> : <EOL> break ; <EOL> onum = body [ : idx ] . count ( '<STR_LIT:<>' ) <EOL> cnum = body [ : idx ] . count ( '<STR_LIT:>>' ) <EOL> qnum = body [ : idx ] . count ( '<STR_LIT:">' ) <EOL> if ( onum == <NUM_LIT:0> and cnum == <NUM_LIT:0> and qnum == <NUM_LIT:0> ) or ( onum > <NUM_LIT:0> and onum == cnum and ( qnum % <NUM_LIT:2> == <NUM_LIT:0> ) ) : <EOL> csvs . append ( body [ : idx ] ) <EOL> body = body [ idx + <NUM_LIT:1> : ] <EOL> pidx = <NUM_LIT:0> <EOL> else : <EOL> pidx = idx + <NUM_LIT:1> <EOL> if ( len ( csvs ) > <NUM_LIT:0> ) : <EOL> csvs . append ( body ) <EOL> raise ESipHeaderCSV ( None , csvs ) <EOL> else : <EOL> self . parsed = True <EOL> self . address = address <EOL> def parse ( self ) : <EOL> self . parsed = True <EOL> self . address = SipAddress ( self . body ) <EOL> def __str__ ( self ) : <EOL> return self . localStr ( ) <EOL> def localStr ( self , local_addr = None , local_port = None ) : <EOL> if not self . parsed : <EOL> return self . body <EOL> return self . address . localStr ( local_addr , local_port ) <EOL> def getCopy ( self ) : <EOL> if not self . parsed : <EOL> return self . __class__ ( self . body ) <EOL> return self . __class__ ( address = self . address . getCopy ( ) ) <EOL> def setBody ( self , body ) : <EOL> self . address = body <EOL> def getUri ( self ) : <EOL> return self . address <EOL> def getUrl ( self ) : <EOL> return self . address . url </s>
