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