Open target uri.

        :param target_uri: Uri to open
        :type target_uri: string

        :returns: Target object
966392
def open(self, target_uri, **kwargs):
        
        target = urlsplit(target_uri, scheme=self.default_opener)

        opener = self.get_opener(target.scheme)
        query = opener.conform_query(target.query)

        target = opener.get_target(
            target.scheme,
            target.path,
            target.fragment,
            target.username,
            target.password,
            target.hostname,
            target.port,
            query,
            **kwargs
        )
        target.opener_path = target_uri

        return target
1312903
private static HttpHost determineTarget(HttpUriRequest request) throws ClientProtocolException {
		// A null target may be acceptable if there is a default target.
		// Otherwise, the null target is detected in the director.
		HttpHost target = null;
		URI requestURI = request.getURI();
		if (requestURI.isAbsolute()) {
			target = URIUtils.extractHost(requestURI);
			if (target == null) {
				throw new ClientProtocolException(
						"URI does not specify a valid host name: " + requestURI);
			}
		}
		return target;
	}
701723
def xdg_open(uri):
    '''
    '''
    try:
        subprocess.call(['xdg-open', uri, ])
    except FileNotFoundError:
        logger.error(traceback.format_exc())
333227
def _set_tracker_uri(self, uri):
        
        parse_result = urlparse.urlparse(uri)
        if (parse_result.scheme.lower() not in ['http', 'https'] or
            not parse_result.netloc or not parse_result.query):
            raise InvalidUriError('Invalid tracker URI (%s)' % uri)
        qdict = cgi.parse_qs(parse_result.query)
        if not qdict or not 'upload_id' in qdict:
            raise InvalidUriError('Invalid tracker URI (%s)' % uri)
        self.tracker_uri = uri
        self.tracker_uri_host = parse_result.netloc
        self.tracker_uri_path = '%s/?%s' % (parse_result.netloc,
                                            parse_result.query)
        self.server_has_bytes = 0
1202073
def open_link(self, link_uri):
        
        self.connection_requested.call(link_uri)
        self.state = State.INITIALIZED
        self.link_uri = link_uri
        try:
            self.link = cflib.crtp.get_link_driver(
                link_uri, self._link_quality_cb, self._link_error_cb)

            if not self.link:
                message = 'No driver found or malformed URI: {}' \
                    .format(link_uri)
                logger.warning(message)
                self.connection_failed.call(link_uri, message)
            else:
                # Add a callback so we can check that any data is coming
                # back from the copter
                self.packet_received.add_callback(
                    self._check_for_initial_packet_cb)

                self._start_connection_setup()
        except Exception as ex:  # pylint: disable=W0703
            # We want to catch every possible exception here and show
            # it in the user interface
            import traceback

            logger.error("Couldn't load link driver: %s\n\n%s",
                         ex, traceback.format_exc())
            exception_text = "Couldn't load link driver: %s\n\n%s" % (
                ex, traceback.format_exc())
            if self.link:
                self.link.close()
                self.link = None
            self.connection_failed.call(link_uri, exception_text)
1332268
def open(self, url, method='get', **kwargs):
        
        response = self.session.request(method, url, **self._build_send_args(**kwargs))
        self._update_state(response)
