Wednesday, April 15, 2009

Launchpad API for PPAs - part 2

Continuing with Launchpad APIs for PPAs, let's illustrate how to find sources within a PPA.

Sources can be found, basically, by name, version, distroseries and status by calling getPublishedSources on a target archive.

 >>> def test_source_lookup(lp):
...     ppa = lp.people['ubuntu-mozilla-daily'].archive
...    ubuntu = lp.distributions['ubuntu']
...    jaunty = ubuntu.getSeries(name_or_version='jaunty')
...    last_firefox = ppa.getPublishedSources(
...        source_name='firefox-3.5', status='Published', distro_series=jaunty,
...        exact_match=True)[0]
...    print last_firefox.displayname

When it run, the output is:

firefox-3.5 3.5~b4~hg20090415r24712+nobinonly-0ubuntu1~umd1 in jaunty

Play with the arguments, also instead of fetching the first item (most recent one) from the collection you may iterate over it.

Posted via web from cprov's posterous