/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: Breezy landing bot
  • Author(s): Jelmer Vernooij
  • Date: 2020-07-28 02:47:10 UTC
  • mfrom: (7519.1.1 merge-3.1)
  • Revision ID: breezy.the.bot@gmail.com-20200728024710-a2ylds219f1lsl62
Merge lp:brz/3.1.

Merged from https://code.launchpad.net/~jelmer/brz/merge-3.1/+merge/388173

Show diffs side-by-side

added added

removed removed

Lines of Context:
222
222
 
223
223
    merge_proposal_description_format = 'plain'
224
224
 
225
 
    def __init__(self, staging=False):
226
 
        self._staging = staging
227
 
        if staging:
228
 
            lp_base_url = uris.STAGING_SERVICE_ROOT
229
 
        else:
230
 
            lp_base_url = uris.LPNET_SERVICE_ROOT
231
 
        self._api_base_url = lp_base_url
 
225
    def __init__(self, service_root):
 
226
        self._api_base_url = service_root
232
227
        self._launchpad = None
233
228
 
234
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
235
236
    def launchpad(self):
236
237
        if self._launchpad is None:
237
238
            self._launchpad = lp_api.connect_launchpad(self._api_base_url, version='devel')
242
243
        return lp_api.uris.web_root_for_service_root(self._api_base_url)
243
244
 
244
245
    def __repr__(self):
245
 
        return "Launchpad(staging=%s)" % self._staging
 
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
246
253
 
247
254
    def hosts(self, branch):
248
255
        # TODO(jelmer): staging vs non-staging?
251
258
    @classmethod
252
259
    def probe_from_url(cls, url, possible_transports=None):
253
260
        if plausible_launchpad_url(url):
254
 
            return Launchpad()
 
261
            return Launchpad(uris.LPNET_SERVICE_ROOT)
255
262
        raise UnsupportedHoster(url)
256
263
 
257
264
    def _get_lp_git_ref_from_branch(self, branch):
462
469
 
463
470
    @classmethod
464
471
    def iter_instances(cls):
465
 
        yield 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)
466
478
 
467
479
    def iter_my_proposals(self, status='open'):
468
480
        statuses = status_to_lp_mp_statuses(status)