67883
def process_target(str)
      if @root == true
        url(str =~ /^\// ? str : "/#{str}")
      else
        str =~ /^(http|https)/i ? str : url(str =~ /^\// ? str : "/#{str}")
      end
    end
1148001
def open_uri(uri, options, follows_remaining: 0)
      uri.open(options)
    rescue OpenURI::HTTPRedirect => exception
      raise Down::TooManyRedirects, "too many redirects" if follows_remaining == 0

      # fail if redirect URI scheme is not http or https
      begin
        uri = ensure_uri(exception.uri)
      rescue Down::InvalidUrl
        response = rebuild_response_from_open_uri_exception(exception)

        raise ResponseError.new("Invalid Redirect URI: #{exception.uri}", response: response)
      end

      # forward cookies on the redirect
      if !exception.io.meta["set-cookie"].to_s.empty?
        options["Cookie"] = exception.io.meta["set-cookie"]
      end

      follows_remaining -= 1
      retry
    rescue OpenURI::HTTPError => exception
      response = rebuild_response_from_open_uri_exception(exception)

      # open-uri attempts to parse the redirect URI, so we re-raise that exception
      if exception.message.include?("(Invalid Location URI)")
        raise ResponseError.new("Invalid Redirect URI: #{response["Location"]}", response: response)
      end

      response_error!(response)
    rescue => exception
      request_error!(exception)
    end
648556
def get(self, alias, target=None):
        
        for target_part in reversed(list(self._get_targets(target))):
            options = self._get(target_part, alias)
            if options:
                return options
346344
def get(self, uri):
        
        uri = self.URI + uri
        return self._client.get(uri)
1327814
def remap_link_target(path, absolute=False):
    
    if path.startswith('@'):
        # static resource
        return static_url(path[1:], absolute=absolute)

    if absolute:
        # absolute-ify whatever the URL is
        return urllib.parse.urljoin(flask.request.url, path)

    return path
159455
def load_all(self, target_uris, **kwargs):
        '''
        
        '''
        yaml_series = self._load_first(
            target_uris, yamlsettings.yamldict.load_all, **kwargs
        )
        yaml_dicts = []
        for yaml_dict in yaml_series:
            yaml_dicts.append(yaml_dict)
        # return YAMLDict objects
        return yaml_dicts
655312
public static String rewriteURI(String uri, HttpHost targetHost) {
        try {
            return URIUtils.rewriteURI(createURI(uri), targetHost).toString();
        } catch (URISyntaxException e) {
            throw new InvalidUriException(e);
        }
    }
306812
def explore_uri(self, explorer_resource, show_back=True):
        
        uri = explorer_resource.uri
        caps = explorer_resource.acceptable_capabilities
        checks = explorer_resource.checks
        print("Reading %s" % (uri))
        options = {}
        capability = None
        try:
            if (caps == 'resource'):
                # Not expecting a capability document
                self.explore_show_head(uri, check_headers=checks)
            else:
                s = Sitemap()
                list = s.parse_xml(url_or_file_open(uri))
                (options, capability) = self.explore_show_summary(
                    list, s.parsed_index, caps, context=uri)
        except IOError as e:
            print("Cannot read %s (%s)" % (uri, str(e)))
        except Exception as e:
            print("Cannot parse %s (%s)" % (uri, str(e)))
        #
        # Loop until we have some valid input
        #
        while (True):
            # don't offer number option for no resources/capabilities
            num_prompt = '' if (len(options) == 0) else 'number, '
            up_prompt = 'b(ack), ' if (show_back) else ''
            if (self.fake_input):
                inp = self.fake_input
            else:
                inp = input("Follow [%s%sq(uit)]?" % (num_prompt, up_prompt))
            if (inp in options.keys()):
                break
            if (inp == 'q'):
                raise ExplorerQuit()
            if (inp == 'b'):
                return(None)
        #
        # Got input that is one of the options
        #
        checks = {}
        r = options[inp]
        if (r.capability is None):
            if (capability in ['resourcelist', 'changelist',
                               'resourcedump', 'changedump']):
                caps = 'resource'
            else:
                caps = self.allowed_entries(capability)
        elif (r.capability is 'resource'):
            caps = r.capability
        else:
            caps = [r.capability]
        # Record anything we know about the resource to check
        if (r.length is not None):
            checks['content-length'] = r.length
        if (r.lastmod is not None):
            checks['last-modified'] = r.lastmod
        if (r.mime_type is not None):
            checks['content-type'] = r.mime_type
        # FIXME - could add fixity checks here too
        return(XResource(r.uri, caps, checks))
890932
def get_target(self, target):
        
        if target not in self._target_cache:
            self._target_cache[target] = self._get_target(target)
        return self._target_cache[target]
328342
def get_redirect_target():
    """"""
    for target in request.values.get('next'), request.referrer:
        if target and is_local_url(target):
            return target
117604
def _get_request_uri(self, request):
        """"""
        request_uri = request['target']
        if request_uri.startswith('/'):  # eg. GET /index.html
            return (request.get('Host', 'localhost').split(':')[0],
                    request_uri[1:])
        elif '://' in request_uri:  # eg. GET http://rded.nl
            locator = request_uri.split('://', 1)[1]
            host, path = locator.split('/', 1)
            return (host.split(':')[0], path)