62
72
_request_factory=ResolveLaunchpadPathRequest,
64
74
"""Resolve the base URL for this transport."""
75
# Do ubuntu: and debianlp: expansions.
76
scheme, netloc, path, query, fragment = urlsplit(url)
77
if scheme in ('ubuntu', 'debianlp'):
78
if scheme == 'ubuntu':
80
distro_series = _ubuntu_series_shortcuts
81
elif scheme == 'debianlp':
83
# No shortcuts for Debian distroseries.
86
raise AssertionError('scheme should be ubuntu: or debianlp:')
87
# Split the path. It's either going to be 'project' or
88
# 'series/project', but recognize that it may be a series we don't
90
path_parts = path.split('/')
91
if len(path_parts) == 1:
92
# It's just a project name.
93
lp_url_template = 'lp:%(distro)s/%(project)s'
94
project = path_parts[0]
96
elif len(path_parts) == 2:
97
# It's a series and project.
98
lp_url_template = 'lp:%(distro)s/%(series)s/%(project)s'
99
series, project = path_parts
101
# There are either 0 or > 2 path parts, neither of which is
102
# supported for these schemes.
103
raise errors.InvalidURL('Bad path: %s' % result.path)
104
# Expand any series shortcuts, but keep unknown series.
105
series = distro_series.get(series, series)
106
# Hack the url and let the following do the final resolution.
107
url = lp_url_template % dict(
111
scheme, netloc, path, query, fragment = urlsplit(url)
65
112
service = LaunchpadService.for_url(url)
66
result = urlsplit(url)
67
113
if _lp_login is None:
68
114
_lp_login = get_lp_login()
69
path = result[2].strip('/')
115
path = path.strip('/')
70
116
if path.startswith('~/'):
71
117
if _lp_login is None:
72
118
raise errors.InvalidURL(path=url,