def parse( self, value ): try: n = value.find( ':' ) if n < 0: raise SipException( 'Failed to parse protocol of URI, ' + value + '.' ) self.protocol = value[:n] value = value[n+1:] n = value.find( '@' ) if n < 0: self.host = value else: self.host = value[n+1:] self.user = value[:n] if self.user: n = self.user.find( ':' ) if n >= 0: self.password = self.user[n+1:] self.user = self.user[:n] self.host = HParams.parse( self.hparams, self.hkparams, self.host ) self.host = Params.parse( self.params, self.kparams, self.host ) n = self.host.find( ':' ) if n >= 0: self.port = int( self.host[n+1:] ) self.host = self.host[:n] if not self.host: raise SipException( 'Failed to parse host of URI, ' + value + '.' ) except not SipException: raise SipException( 'Failed to parse the URI, ' + value + '.' )
def parse( self, value ): lvalue = Params.parse( self.params, self.kparams, value ) if lvalue.startswith( '<' ) and lvalue.endswith( '>' ): lvalue = lvalue.lstrip( '<' ) lvalue = lvalue.rstrip( '>' ) self.uri = Uri( uri ) else: SipException( 'InfoElement, ' + str(self.value) + ', does not have opening or closing brackets.' )
def parse( self, value ): value = Params.parse( self.params, self.kparams, value ) if value: n = value.find( '/' ) if n >= 0: self.type = value[:n] self.subtype = value[n+1:] else: self.type = value
def parse( self, value ): value = Params.parse( self.params, self.kparams, value ) if value: values = value.split( ' ' ) self.host = values[1] values = values[0].split( '/' ) self.protocol = values[0] self.version = values[1] self.transport = values[2]
def parse( self, value ): name = None uri = None # Try to parse using angle-brackets. n = value.find( '>' ) if n >= 0: dummy = Params.parse( self.params, self.kparams, value[n+1:] ) nameUri = value[:n] n = nameUri.find( '<' ) if n < 0: raise SipException( 'Failed to find the matching left-angle-bracket for address, ' + value + '.' ) uri = nameUri[n+1:] name = nameUri[:n] else: nameUri = Params.parse( self.params, self.kparams, value ) uriIndex = 0 nameUriArray = nameUri.split( '"' ) if len(nameUriArray) == 1: pass elif len(nameUriArray) == 3: name = nameUriArray[1] uriIndex = 2 else: raise SipException( 'Failed to parse address, ' + value + '.' ) uri = nameUriArray[uriIndex] # Display Name if name: name = name.strip( ' ' ) self.name = name.strip( '"' ) # URI if uri: self.uri = Uri( uri ) else: raise SipException( 'Failed to find URI in address, ' + value + '.' )
def parse( self, value ): try: n = value.find( ':' ) if n < 0: raise SipException( 'Failed to parse protocol of URI, ' + value + '.' ) self.protocol = value[:n] value = value[n+1:] self.user = Params.parse( self.params, self.kparams, value ) if not self.user: raise SipException( 'Failed to parse user of URI, ' + value + '.' ) except not SipException: raise SipException( 'Failed to parse the URI, ' + value + '.' )
def parse( self, value ): if ( isinstance( value, int ) ): self.value = int(value) else: value = Params.parse( self.params, self.kparams, value ) self.value = int(value)
def parse( self, value ): value = Params.parse( self.params, self.kparams, value ) if value: self.value = value else: self.value = ''