예제 #1
0
 def __init__(self, baseurl):
     _, host, path, query, fragment = urlsplit(baseurl)
     path = path.strip("/")
     if not path.endswith("/issues"):
         raise BadGitLabURL(baseurl)
     path = "/api/v4/projects/%s" % quote(path[:-len("/issues")], safe="")
     baseurl = urlunsplit(("https", host, path, query, fragment))
     super(GitLab, self).__init__(baseurl)
     self.cached_bugs = {}
예제 #2
0
 def __init__(self, baseurl):
     _, host, path, query, fragment = urlsplit(baseurl)
     host = "api." + host
     path = path.rstrip("/")
     if not path.endswith("/issues"):
         raise BadGitHubURL(baseurl)
     path = "/repos" + path[:-len("/issues")]
     baseurl = urlunsplit(("https", host, path, query, fragment))
     super(GitHub, self).__init__(baseurl)
     self.cached_bugs = {}
예제 #3
0
 def checkLimit(self, url, timeout, token=None):
     """See `IGitHubRateLimit`."""
     auth_header = "token %s" % token if token is not None else None
     host = urlsplit(url).netloc
     if (host, token) not in self._limits:
         self._limits[(host, token)] = self._update(
             host, timeout, auth_header=auth_header)
     limit = self._limits[(host, token)]
     if not limit["remaining"]:
         raise GitHubExceededRateLimit(host, limit["reset"])
     yield auth_header
     limit["remaining"] -= 1
예제 #4
0
def extract_url_parameter(url, parameter):
    """Extract parameter and its value from a URL.

    Use this if your test needs to inspect a parameter value embedded in
    a URL, but doesn't really care what the rest of the URL looks like
    or how the parameters are ordered.
    """
    scheme, host, path, query, fragment = urlsplit(url)
    args = query.split("&")
    for arg in args:
        key, value = arg.split("=")
        if key == parameter:
            return arg
    return None
예제 #5
0
def extract_url_parameter(url, parameter):
    """Extract parameter and its value from a URL.

    Use this if your test needs to inspect a parameter value embedded in
    a URL, but doesn't really care what the rest of the URL looks like
    or how the parameters are ordered.
    """
    scheme, host, path, query, fragment = urlsplit(url)
    args = query.split('&')
    for arg in args:
        key, value = arg.split('=')
        if key == parameter:
            return arg
    return None
예제 #6
0
def hostpair(url):
    """Parse the host and port number out of a URL string."""
    parts = urlsplit(url)
    host, port = parts[1].split(':')
    port = int(port)
    return (host, port)
def hostpair(url):
    """Parse the host and port number out of a URL string."""
    parts  = urlsplit(url)
    host, port = parts[1].split(':')
    port = int(port)
    return (host, port)