Formats the base URL either `host` or `instance`

        :return: Base URL string
542107
def get_base_url(use_ssl, instance=None, host=None):
        

        if instance is not None:
            host = ("%s.service-now.com" % instance).rstrip('/')

        if use_ssl is True:
            return "https://%s" % host

        return "http://%s" % host
762233
def _url_format(self, service):
        
        base_service_url = '{base}{service}'.format(
            base=self.urlbase,
            service=service
        )
        return base_service_url
80678
def create_basic_url(self):
        
        if self.username is None:
            if self.namespace is None:
                request_url = "{}/api/0/{}/".format(
                    self.instance, self.repo)
            else:
                request_url = "{}/api/0/{}/{}/".format(
                    self.instance, self.namespace, self.repo)
        else:
            if self.namespace is None:
                request_url = "{}/api/0/fork/{}/{}/".format(
                    self.instance, self.username, self.repo)
            else:
                request_url = "{}/api/0/fork/{}/{}/{}/".format(
                    self.instance, self.username, self.namespace, self.repo)
        return request_url
1020234
def build_url (self):
        
        # norm base url - can raise UnicodeError from url.idna_encode()
        base_url, is_idn = url_norm(self.base_url, self.encoding)
        # make url absolute
        if self.base_ref:
            # use base reference as parent url
            if ":" not in self.base_ref:
                # some websites have a relative base reference
                self.base_ref = urljoin(self.parent_url, self.base_ref)
            self.url = urljoin(self.base_ref, base_url)
        elif self.parent_url:
            # strip the parent url query and anchor
            urlparts = list(urlparse.urlsplit(self.parent_url))
            urlparts[4] = ""
            parent_url = urlutil.urlunsplit(urlparts)
            self.url = urljoin(parent_url, base_url)
        else:
            self.url = base_url
        # urljoin can unnorm the url path, so norm it again
        urlparts = list(urlparse.urlsplit(self.url))
        if urlparts[2]:
            urlparts[2] = urlutil.collapse_segments(urlparts[2])
        self.url = urlutil.urlunsplit(urlparts)
        # split into (modifiable) list
        self.urlparts = strformat.url_unicode_split(self.url)
        self.build_url_parts()
        # and unsplit again
        self.url = urlutil.urlunsplit(self.urlparts)
1244676
def url(self):
        """"""
        if self.parent is None:
            # TODO: differing API Versions?
            pieces = [self.client.base_url, 'api', 'atlas', 'v2']
        else:
            pieces = [self.parent.url]

        pieces.append(self.model_class.path)
        return '/'.join(pieces)
1343002
def request_host(request):
    
    url = request.get_full_url()
    parse_result = compat.urlparse.urlparse(url)
    scheme, host, port = parse_result.scheme, parse_result.hostname, parse_result.port
    try:
        port = int(port)
    except ValueError:
        pass
    if host == "":
        host = request.get_header("Host", "")

    if port != default_ports.get(scheme):
        host = "%s:%s" % (host, port)
    return host
370418
def get_url(self, path):
        
        host = ('[' + self.host + ']' if (self.host.find(':') != -1)
                else self.host)
        base_url = self.protocol + '://' + host + ':' + str(self.port)
        return base_url + '/v3alpha/' + path.lstrip("/")
808966
def _build_url(self, host, sport, method, id, format, parameters):
        
        path = "/".join(filter(None, (sport, method, id)))
        url = "https://" + host + "/" + path + "." + format
        if parameters:
            paramstring = urllib.parse.urlencode(parameters)
            url = url + "?" + paramstring
        return url
1296185
def _get_url(self, path):
        
        options = self._options.copy()
        options.update({'path': path})
        return self._base_url.format(**options)
797527
def _url(self, url, file_upload=False):
        

        host = self.api_url
        if file_upload:
            host = self.uploads_api_url

        protocol = 'https' if self.https else 'http'
        if url.endswith('/'):
            url = url[:-1]
        return '{0}://{1}/{2}'.format(
            protocol,
            host,
            url
        )
1312292
def as_url(self):
        '''
        
        '''
        if '' in self._scope:
            return self._finalize().as_url

        if not self._is_endpoint:
            raise UrlBuildingError('Not an endpoint {}'.format(repr(self)))

        if self._ready:
            path, host = self._path, self._host
        else:
            return self().as_url

        # XXX there is a little mess with `domain` and `host` terms
        if ':' in host:
            domain, port = host.split(':')
        else:
            domain = host
            port = None

        if self._bound_env:
            request = self._bound_env.request
            scheme_port = {'http': '80',
                           'https': '443'}.get(request.scheme, '80')

            # Domain to compare with the result of build.
            # If both values are equal, domain part can be hidden from result.
            # Take it from route_state, not from env.request, because
            # route_state contains domain values with aliased replaced by their
            # primary value
            primary_domain = self._bound_env._route_state.primary_domain
            host_split = request.host.split(':')
            request_domain = host_split[0]
            request_port = host_split[1] if len(host_split) > 1 else scheme_port
            port = port or request_port

            return URL(path, host=domain or request_domain,
                       port=port if port != scheme_port else None,
                       scheme=request.scheme, fragment=self._fragment,
                       show_host=host and (domain != primary_domain \
                                           or port != request_port))
        return URL(path, host=domain, port=port,
                   fragment=self._fragment, show_host=True)
628863
def _construct_url(self, endpoint):
        """"""
        parsed_url = urlparse(self.host)
        scheme = parsed_url[0]
        host = parsed_url[1]
        # Handle host without a scheme specified (eg. www.example.com)
        if scheme == "":
            scheme = "http"
            host = self.host

        if not endpoint.startswith("/"):
            endpoint = "/" + endpoint
        if self.config["api_version"] is not None:
            endpoint = "/v%d%s" % (self.config["api_version"], endpoint)
        return urlunparse((scheme, host, endpoint, '', '', ''))
803808
def format_url(self, url, **kwargs):
        # type: (str, Any) -> str
        
        url = url.format(**kwargs)
        parsed = urlparse(url)
        if not parsed.scheme or not parsed.netloc:
            url = url.lstrip('/')
            base = self.config.base_url.format(**kwargs).rstrip('/')
            url = urljoin(base + '/', url)
        return url
446525
def _construct_url(self, url, base, quote):
        
        if not base and not quote:
            return url
        else:
            url = url + base.lower() + quote.lower() + "/"
            return url
690300
def _FormatHostname(self, event):
    
    hostname = self._output_mediator.GetHostname(event)
    return self._FormatField(hostname)
1224616
def ftp_url(self):
        # type: () -> Text
        """"""
        url = (
            "ftp://{}".format(self.host)
            if self.port == 21
            else "ftp://{}:{}".format(self.host, self.port)
        )
        return url
1133922
def gethost(self, default=None, errors='strict'):
        
        host = self.host
        if host is None or (not host and default is not None):
            return default
        elif host.startswith(self.LBRACKET) and host.endswith(self.RBRACKET):
            return _ip_literal(host[1:-1])
        elif host.startswith(self.LBRACKET) or host.endswith(self.RBRACKET):
            raise ValueError('Invalid host %r' % host)
        # TODO: faster check for IPv4 address?
        return _ipv4_address(host) or uridecode(host, 'utf-8', errors).lower()