/brz/remove-bazaar

To get this branch, use:
bzr branch http://gegoxaren.bato24.eu/bzr/brz/remove-bazaar

« back to all changes in this revision

Viewing changes to breezy/plugins/launchpad/hoster.py

  • Committer: Jelmer Vernooij
  • Date: 2020-07-05 12:50:01 UTC
  • mfrom: (7490.40.46 work)
  • mto: (7490.40.48 work)
  • mto: This revision was merged to the branch mainline in revision 7519.
  • Revision ID: jelmer@jelmer.uk-20200705125001-7s3vo0p55szbbws7
Merge lp:brz/3.1.

Show diffs side-by-side

added added

removed removed

Lines of Context:
17
17
 
18
18
"""Support for Launchpad."""
19
19
 
 
20
from __future__ import absolute_import
 
21
 
20
22
import re
21
23
import shutil
22
24
import tempfile
222
224
 
223
225
    merge_proposal_description_format = 'plain'
224
226
 
225
 
    def __init__(self, service_root):
226
 
        self._api_base_url = service_root
227
 
        self._launchpad = None
228
 
 
229
 
    @property
230
 
    def name(self):
231
 
        if self._api_base_url == uris.LPNET_SERVICE_ROOT:
232
 
            return 'Launchpad'
233
 
        return 'Launchpad at %s' % self.base_url
234
 
 
235
 
    @property
236
 
    def launchpad(self):
237
 
        if self._launchpad is None:
238
 
            self._launchpad = lp_api.connect_launchpad(self._api_base_url, version='devel')
239
 
        return self._launchpad
 
227
    def __init__(self, staging=False):
 
228
        self._staging = staging
 
229
        if staging:
 
230
            lp_base_url = uris.STAGING_SERVICE_ROOT
 
231
        else:
 
232
            lp_base_url = uris.LPNET_SERVICE_ROOT
 
233
        self.launchpad = lp_api.connect_launchpad(lp_base_url, version='devel')
240
234
 
241
235
    @property
242
236
    def base_url(self):
243
 
        return lp_api.uris.web_root_for_service_root(self._api_base_url)
 
237
        return lp_api.uris.web_root_for_service_root(
 
238
            str(self.launchpad._root_uri))
244
239
 
245
240
    def __repr__(self):
246
 
        return "Launchpad(service_root=%s)" % self._api_base_url
247
 
 
248
 
    def get_current_user(self):
249
 
        return self.launchpad.me.name
250
 
 
251
 
    def get_user_url(self, username):
252
 
        return self.launchpad.people[username].web_link
 
241
        return "Launchpad(staging=%s)" % self._staging
253
242
 
254
243
    def hosts(self, branch):
255
244
        # TODO(jelmer): staging vs non-staging?
258
247
    @classmethod
259
248
    def probe_from_url(cls, url, possible_transports=None):
260
249
        if plausible_launchpad_url(url):
261
 
            return Launchpad(uris.LPNET_SERVICE_ROOT)
 
250
            return Launchpad()
262
251
        raise UnsupportedHoster(url)
263
252
 
264
253
    def _get_lp_git_ref_from_branch(self, branch):
469
458
 
470
459
    @classmethod
471
460
    def iter_instances(cls):
472
 
        credential_store = lp_api.get_credential_store()
473
 
        for service_root in set(uris.service_roots.values()):
474
 
            auth_engine = lp_api.get_auth_engine(service_root)
475
 
            creds = credential_store.load(auth_engine.unique_consumer_id)
476
 
            if creds is not None:
477
 
                yield cls(service_root)
 
461
        yield cls()
478
462
 
479
463
    def iter_my_proposals(self, status='open'):
480
464
        statuses = status_to_lp_mp_statuses(status)