~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/plugins/launchpad/__init__.py

  • Committer: Andrew Bennetts
  • Date: 2007-11-10 15:09:09 UTC
  • mfrom: (2916.2.17 streamable-containers)
  • mto: This revision was merged to the branch mainline in revision 3174.
  • Revision ID: andrew.bennetts@canonical.com-20071110150909-ik5254kgn930th10
Merge streamable-containers.

Show diffs side-by-side

added added

removed removed

Lines of Context:
14
14
# along with this program; if not, write to the Free Software
15
15
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
16
16
 
17
 
"""Launchpad.net integration plugin for Bazaar
18
 
 
19
 
To install this file, put the 'bzr_lp' directory, or a symlink to it,
20
 
in your ~/.bazaar/plugins/ directory.
21
 
"""
 
17
"""Launchpad.net integration plugin for Bazaar."""
22
18
 
23
19
# The XMLRPC server address can be overridden by setting the environment
24
20
# variable $BZR_LP_XMLRPL_URL
84
80
            author='',
85
81
            link_bug=None,
86
82
            dry_run=False):
87
 
        from lp_registration import (
 
83
        from bzrlib.plugins.launchpad.lp_registration import (
88
84
            LaunchpadService, BranchRegistrationRequest, BranchBugLinkRequest,
89
85
            DryRunLaunchpadService)
90
86
        rego = BranchRegistrationRequest(branch_url=branch_url,
114
110
 
115
111
register_command(cmd_register_branch)
116
112
 
 
113
 
 
114
class cmd_launchpad_login(Command):
 
115
    """Show or set the Launchpad user ID.
 
116
 
 
117
    When communicating with Launchpad, some commands need to know your
 
118
    Launchpad user ID.  This command can be used to set or show the
 
119
    user ID that Bazaar will use for such communication.
 
120
 
 
121
    :Examples:
 
122
      Show the Launchpad ID of the current user::
 
123
 
 
124
          bzr launchpad-login
 
125
 
 
126
      Set the Launchpad ID of the current user to 'bob'::
 
127
 
 
128
          bzr launchpad-login bob
 
129
    """
 
130
    aliases = ['lp-login']
 
131
    takes_args = ['name?']
 
132
    takes_options = [
 
133
        Option('no-check',
 
134
               "Don't check that the user name is valid."),
 
135
        ]
 
136
 
 
137
    def run(self, name=None, no_check=False):
 
138
        from bzrlib.plugins.launchpad import account
 
139
        check_account = not no_check
 
140
 
 
141
        if name is None:
 
142
            username = account.get_lp_login()
 
143
            if username:
 
144
                if check_account:
 
145
                    account.check_lp_login(username)
 
146
                self.outf.write(username + '\n')
 
147
            else:
 
148
                self.outf.write('No Launchpad user ID configured.\n')
 
149
                return 1
 
150
        else:
 
151
            if check_account:
 
152
                account.check_lp_login(name)
 
153
            account.set_lp_login(name)
 
154
 
 
155
register_command(cmd_launchpad_login)
 
156
 
 
157
 
117
158
register_lazy_transport(
118
159
    'lp:',
119
160
    'bzrlib.plugins.launchpad.lp_indirect',
127
168
def test_suite():
128
169
    """Called by bzrlib to fetch tests for this plugin"""
129
170
    from unittest import TestSuite, TestLoader
130
 
    import test_register
131
 
    import test_lp_indirect
 
171
    from bzrlib.plugins.launchpad import (
 
172
        test_register, test_lp_indirect, test_account)
132
173
 
133
174
    loader = TestLoader()
134
175
    suite = TestSuite()
135
 
    for m in [test_register, test_lp_indirect]:
 
176
    for m in [test_register, test_lp_indirect, test_account]:
136
177
        suite.addTests(loader.loadTestsFromModule(m))
137
178
    return suite
138
179