/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-28 00:32:38 UTC
  • mfrom: (7490.40.77 work)
  • mto: (7490.40.79 work)
  • mto: This revision was merged to the branch mainline in revision 7521.
  • Revision ID: jelmer@jelmer.uk-20200728003238-vx5u412hn72f18lr
Merge lp:brz/3.1.

Show diffs side-by-side

added added

removed removed

Lines of Context:
224
224
 
225
225
    merge_proposal_description_format = 'plain'
226
226
 
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')
 
227
    def __init__(self, service_root):
 
228
        self._api_base_url = service_root
 
229
        self._launchpad = None
 
230
 
 
231
    @property
 
232
    def name(self):
 
233
        if self._api_base_url == uris.LPNET_SERVICE_ROOT:
 
234
            return 'Launchpad'
 
235
        return 'Launchpad at %s' % self.base_url
 
236
 
 
237
    @property
 
238
    def launchpad(self):
 
239
        if self._launchpad is None:
 
240
            self._launchpad = lp_api.connect_launchpad(self._api_base_url, version='devel')
 
241
        return self._launchpad
234
242
 
235
243
    @property
236
244
    def base_url(self):
237
 
        return lp_api.uris.web_root_for_service_root(
238
 
            str(self.launchpad._root_uri))
 
245
        return lp_api.uris.web_root_for_service_root(self._api_base_url)
239
246
 
240
247
    def __repr__(self):
241
 
        return "Launchpad(staging=%s)" % self._staging
 
248
        return "Launchpad(service_root=%s)" % self._api_base_url
 
249
 
 
250
    def get_current_user(self):
 
251
        return self.launchpad.me.name
 
252
 
 
253
    def get_user_url(self, username):
 
254
        return self.launchpad.people[username].web_link
242
255
 
243
256
    def hosts(self, branch):
244
257
        # TODO(jelmer): staging vs non-staging?
247
260
    @classmethod
248
261
    def probe_from_url(cls, url, possible_transports=None):
249
262
        if plausible_launchpad_url(url):
250
 
            return Launchpad()
 
263
            return Launchpad(uris.LPNET_SERVICE_ROOT)
251
264
        raise UnsupportedHoster(url)
252
265
 
253
266
    def _get_lp_git_ref_from_branch(self, branch):
458
471
 
459
472
    @classmethod
460
473
    def iter_instances(cls):
461
 
        yield cls()
 
474
        credential_store = lp_api.get_credential_store()
 
475
        for service_root in set(uris.service_roots.values()):
 
476
            auth_engine = lp_api.get_auth_engine(service_root)
 
477
            creds = credential_store.load(auth_engine.unique_consumer_id)
 
478
            if creds is not None:
 
479
                yield cls(service_root)
462
480
 
463
481
    def iter_my_proposals(self, status='open'):
464
482
        statuses = status_to_lp_mp_statuses(status)