~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

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

  • Committer: Jonathan Lange
  • Date: 2009-12-16 05:03:05 UTC
  • mto: This revision was merged to the branch mainline in revision 4907.
  • Revision ID: jml@canonical.com-20091216050305-2478c12typezz1g3
Move lp_registration imports into commands.

Show diffs side-by-side

added added

removed removed

Lines of Context:
41
41
    NotBranchError,
42
42
    )
43
43
from bzrlib.help_topics import topic_registry
44
 
# XXX: Lazy import this
45
 
from bzrlib.plugins.launchpad.lp_registration import (
46
 
    LaunchpadService,
47
 
    NotLaunchpadBranch,
48
 
    )
49
44
 
50
45
 
51
46
class cmd_register_branch(Command):
113
108
            dry_run=False):
114
109
        from bzrlib.plugins.launchpad.lp_registration import (
115
110
            BranchRegistrationRequest, BranchBugLinkRequest,
116
 
            DryRunLaunchpadService)
 
111
            DryRunLaunchpadService, LaunchpadService)
117
112
        if public_url is None:
118
113
            try:
119
114
                b = _mod_branch.Branch.open_containing('.')[0]
182
177
            yield branch_url
183
178
 
184
179
    def _get_web_url(self, service, location):
 
180
        from bzrlib.plugins.launchpad.lp_registration import (
 
181
            NotLaunchpadBranch)
185
182
        for branch_url in self._possible_locations(location):
186
183
            try:
187
184
                return service.get_web_url_from_branch_url(branch_url)
190
187
        raise NotLaunchpadBranch(branch_url)
191
188
 
192
189
    def run(self, location=None, dry_run=False):
 
190
        from bzrlib.plugins.launchpad.lp_registration import (
 
191
            LaunchpadService)
193
192
        if location is None:
194
193
            location = u'.'
195
 
        web_url = self._get_web_url(LaunchpadService(), location)
 
194
        web_url = self._get_web_url(
 
195
            lp_registration.LaunchpadService(), location)
196
196
        trace.note('Opening %s in web browser' % web_url)
197
197
        if not dry_run:
198
198
            import webbrowser   # this import should not be lazy
275
275
        return lp_api
276
276
 
277
277
    def run(self, location='.'):
 
278
        from bzrlib.plugins.launchpad.lp_registration import LaunchpadService
278
279
        service = LaunchpadService()
279
280
        lp_api = self._get_lp_api()
280
281
        launchpad = lp_api.login(service)