def _transform_url(url, transform_netloc):
    purl = urllib_parse.urlsplit(url)
    netloc = transform_netloc(purl.netloc)
    # stripped url
    url_pieces = (purl.scheme, netloc, purl.path, purl.query, purl.fragment)
    surl = urllib_parse.urlunsplit(url_pieces)
    return surl
Пример #2
0
def remove_auth_from_url(url):
    # Return a copy of url with 'username:password@' removed.
    # username/pass params are passed to subversion through flags
    # and are not recognized in the url.

    # parsed url
    purl = urllib_parse.urlsplit(url)
    netloc, user_pass = split_auth_from_netloc(purl.netloc)

    # stripped url
    url_pieces = (purl.scheme, netloc, purl.path, purl.query, purl.fragment)
    surl = urllib_parse.urlunsplit(url_pieces)
    return surl
Пример #3
0
 def get_url_rev(self):
     """
     Returns the correct repository URL and revision by parsing the given
     repository URL
     """
     error_message = ("Sorry, '%s' is a malformed VCS url. "
                      "The format is <vcs>+<protocol>://<url>, "
                      "e.g. svn+http://myrepo/svn/MyApp#egg=MyApp")
     assert '+' in self.url, error_message % self.url
     url = self.url.split('+', 1)[1]
     scheme, netloc, path, query, frag = urllib_parse.urlsplit(url)
     rev = None
     if '@' in path:
         path, rev = path.rsplit('@', 1)
     url = urllib_parse.urlunsplit((scheme, netloc, path, query, ''))
     return url, rev
Пример #4
0
    def remove_auth_from_url(url):
        # Return a copy of url with 'username:password@' removed.
        # username/pass params are passed to subversion through flags
        # and are not recognized in the url.

        # parsed url
        purl = urllib_parse.urlsplit(url)
        stripped_netloc = \
            purl.netloc.split('@')[-1]

        # stripped url
        url_pieces = (
            purl.scheme, stripped_netloc, purl.path, purl.query, purl.fragment
        )
        surl = urllib_parse.urlunsplit(url_pieces)
        return surl
def _transform_url(url, transform_netloc):
    """Transform and replace netloc in a url.

    transform_netloc is a function taking the netloc and returning a
    tuple. The first element of this tuple is the new netloc. The
    entire tuple is returned.

    Returns a tuple containing the transformed url as item 0 and the
    original tuple returned by transform_netloc as item 1.
    """
    purl = urllib_parse.urlsplit(url)
    netloc_tuple = transform_netloc(purl.netloc)
    # stripped url
    url_pieces = (purl.scheme, netloc_tuple[0], purl.path, purl.query,
                  purl.fragment)
    surl = urllib_parse.urlunsplit(url_pieces)
    return surl, netloc_tuple
Пример #6
0
 def get_url_rev(self):
     """
     Returns the correct repository URL and revision by parsing the given
     repository URL
     """
     error_message = (
         "Sorry, '%s' is a malformed VCS url. "
         "The format is <vcs>+<protocol>://<url>, "
         "e.g. svn+http://myrepo/svn/MyApp#egg=MyApp"
     )
     assert '+' in self.url, error_message % self.url
     url = self.url.split('+', 1)[1]
     scheme, netloc, path, query, frag = urllib_parse.urlsplit(url)
     rev = None
     if '@' in path:
         path, rev = path.rsplit('@', 1)
     url = urllib_parse.urlunsplit((scheme, netloc, path, query, ''))
     return url, rev
Пример #7
0
    def get_url_rev_and_auth(self, url):
        """
        Parse the repository URL to use, and return the URL, revision,
        and auth info to use.

        Returns: (url, rev, (username, password)).
        """
        scheme, netloc, path, query, frag = urllib_parse.urlsplit(url)
        if '+' not in scheme:
            raise ValueError(
                "Sorry, {!r} is a malformed VCS url. "
                "The format is <vcs>+<protocol>://<url>, "
                "e.g. svn+http://myrepo/svn/MyApp#egg=MyApp".format(url))
        # Remove the vcs prefix.
        scheme = scheme.split('+', 1)[1]
        netloc, user_pass = self.get_netloc_and_auth(netloc, scheme)
        rev = None
        if '@' in path:
            path, rev = path.rsplit('@', 1)
        url = urllib_parse.urlunsplit((scheme, netloc, path, query, ''))
        return url, rev, user_pass
Пример #8
0
 def url_without_fragment(self):
     scheme, netloc, path, query, fragment = urllib_parse.urlsplit(self.url)
     return urllib_parse.urlunsplit((scheme, netloc, path, query, None))
 def url_without_fragment(self):
     # type: () -> str
     scheme, netloc, path, query, fragment = urllib_parse.urlsplit(self.url)
     return urllib_parse.urlunsplit((scheme, netloc, path, query, None))