Parse a URI into a Route namedtuple

    :param uri: URI or relative URI
    :type uri: str
    :param endpoint_uri: URI of the endpoint
    :type endpoint_uri: str
    :return: Parsed route
    :rtype: _Route
480614
def parse_uri(uri, endpoint_uri):
    
    temp_parse = urlparse(uri)
    return _Route(
        urljoin(endpoint_uri, temp_parse.path),
        parse_qs(temp_parse.query)
    )
660418
private synchronized String getMatchingURI(String incomingURI) {
        String[] incomingURIParts = incomingURI.split("/");

        ArrayList<String[]> tockenizedEndpoints = new ArrayList<String[]>();
        for (String endpointURI : serverEndpointConfigMap.keySet()) {
            // Since the endpoint paths are either relative URIs or URI templates level 1, the paths do not match if they 
            // do not have the same number of segments, using ’/’ as the separator.
            if (incomingURIParts.length == endpointURI.split("/").length) {
                tockenizedEndpoints.add(endpointURI.split("/"));
            }
        }

        /**
         * For each segment of the incoming uri, compare the corresponding segment of every endpoint uri. If matched (exact match or variable {} match)
         * add that endpoint to the list of matchedURI. Move to next segment of the incoming uri and do the same match. At the end of this loop
         * we have list of possible matched endpoints for the incoming URI
         * For e.g if the incoming uri = a/b/d and endpoints are /{var}/b/d, /a/x/y, {var}/b/{var}, /a/{var}/{var}, /{var}/{var}/{var} then
         * possible matchedURIs are /{var}/b/d, {var}/b/{var}, /a/{var}/{var}, /{var}/{var}/{var}
         */
        for (int i = 1; i < incomingURIParts.length; i++) { // start with i=1 skipping the first part because first part of split("/") for /../../.. is always an empty string 
            ArrayList<String[]> matchedURIs = new ArrayList<String[]>();
            // for a each segment in incomingURI, check the corresponding segment of every endpoint.
            for (int j = 0; j < tockenizedEndpoints.size(); j++) {
                String[] tockens = tockenizedEndpoints.get(j);
                if (incomingURIParts[i].equals(tockens[i])) {
                    matchedURIs.add(tockenizedEndpoints.get(j));
                }
                if (tockens[i].startsWith("{") && (tockens[i].endsWith("}"))) {
                    matchedURIs.add(tockenizedEndpoints.get(j));
                }
            }
            tockenizedEndpoints.clear();
            tockenizedEndpoints.addAll(matchedURIs);
        }

        //sort matched endpoints in order of preference from left to right for exact match at each segment giving a higher precedence 
        if (tockenizedEndpoints.size() > 1) {
            Collections.sort(tockenizedEndpoints, COMPARATOR);
        }

        String[] tockenizedEndpoint = null;
        if (!tockenizedEndpoints.isEmpty()) {
            tockenizedEndpoint = tockenizedEndpoints.get(0); //best match is always the top element in the sorted list
        }

        if (tockenizedEndpoint != null) {
            return unTockenizeEp(tockenizedEndpoint);
        } else {
            return null;
        }
    }
1253415
def parse_uri(uri):
    
    groups = URI.match(uri).groups()
    return (groups[1], groups[3], groups[4], groups[6], groups[8])
393486
def root_endpoint(request, format=None):
    
    endpoints = []
    # loop over url modules
    for urlmodule in urlpatterns:
        # is it a urlconf module?
        if hasattr(urlmodule, 'urlconf_module'):
            is_urlconf_module = True
        else:
            is_urlconf_module = False
        # if url is really a urlmodule
        if is_urlconf_module:
            # loop over urls of that module
            for url in urlmodule.urlconf_module.urlpatterns:
                # TODO: configurable skip url in settings
                # skip api-docs url
                if url.name in ['django.swagger.resources.view']:
                    continue
                # try adding url to list of urls to show
                try:
                    endpoints.append({
                        'name': url.name.replace('api_', ''),
                        'url': reverse(url.name, request=request, format=format)
                    })
                # urls of object details will fail silently (eg: /nodes/<slug>/)
                except NoReverseMatch:
                    pass
    return Response(endpoints)
