Parse Connection string to extract host and port.

        :param uri: full URI for redis connection in the form of host:port

        :returns: list of RedisConnection objects
502074
def connection_string_parser(uri: str) -> list:
        
        redis_connections = []
        raw_connections = uri.split(',')
        connections = [
            connection for connection in raw_connections if len(connection) > 0
        ]

        for connection in connections:
            raw_connection = connection.split(':')
            if len(raw_connection) == 1:
                host = raw_connection[0].strip()
                port = _DEFAULT_REDIS_PORT
            elif len(raw_connection) == 2:
                host = raw_connection[0].strip()
                port = int(raw_connection[1])
            else:
                raise RuntimeError(
                    "Unable to parse redis connection string: {0}".format(
                        raw_connection
                    )
                )

            redis_connection = _RedisConnection(host, port)
            redis_connections.append(redis_connection)

        return redis_connections
616050
def connection_id_to_endpoint(self, connection_id):
        
        with self._connections_lock:
            try:
                connection_info = self._connections[connection_id]
                return connection_info.uri
            except KeyError:
                return None
1286076
def _uri_split(uri):
    """"""
    scheme, netloc, path, query, fragment = _safe_urlsplit(uri)

    auth = None
    port = None

    if '@' in netloc:
        auth, netloc = netloc.split('@', 1)

    if netloc.startswith('['):
        host, port_part = netloc[1:].split(']', 1)
        if port_part.startswith(':'):
            port = port_part[1:]
    elif ':' in netloc:
        host, port = netloc.split(':', 1)
    else:
        host = netloc
    return scheme, auth, host, port, path, query, fragment
219937
private static void doParse(String connectionUri, JsonObject configuration) {
    Pattern pattern = Pattern.compile(FULL_URI_REGEX);
    Matcher matcher = pattern.matcher(connectionUri);

    if (matcher.matches()) {
      // parse the user and password
      parseUserandPassword(matcher.group(USER_INFO_GROUP), configuration);

      // parse the IP address/host/unix domainSocket address
      parseNetLocation(matcher.group(NET_LOCATION_GROUP), configuration);

      // parse the port
      parsePort(matcher.group(PORT_GROUP), configuration);

      // parse the database name
      parseDatabaseName(matcher.group(DATABASE_GROUP), configuration);

      // parse the parameters
      parseParameters(matcher.group(PARAMETER_GROUP), configuration);

    } else {
      throw new IllegalArgumentException("Wrong syntax of connection URI");
    }
  }
376161
def parse_redis_url(url):
    """"""

    # create config with some sane defaults
    redis_config = {
        "DB": 0,
        "PASSWORD": None,
        "HOST": "localhost",
        "PORT": 6379,
        "SSL": False
    }

    if not url:
        return redis_config

    url = urlparse.urlparse(url)
    # Remove query strings.
    path = url.path[1:]
    path = path.split('?', 2)[0]

    if path:
        redis_config.update({"DB": int(path)})
    if url.password:
        redis_config.update({"PASSWORD": url.password})
    if url.hostname:
        redis_config.update({"HOST": url.hostname})
    if url.port:
        redis_config.update({"PORT": int(url.port)})
    if url.scheme in ['https', 'rediss']:
        redis_config.update({"SSL": True})

    return redis_config
144851
def port_uri_segment(self):
        
        if self._port_uri_segment is None:
            family = self.get_property('adapter-family')
            try:
                self._port_uri_segment = self.port_uri_segment_by_family[
                    family]
            except KeyError:
                self._port_uri_segment = ''
        return self._port_uri_segment
616278
def connection_url_to_hash(url)
      url ||= ''
      uri = URI.parse url
      spec = {
        host:     uri.host,
        port:     uri.port,
        adapter:  uri.scheme,
        username: uri.user,
        password: uri.password,
        database: uri.path.sub(%r{^/}, '')
      }
      spec.reject! {|_, value| !value}
      {adapter: 'redis'}.merge spec
    end
63006
def get_connection(self, internal=False):
        
        # Determine the connection string to use.
        connect_string = self.connect_string
        if internal:
            connect_string = self.internal_connect_string

        # Stripe Redis protocol prefix coming from the API.
        connect_string = connect_string.strip('redis://')
        host, port = connect_string.split(':')

        # Build and return the redis client.
        return redis.StrictRedis(host=host, port=port, password=self._password)
