Bug#566841: ftplugin/debchangelog.vim: Use python-launchpadlib (and the LP API) for bug completion for Ubuntu bugs
Michael Bienia
geser at ubuntu.com
Mon Jan 25 13:45:48 UTC 2010
Package: vim-runtime
Version: 2:7.2.330-1
Severity: normal
Tags: patch
Hello,
I noticed that ftplugin/debchangelog.vim still uses
python-launchpad-bugs to fetch the bug listings for an Ubuntu package.
The attached patch changes it to use the LP API (through
python-launchpadlib) instead. It uses the new anonymous access to LP
which will be rolled-out to the 'production' servers on 2010-01-27 (but
you can already use it on the 'edge' servers[0]).
As you might notice, I don't have much experience in writing vim
extensions, so feel free to improve the patch where necessary.
Michael
0: http://blog.launchpad.net/general/anonymous-access-to-the-launchpad-web-service-api
--- vim-7.2.330.orig/runtime/ftplugin/debchangelog.vim
+++ vim-7.2.330/runtime/ftplugin/debchangelog.vim
@@ -8,7 +8,7 @@
" URL: http://git.debian.org/?p=pkg-vim/vim.git;a=blob_plain;f=runtime/ftplugin/debchangelog.vim;hb=debian
" Bug completion requires apt-listbugs installed for Debian packages or
-" python-launchpad-bugs installed for Ubuntu packages
+" python-launchpadlib >= 1.5.4 installed for Ubuntu packages
if exists("b:did_ftplugin")
finish
@@ -329,17 +329,23 @@
python << EOF
import vim
try:
- from launchpadbugs import connector
- buglist = connector.ConnectBugList()
- bl = list(buglist('https://bugs.launchpad.net/ubuntu/+source/%s' % vim.eval('pkgsrc')))
- bl.sort(None, int)
- liststr = '['
- for bug in bl:
- liststr += "'#%d - %s'," % (int(bug), bug.summary.replace('\'', '\'\''))
- liststr += ']'
- vim.command('silent let bug_lines = %s' % liststr)
+ from launchpadlib.launchpad import Launchpad
+ from lazr.restfulclient.errors import HTTPError
+ # login anonymously
+ lp = Launchpad.login_anonymously('debchangelog.vim', 'production')
+ try:
+ dsp = lp.load('%s/ubuntu/+source/%s' % (lp._root_uri, vim.eval('pkgsrc')))
+ tasklist = dsp.searchTasks(status = ('New', 'Incomplete', 'Confirmed', 'Triaged', 'In Progress', 'Fix Committed'), order_by='id')
+ liststr = '['
+ for task in tasklist:
+ bug = task.bug
+ liststr += "'#%d - %s'," % (bug.id, bug.title.replace('\'', '\'\''))
+ liststr += ']'
+ vim.command('silent let bug_lines = %s' % liststr.encode('utf-8'))
+ except HTTPError:
+ pass
except ImportError:
- vim.command('echoerr \'python-launchpad-bugs needs to be installed to use Launchpad bug completion\'')
+ vim.command('echoerr \'python-launchpadlib >= 1.5.4 needs to be installed to use Launchpad bug completion\'')
EOF
else
if ! filereadable('/usr/sbin/apt-listbugs')
More information about the pkg-vim-maintainers
mailing list