code: def set_uri(self, uri):
          
          try:
              uri = Url.from_string(uri, self.protocol)
          except ValueError:
              raise ValueError('Hostname parse error: ' + repr(uri))
          hostname = uri.hostname or ''
          name = uri.path and hostname + uri.path or hostname
          self.set_protocol(uri.protocol)
          self.set_tcp_port(uri.port)
          self.set_name(name)
          self.set_address(name)
  
          if uri.username is not None \
             or uri.password1 is not None \
             or uri.password2:
              account = Account(uri.username, uri.password1, uri.password2)
              self.set_account(account)
  
          for key, val in list(uri.vars.items()):
              self.set(key, val)
docs: Defines the protocol, hostname/address, TCP port number, username,
          and password from the given URL. The hostname may be URL formatted,
          so the following formats are all valid:
  
              - myhostname
              - myhostname.domain
              - ssh:hostname
              - ssh:hostname.domain
              - ssh://hostname
              - ssh://user@hostname
              - ssh://user:password@hostname
              - ssh://user:password@hostname:21
  
          For a list of supported protocols please see set_protocol().
  
          :type  uri: string
          :param uri: An URL formatted hostname.