~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/plugins/launchpad/lp_directory.py

  • Committer: Jelmer Vernooij
  • Date: 2010-12-20 11:57:14 UTC
  • mto: This revision was merged to the branch mainline in revision 5577.
  • Revision ID: jelmer@samba.org-20101220115714-2ru3hfappjweeg7q
Don't use no-plugins.

Show diffs side-by-side

added added

removed removed

Lines of Context:
40
40
register_urlparse_netloc_protocol('bzr+ssh')
41
41
register_urlparse_netloc_protocol('lp')
42
42
 
 
43
_ubuntu_series_shortcuts = {
 
44
    'n': 'natty',
 
45
    'm': 'maverick',
 
46
    'l': 'lucid',
 
47
    'k': 'karmic',
 
48
    'j': 'jaunty',
 
49
    'h': 'hardy',
 
50
    'd': 'dapper',
 
51
    }
 
52
 
43
53
 
44
54
class LaunchpadDirectory(object):
45
55
 
62
72
                 _request_factory=ResolveLaunchpadPathRequest,
63
73
                 _lp_login=None):
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':
 
79
                distro = 'ubuntu'
 
80
                distro_series = _ubuntu_series_shortcuts
 
81
            elif scheme == 'debianlp':
 
82
                distro = 'debian'
 
83
                # No shortcuts for Debian distroseries.
 
84
                distro_series = {}
 
85
            else:
 
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
 
89
            # know about.
 
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]
 
95
                series = None
 
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
 
100
            else:
 
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(
 
108
                distro=distro,
 
109
                series=series,
 
110
                project=project)
 
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,