~doctormo/python-snippets/lp-merge-request-example

« back to all changes in this revision

Viewing changes to launchpadlib/has_release_target.py

  • Committer: Jono Bacon
  • Date: 2010-01-12 18:38:28 UTC
  • mfrom: (12.1.1 launchpadlib)
  • Revision ID: jono@ubuntu.com-20100112183828-9wdutnsi2ohe38sk
Our first liblaunchpad examples! Thanks Markus!

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#!/usr/bin/env python
 
2
#
 
3
# [SNIPPET_NAME: has release target]
 
4
# [SNIPPET_CATEGORIES: launchpadlib]
 
5
# [SNIPPET_DESCRIPTION: Check if a bug is nominated for a certain release series]
 
6
# [SNIPPET_AUTHOR: Markus Korn <thekorn@gmx.de>]
 
7
# [SNIPPET_LICENSE: GPL]
 
8
 
 
9
# For more Examples see https://help.launchpad.net/API/Examples
 
10
 
 
11
from launchpadlib.launchpad import Launchpad, STAGING_SERVICE_ROOT
 
12
 
 
13
def has_target(bug, series):
 
14
   series_url = str(series)
 
15
   for task in bug.bug_tasks:
 
16
       if str(task).startswith(series_url):
 
17
           return True
 
18
   return False
 
19
 
 
20
# connect ot the staging service of launchpad
 
21
launchpad = Launchpad.login_with("python-snippets", STAGING_SERVICE_ROOT)
 
22
# get a bug object
 
23
bug = launchpad.bugs[324614]
 
24
# get the ubuntu distro object and the jaunty release series
 
25
ubuntu = launchpad.distributions["ubuntu"]
 
26
jaunty = ubuntu.getSeries(name_or_version="jaunty")
 
27
print has_target(bug, jaunty)