/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 brzlib/plugins/launchpad/account.py

  • Committer: Jelmer Vernooij
  • Date: 2017-05-21 12:41:27 UTC
  • mto: This revision was merged to the branch mainline in revision 6623.
  • Revision ID: jelmer@jelmer.uk-20170521124127-iv8etg0vwymyai6y
s/bzr/brz/ in apport config.

Show diffs side-by-side

added added

removed removed

Lines of Context:
20
20
than once for each place that needs to take it into account.
21
21
"""
22
22
 
23
 
from ... import (
 
23
from __future__ import absolute_import
 
24
 
 
25
from brzlib import (
24
26
    errors,
25
27
    trace,
26
28
    transport,
27
29
    )
28
 
from ...config import AuthenticationConfig, GlobalStack
29
 
from ...i18n import gettext
 
30
from brzlib.config import AuthenticationConfig, GlobalStack
 
31
from brzlib.i18n import gettext
30
32
 
31
33
LAUNCHPAD_BASE = 'https://launchpad.net/'
32
34
 
42
44
 
43
45
class MismatchedUsernames(errors.BzrError):
44
46
 
45
 
    _fmt = ('breezy.conf and authentication.conf disagree about launchpad'
 
47
    _fmt = ('bazaar.conf and authentication.conf disagree about launchpad'
46
48
            ' account name.  Please re-run launchpad-login.')
47
49
 
48
50
 
49
51
def get_lp_login(_config=None):
50
52
    """Return the user's Launchpad username.
51
53
 
52
 
    :raises: MismatchedUsername if authentication.conf and breezy.conf
 
54
    :raises: MismatchedUsername if authentication.conf and bazaar.conf
53
55
        disagree about username.
54
56
    """
55
57
    if _config is None:
71
73
def _set_global_option(username, _config=None):
72
74
    if _config is None:
73
75
        _config = GlobalStack()
74
 
    if username is None:
75
 
        _config.remove('launchpad_username')
76
 
    else:
77
 
        _config.set('launchpad_username', username)
 
76
    _config.set('launchpad_username', username)
78
77
 
79
78
 
80
79
def set_lp_login(username, _config=None):
81
80
    """Set the user's Launchpad username"""
82
81
    _set_global_option(username, _config)
83
 
    if username is not None:
84
 
        _set_auth_user(username)
 
82
    _set_auth_user(username)
85
83
 
86
84
 
87
85
def _get_auth_user(auth=None):
90
88
    username = auth.get_user('ssh', '.launchpad.net')
91
89
    return username
92
90
 
93
 
 
94
91
def _set_auth_user(username, auth=None):
95
92
    if auth is None:
96
93
        auth = AuthenticationConfig()