def _normalize_hosts(hosts):
 if (hosts is None):
  return [{}]
 if isinstance(hosts, string_types):
  hosts = [hosts]
 out = []
 for host in hosts:
  if isinstance(host, string_types):
   if (u'://' not in host):
    host = (u'//%s' % host)
   parsed_url = urlparse(host)
   h = {u'host': parsed_url.hostname}
   if parsed_url.port:
    h[u'port'] = parsed_url.port
   if (parsed_url.scheme == u'https'):
    h[u'port'] = (parsed_url.port or 443)
    h[u'use_ssl'] = True
    h[u'scheme'] = u'http'
   elif parsed_url.scheme:
    h[u'scheme'] = parsed_url.scheme
   if (parsed_url.username or parsed_url.password):
    h[u'http_auth'] = (u'%s:%s' % (parsed_url.username, parsed_url.password))
   if (parsed_url.path and (parsed_url.path != u'/')):
    h[u'url_prefix'] = parsed_url.path
   out.append(h)
  else:
   out.append(host)
 return out

def _normalize_hosts ( hosts ) : if ( hosts is None ) : return [ { } ] if isinstance ( hosts , string_types ) : hosts = [ hosts ] out = [ ] for host in hosts : if isinstance ( host , string_types ) : if ( u'://' not in host ) : host = ( u'//%s' % host ) parsed_url = urlparse ( host ) h = { u'host' : parsed_url . hostname } if parsed_url . port : h [ u'port' ] = parsed_url . port if ( parsed_url . scheme == u'https' ) : h [ u'port' ] = ( parsed_url . port or 443 ) h [ u'use_ssl' ] = True h [ u'scheme' ] = u'http' elif parsed_url . scheme : h [ u'scheme' ] = parsed_url . scheme if ( parsed_url . username or parsed_url . password ) : h [ u'http_auth' ] = ( u'%s:%s' % ( parsed_url . username , parsed_url . password ) ) if ( parsed_url . path and ( parsed_url . path != u'/' ) ) : h [ u'url_prefix' ] = parsed_url . path out . append ( h ) else : out . append ( host ) return out
helper function to transform hosts argument to :class:~elasticsearch .