1293102
def parse_endpoint(endpoint, identifier_type=None):
        
        # compute the operation
        parts = endpoint.split(".")
        operation = Operation.from_name(parts[1])

        # extract its parts
        matcher = match(operation.endpoint_pattern, endpoint)
        if not matcher:
            raise InternalServerError("Malformed operation endpoint: {}".format(endpoint))
        kwargs = matcher.groupdict()
        del kwargs["operation"]
        if identifier_type is not None:
            kwargs["identifier_type"] = identifier_type
        return operation, Namespace(**kwargs)
691156
def _build_url(self, endpoint):
        
        try:
            path = self.endpoints[endpoint]
        except KeyError:
            msg = 'Unknown endpoint `{0}`'
            raise ValueError(msg.format(endpoint))
        absolute_url = urljoin(self.target, path)
        return absolute_url
672489
def parseURI(str):
    
    ret = libxml2mod.xmlParseURI(str)
    if ret is None:raise uriError('xmlParseURI() failed')
    return URI(_obj=ret)
167188
def uri_with(uri, scheme=None, netloc=None, path=None, params=None, query=None, fragment=None):
    
    old_scheme, old_netloc, old_path, old_params, old_query, old_fragment = urlparse(uri)
    path, _netloc = _normalize_win_path(path)
    return urlunparse((
        scheme or old_scheme,
        netloc or old_netloc,
        path or old_path,
        params or old_params,
        query or old_query,
        fragment or old_fragment
    ))
276649
def to_addressable_uri(uri)
      uri.nil? || uri.is_a?(Addressable::URI) ? uri : Addressable::URI.parse(uri)
    end
1230595
def get_endpoint(self, endpoint=None):
        """"""
        base_url = self.api_config.api_url
        if not endpoint:
            if 'localhost' in base_url:
                endpoint = ''
            else:
                endpoint = ENDPOINTS[self.endpoint_type]

        endpoint = '/'.join([p.strip('/') for p in (base_url, endpoint)]).strip('/')
        self.logger.info("Using Endpoint: %s", endpoint)
        return endpoint
1070069
def URI(url) # rubocop:disable Naming/MethodName
      if url.respond_to?(:host)
        url
      elsif url.respond_to?(:to_str)
        default_uri_parser.call(url)
      else
        raise ArgumentError, 'bad argument (expected URI object or URI string)'
      end
    end
1298922
def get_endpoint_server_root(self):
        
        parsed = urlparse(self._endpoint)
        root = parsed.scheme + "://" + parsed.hostname

        if parsed.port is not None:
            root += ":" + unicode(parsed.port)

        return root
392244
def to_routes_with_endpoint
			endpoint =
				parts.reduce(result = Flame::Router::Routes.new) do |hash, part|
					hash[part] ||= Flame::Router::Routes.new
				end
			[result, endpoint]
		end
265251
def _relative_uris(self, uri_list):
        

        return [u for u in (self._relative(uri) for uri in uri_list) if u]
1330440
def endpoint(url, method="GET", expected_status=200):
    
    def dec(obj):
        obj.ENDPOINT = url
        obj.METHOD = method
        obj.EXPECTED_STATUS = expected_status
        return obj

    return dec
777664
def request_uri=(new_request_uri)
      if !new_request_uri.respond_to?(:to_str)
        raise TypeError, "Can't convert #{new_request_uri.class} into String."
      end
      if self.absolute? && self.scheme !~ /^https?$/i
        raise InvalidURIError,
          "Cannot set an HTTP request URI for a non-HTTP URI."
      end
      new_request_uri = new_request_uri.to_str
      path_component = new_request_uri[/^([^\?]*)\??(?:.*)$/, 1]
      query_component = new_request_uri[/^(?:[^\?]*)\?(.*)$/, 1]
      path_component = path_component.to_s
      path_component = (!path_component.empty? ? path_component : SLASH)
      self.path = path_component
      self.query = query_component

      # Reset dependent values
      remove_composite_values
    end
531261
def parse_uri(uri: str) -> WebSocketURI:
    
    parsed = urllib.parse.urlparse(uri)
    try:
        assert parsed.scheme in ["ws", "wss"]
        assert parsed.params == ""
        assert parsed.fragment == ""
        assert parsed.hostname is not None
    except AssertionError as exc:
        raise InvalidURI(uri) from exc

    secure = parsed.scheme == "wss"
    host = parsed.hostname
    port = parsed.port or (443 if secure else 80)
    resource_name = parsed.path or "/"
    if parsed.query:
        resource_name += "?" + parsed.query
    user_info = None
    if parsed.username or parsed.password:
        user_info = (parsed.username, parsed.password)
    return WebSocketURI(secure, host, port, resource_name, user_info)