def _normalize_hosts(hosts):
    # if hosts are empty, just defer to defaults down the line
    if hosts is None:
        return [{}]

    # passed in just one string
    if isinstance(hosts, string_types):
        hosts = [hosts]

    out = []
    # normalize hosts to dicts
    for host in hosts:
        if isinstance(host, string_types):
            if '://' not in host:
                host = "//%s" % host

            parsed_url = urlparse(host)
            h = {"host": parsed_url.hostname}

            if parsed_url.port:
                h["port"] = parsed_url.port

            if parsed_url.scheme == "https":
                h['port'] = parsed_url.port or 443
                h['use_ssl'] = True
                h['scheme'] = 'http'
            elif parsed_url.scheme:
                h['scheme'] = parsed_url.scheme

            if parsed_url.username or parsed_url.password:
                h['http_auth'] = '%s:%s' % (parsed_url.username, parsed_url.password)

            if parsed_url.path and parsed_url.path != '/':
                h['url_prefix'] = parsed_url.path

            out.append(h)
        else:
            out.append(host)
    return out
Move or query the window cursor.
dataset/ETHPy150Open elastic/elasticsearch-py/elasticsearch/client/__init__.py/_normalize_hosts--crossover with--dataset/ETHPy150Open Ali-Razmjoo/OWASP-ZSC/module/readline_windows/pyreadline/console/ironpython_console.py/Console.pos