Launchpadlib

Launchpadlib

launchpadlib is an open-source Python library that lets you treat the HTTP resources published by Launchpad's web service as Python objects responding to a standard set of commands. With launchpadlib you can integrate your applications into Launchpad without knowing a lot about HTTP client programming.

Installing

Lucid

sudo apt-get install python-launchpadlib

Hello, World!

from launchpadlib.launchpad import Launchpad
import os

server    = 'edge'
cachedir  = os.path.expanduser("~/.launchpadlib/cache")
app_name  = "Just-Testing"

launchpad = Launchpad.login_anonymously(app_name, server, cachedir)
paultag = launchpad.people["paultag"]

print paultag.display_name

And that ( providing paultag did not change his name ) will output

>>> Paul Tagliamonte

Fantastic. Let's move on to some nifty features of launchpadlib. Let's take a bit of a look at paultag's details.

from launchpadlib.launchpad import Launchpad
import os

server    = 'edge'
cachedir  = os.path.expanduser("~/.launchpadlib/cache")
app_name  = "Just-Testing"

launchpad = Launchpad.login_anonymously(app_name, server, cachedir)
paultag = launchpad.people["paultag"]

realname = paultag.display_name

print realname + "'s GPG key fingerprint(s) is/are"

for key in paultag.gpg_keys:
        print "  " + key.fingerprint

print realname + " speaks"

for language in paultag.languages:
        print "  " + language.english_name

Fantastic. If paultag has not gone to school to pick up a new language or uploaded a new GPG key, the output should be

>>> Paul Tagliamonte's GPG key fingerprint(s) is/are
>>>   57DC4BD33F73E0CDBA98D22AF7EBEE8EB7982329
>>> Paul Tagliamonte speaks
>>>  English
>>>  German

Launchpadlib (last edited 2010-04-30 14:47:31 by 143)