12.1.1
by Markus Korn
* added 'launchpadlib' category. This category has samples using |
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) |