예제 #1
0
 def test_simple(self):
     self.assertEqual(
             parse_rsync_url('foo:bar/path'),
             (None, 'foo', 'bar/path'))
     self.assertEqual(
             parse_rsync_url('user@foo:bar/path'),
             ('user', 'foo', 'bar/path'))
예제 #2
0
 def test_simple(self):
     self.assertEqual(
             parse_rsync_url('foo:bar/path'),
             (None, 'foo', 'bar/path'))
     self.assertEqual(
             parse_rsync_url('user@foo:bar/path'),
             ('user', 'foo', 'bar/path'))
예제 #3
0
파일: urls.py 프로젝트: tpow/breezy
def git_url_to_bzr_url(location):
    url = URL.from_string(location)
    if (url.scheme not in KNOWN_GIT_SCHEMES
            and not url.scheme.startswith('chroot-')):
        try:
            (username, host, path) = parse_rsync_url(location)
        except ValueError:
            return location
        else:
            url = URL(scheme='git+ssh',
                      quoted_user=(quote(username) if username else None),
                      quoted_password=None,
                      quoted_host=quote(host),
                      port=None,
                      quoted_path=quote(path, safe="/~"))
        return str(url)
    else:
        return location
예제 #4
0
파일: urls.py 프로젝트: zeta1999/breezy
def git_url_to_bzr_url(location, branch=None, ref=None):
    if branch is not None and ref is not None:
        raise ValueError('only specify one of branch or ref')
    url = urlutils.URL.from_string(location)
    if (url.scheme not in KNOWN_GIT_SCHEMES
            and not url.scheme.startswith('chroot-')):
        try:
            (username, host, path) = parse_rsync_url(location)
        except ValueError:
            return location
        else:
            url = urlutils.URL(
                scheme='git+ssh',
                quoted_user=(urlutils.quote(username) if username else None),
                quoted_password=None,
                quoted_host=urlutils.quote(host),
                port=None,
                quoted_path=urlutils.quote(path, safe="/~"))
        location = str(url)
    elif url.scheme in SCHEME_REPLACEMENT:
        url.scheme = SCHEME_REPLACEMENT[url.scheme]
        location = str(url)
    if ref == b'HEAD':
        ref = branch = None
    if ref:
        try:
            branch = ref_to_branch_name(ref)
        except ValueError:
            branch = None
        else:
            ref = None
    if ref or branch:
        params = {}
        if ref:
            params['ref'] = urlutils.quote_from_bytes(ref, safe='')
        if branch:
            params['branch'] = urlutils.escape(branch, safe='')
        location = urlutils.join_segment_parameters(location, params)
    return location