864464
public static String getHost(URI uri) throws IOException {
    String host = uri.getHost();
    if (host != null) {
      return host;
    }
    host = uri.toString();
    int sInd = host.indexOf("//") + 2;
    host = host.substring(sInd);
    int eInd = host.indexOf("/");
    if (eInd != -1) {
      host = host.substring(0,eInd);
    }
    host = URLDecoder.decode(host, StandardCharsets.UTF_8.toString());
    return host;
  }
812945
def get_uri_parts(self, value):
        
        if value.startswith('pyuri_'):
            value = self.rpyhttp(value)
        parts = self.parse_uri(value)
        try:
            return (self.ns_dict[parts[0]], parts[1])
        except KeyError:
            try:
                return (self.ns_dict[parts[0].lower()], parts[1])
            except KeyError:
                return ((None, parts[0]), parts[1])
1029591
def parse_url(self, uri):
        
        parsed = urlparse.urlparse(uri)
        if 'scheme' not in parsed:
            class Object(object):
                pass
            newparsed = Object()
            newparsed.scheme = parsed[0]
            newparsed.netloc = parsed[1]
            newparsed.path = parsed[2]
            newparsed.params = parsed[3]
            newparsed.query = parsed[4]
            newparsed.fragment = parsed[5]
            newparsed.username = ''
            newparsed.password = ''
            newparsed.hostname = ''
            newparsed.port = ''
            parsed = newparsed
        return parsed
612945
def url_to_host_port(url, port=None):
    
    if not url.startswith('http://') and not url.startswith('https://'):
        url = 'http://' + url

    if not port:
        port = RPC_SERVER_PORT

    urlinfo = urllib2.urlparse.urlparse(url)
    hostport = urlinfo.netloc

    parts = hostport.split('@')
    if len(parts) > 2:
        return None, None

    if len(parts) == 2:
        hostport = parts[1]

    parts = hostport.split(':')
    if len(parts) > 2:
        return None, None

    if len(parts) == 2:
        try:
            port = int(parts[1])
            assert 0 < port and port < 65535, 'Invalid port'
        except TypeError:
            return None, None

    return parts[0], port
1018558
def parse_uri(value):
        
        value = RdfNsManager.clean_iri(value)
        lookup = None
        end = None

        try:
            lookup = value[:value.rindex('#')+1]
            end = value[value.rindex('#')+1:]
        except ValueError:
            try:
                lookup = value[:value.rindex('/')+1]
                end = value[value.rindex('/')+1:]
            except ValueError:
                try:
                    lookup = value[:value.index(':')]
                    end = value[value.rindex(':')+1:]
                except ValueError:
                    try:
                        lookup = value[:value.index('_')]
                        end = value[value.index('_')+1:]
                    except ValueError:
                        lookup = value
                        end = ""

        return (lookup, end)
1196947
public StatefulRedisConnection<String, String> connect(RedisURI redisURI) {

        assertNotNull(redisURI);

        return getConnection(connectStandaloneAsync(newStringStringCodec(), redisURI, redisURI.getTimeout()));
    }
731965
def parse_host(cls, host):
        ''''''
        if host.endswith(']'):
            return cls.parse_hostname(host), None
        else:
            hostname, sep, port = host.rpartition(':')

        if sep:
            port = int(port)
            if port < 0 or port > 65535:
                raise ValueError('Port number invalid')
        else:
            hostname = port
            port = None

        return cls.parse_hostname(hostname), port
353536
def parse_uri(uri_string):
    
    parts = urlparse.urlparse(uri_string)
    uri = Uri()
    if parts[0]:
      uri.scheme = parts[0]
    if parts[1]:
      host_parts = parts[1].split(':')
      if host_parts[0]:
        uri.host = host_parts[0]
      if len(host_parts) > 1:
        uri.port = int(host_parts[1])
    if parts[2]:
      uri.path = parts[2]
    if parts[4]:
      param_pairs = parts[4].split('&')
      for pair in param_pairs:
        pair_parts = pair.split('=')
        if len(pair_parts) > 1:
          uri.query[urllib.unquote_plus(pair_parts[0])] = (
              urllib.unquote_plus(pair_parts[1]))
        elif len(pair_parts) == 1:
          uri.query[urllib.unquote_plus(pair_parts[0])] = None
    return uri
45595
def get_uri(self):
        
        url = Url()
        url.protocol = self.get_protocol()
        url.hostname = self.get_address()
        url.port = self.get_tcp_port()
        url.vars = dict((k, to_list(v))
                        for (k, v) in list(self.get_all().items())
                        if isinstance(v, str) or isinstance(v, list))

        if self.account:
            url.username = self.account.get_name()
            url.password1 = self.account.get_password()
            url.password2 = self.account.authorization_password

        return str(url)