BugList

Differences between revisions 9 and 10
Revision 9 as of 2007-07-09 13:37:52
Size: 2694
Editor: a89-182-22-219
Comment: fixed headings and added custom-built filter-functions example
Revision 10 as of 2007-09-03 10:27:24
Size: 2764
Editor: a89-182-150-140
Comment:
Deletions are marked like this. Additions are marked like this.
Line 6: Line 6:
{{{ import launchpadbugs.connector as Connector {{{#!python
import launchpadbugs.connector as Connector
Line 9: Line 10:
BugList.authentification = "cookie.txt" BugList.authentication = "cookie.txt"
Line 13: Line 14:
{{{ l = BugList("https://bugs.launchpad.net/ubuntu/+source/bughelper/+bugs") {{{#!python
l = BugList("https://bugs.launchpad.net/ubuntu/+source/bughelper/+bugs")
Line 28: Line 30:
{{{ l += BugList("https://bugs.launchpad.net/bughelper/+bugs") {{{#!python
l += BugList("https://bugs.launchpad.net/bughelper/+bugs")
Line 35: Line 38:
{{{ BugList.set_filter(minbug=100000, filterbug="117701,109628", status="New") {{{#!python
BugList.set_filter(minbug=100000, filterbug="117701,109628", status="New")
Line 43: Line 47:
{{{ print l.sort("nr") {{{#!python
print l.sort("nr")
Line 49: Line 54:
{{{ a = BugList("https://launchpad.net/ubuntu/+source/apport/+bugs?%s" %BugList.urlopt) {{{#!python
a = BugList("https://launchpad.net/ubuntu/+source/apport/+bugs?%s" %BugList.urlopt)
Line 56: Line 62:
{{{ try: {{{#!python
try:
Line 67: Line 74:
{{{ bl = BugList("https://bugs.launchpad.net/bughelper/+bugs") {{{#!python
bl = BugList("https://bugs.launchpad.net/bughelper/+bugs")

This is still work in progress

Example usage of BugList

Use `LaunchpadConnector` and setting authentification:

   1 import launchpadbugs.connector as Connector
   2 
   3 BugList = Connector.ConnectBugList()
   4 BugList.authentication = "cookie.txt"

Getting a list of bugs and print available information:

   1 l = BugList("https://bugs.launchpad.net/ubuntu/+source/bughelper/+bugs")
   2 for i in l.bugs:
   3     print i.bugnumber,
   4     print i.url,
   5     print i.summary,
   6     print i.importance,
   7     print i.status,
   8     print i.sourcepackage

{{{ 88521 https://bugs.launchpad.net/ubuntu/+source/bughelper/+bug/88521 selectively pulling attachments by name Medium Incomplete None

88102 https://bugs.launchpad.net/ubuntu/+source/bughelper/+bug/88102 sort report by issue type rather than bug number Undecided Confirmed None }}}

Adding some (upstream) bugs to the set

   1 l += BugList("https://bugs.launchpad.net/bughelper/+bugs")
   2 print l.bugs

{{{ set([109628, 110937, 88521, 88102, 84723, 88102, 81291, 85152, 88521, 90084, 109547]) }}}

Setting a filter and filter the set of bugs

   1 BugList.set_filter(minbug=100000, filterbug="117701,109628", status="New")
   2 l = l.filter()
   3 print l.bugs

{{{ set([110937, 109547]) }}}

Sorting the list of bugs

   1 print l.sort("nr")

{{{ [109547, 110937] }}}

add LP urloptions to an url

   1 a = BugList("https://launchpad.net/ubuntu/+source/apport/+bugs?%s" %BugList.urlopt)
   2 print a.bugs

{{{ set([123180, 122818, 123394, 119270, 123440, 87364, 105224, 108482, 95504, 114215, 118407, 118827, 119104, 95822, 121121, 121341, 122196, 123216, 122274, 122347, 122522, 122798, 89916, 122882, 94130, 122859, 123062]) }}}

Raising `LPUrlError` for invalid urls

   1 try:
   2     a = BugList("https://bugs.launchpad.net/ubuntu/+source/firefokkksss/+bugs")
   3     print len(a.bugs)
   4 except BugList.Error.LPUrlError, e:
   5     print e

"'Page not found (url: https://bugs.launchpad.net/ubuntu/+source/firefokkksss/+bugs)'"

Use custom-made filter-functions

   1 bl = BugList("https://bugs.launchpad.net/bughelper/+bugs")
   2 def RFE_filter(bugs):
   3     result = set()
   4     for b in bugs:
   5         if b.summary.startswith("RFE"):
   6             result.add(b)
   7     return result
   8             
   9 
  10 for b in bl.filter(func=[RFE_filter]).bugs:
  11     print "%s (%s)" %(b.summary, b.bugnumber)

{{{ RFE: Web interface to bughelper (81291) RFE: grep for package version (84723) }}}


Go Back to [:BugHelper/Dev].BR CategoryBugHelper

BugHelper/Dev/python-launchpad-bugs/BugList (last edited 2008-08-06 17:01:38 by localhost)