def _LoadHost(self, hostname, port=None, proxy=None):
    """Load hostname and port to connect to.

    Args:
      hostname: str, like a URL or a hostname string.  Examples:
        'http://foo' 'http://foo:port' 'https://foo' 'foo:port' 'foo'
      port: int, optional, port to connect to, which will be overridden by
        any port specified in the hostname str.
      proxy: str, optional, "host:port" formatted HTTP proxy
    Raises:
      Error: if args are malformed
    """
    logging.debug('LoadHost(%s, %s)', hostname, port)

    # unicode causes problems later on the socket level. rid ourselves of it.
    hostname = str(hostname)
    if proxy is not None:
      proxy = str(proxy)
    elif proxy is None:
      if os.environ.get('HTTPS_PROXY'):
        proxy = str(os.environ['HTTPS_PROXY'])
      elif os.environ.get('http_proxy'):
        proxy = str(os.environ['http_proxy'])

    # note: defaulting to https when no scheme is given.
    if not hostname.startswith('http'):
      hostname = 'https://%s' % hostname

    (scheme, netloc, unused_path, unused_query, unused_frag
    ) = urlparse.urlsplit(hostname)

    (hostname, tmp_port) = urllib.splitport(netloc)
    if tmp_port:
      port = tmp_port

    use_https = False
    if scheme == 'https':
      use_https = True

    if port:
      try:
        port = int(port)
      except TypeError:
        raise Error('invalid port value %s' % str(port))

    if port == 80 and not use_https:
      port = None
    if port == 443 and use_https:
      port = None

    self.hostname = hostname
    self.port = port
    self.netloc = self.hostname
    self.use_https = use_https

    if self.port and self.port != 80 and self.port != 443:
      self.netloc = (self.netloc, self.port) % '%s:%d'

    logging.debug('LoadHost(): hostname = %s, port = %s, use_https = %s',
                  self.hostname, self.port, self.use_https)

    self.proxy_hostname = None
    self.proxy_port = None
    self.proxy_use_https = False
    if proxy:
      u = urlparse.urlparse(proxy)
      if u.scheme in ['https', 'http']:
        self.proxy_use_https = u.scheme == 'https'
        (self.proxy_hostname, self.proxy_port) = urllib.splitport(u.netloc)
      else:
        (self.proxy_hostname, self.proxy_port) = urllib.splitport(proxy)
      if not self.proxy_port:
        raise Error('proxy does not specify port: %s', proxy)
      self.proxy_port = int(self.proxy_port)
      logging.debug('LoadHost(): proxy host = %s, proxy port = %s',
                    self.proxy_hostname, self.proxy_port)
dataset/ETHPy150Open google/simian/src/simian/client/client.py/HttpsClient._LoadHost/swapped operands of `%`