/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/lp_api.py

  • Committer: Jelmer Vernooij
  • Date: 2020-08-10 15:00:17 UTC
  • mfrom: (7490.40.99 work)
  • mto: This revision was merged to the branch mainline in revision 7521.
  • Revision ID: jelmer@jelmer.uk-20200810150017-vs7xnrd1vat4iktg
Merge lp:brz/3.1.

Show diffs side-by-side

added added

removed removed

Lines of Context:
16
16
 
17
17
"""Tools for dealing with the Launchpad API."""
18
18
 
19
 
from __future__ import absolute_import
20
 
 
21
19
# Importing this module will be expensive, since it imports launchpadlib and
22
20
# its dependencies. However, our plan is to only load this module when it is
23
21
# needed by a command that uses it.
24
22
 
25
23
 
26
24
import re
27
 
try:
28
 
    from urllib.parse import (
29
 
        urlparse,
30
 
        urlunparse,
31
 
        )
32
 
except ImportError:  # python < 3
33
 
    from urlparse import (
34
 
        urlparse,
35
 
        urlunparse,
36
 
        )
 
25
from urllib.parse import (
 
26
    urlparse,
 
27
    urlunparse,
 
28
    )
37
29
 
38
30
from ... import (
39
31
    branch,
60
52
except ImportError as e:
61
53
    raise LaunchpadlibMissing(e)
62
54
 
 
55
from launchpadlib.credentials import RequestTokenAuthorizationEngine
63
56
from launchpadlib.launchpad import (
64
57
    Launchpad,
65
58
    )
106
99
        errors.BzrError.__init__(self, branch=branch, url=branch.base)
107
100
 
108
101
 
 
102
def get_auth_engine(base_url):
 
103
    return Launchpad.authorization_engine_factory(base_url, 'breezy')
 
104
 
 
105
 
 
106
def get_credential_store():
 
107
    return Launchpad.credential_store_factory(None)
 
108
 
 
109
 
109
110
def connect_launchpad(base_url, timeout=None, proxy_info=None,
110
111
                      version=Launchpad.DEFAULT_VERSION):
111
112
    """Log in to the Launchpad API.
119
120
        cache_directory = get_cache_directory()
120
121
    except EnvironmentError:
121
122
        cache_directory = None
 
123
    credential_store = get_credential_store()
 
124
    authorization_engine = get_auth_engine(base_url)
122
125
    return Launchpad.login_with(
123
126
        'breezy', base_url, cache_directory, timeout=timeout,
 
127
        credential_store=credential_store,
 
128
        authorization_engine=authorization_engine,
124
129
        proxy_info=proxy_info, version=version)
125
130
 
126
131