changes_0.3

Differences between revisions 2 and 3
Revision 2 as of 2008-07-08 12:32:51
Size: 1637
Editor: 130
Comment:
Revision 3 as of 2008-07-08 13:01:00
Size: 2834
Editor: 130
Comment:
Deletions are marked like this. Additions are marked like this.
Line 43: Line 43:

== Filtering BugList-objects ==

In the past BugList-objects had a method called `filter()` for filter purposes. This method has now been removed, please use the buildin `filter()` function instead.

In the past filtering of buglists looked like:

{{{#!python
>>> from launchpadbugs.connector import ConnectBugList
>>> BugList = ConnectBugList()
>>> l = BugList("https://bugs.launchpad.net/ubuntu/+source/bughelper/+bugs")
>>> BugList.set_filter(minbug=100000, filterbug="117701,109628", status="New")
>>> l = l.filter()
>>> print l
    #.... [output]
}}}

This has now been replaced by:

{{{#!python
>>> from launchpadbugs.connector import ConnectBugList
>>> BugList = ConnectBugList()
>>> l = BugList("https://bugs.launchpad.net/ubuntu/+source/bughelper/+bugs")
>>> print l
BugList([<BugInfo 239007>,<BugInfo 129341>,<BugInfo 88102>,<BugInfo 150887>])
>>> filter(lambda x: int(x) > 100000 and int(x) not in (117701, 109628) and x.status == "New", l)
[<BugInfo 129341>]
>>>
}}}

In python-launchpad-bugs 0.3 it is also possible to filter bugs during the fetching process, for more information on this please visit ["BugHelper/Dev/python-launchpad-bugs/BugList"]

this is work in progress

API changes in python-launchpad-bugs 0.3

There are some API related differences between python-launchpad-bugs 0.2 and 0.3. This documents aims to describe these and show nesseccary changes to code using this library.

Exceptions

python-launchpad-bugs 0.3 now has a seperate module called exceptions where basically two classes of exceptions are defined: LaunchpadError and PythonLaunchpadBugsError. Both have several subclasses, for a complete list please have a look at help(exceptions).

In former versions of python-launchpad-bugs there only existed one exception-class as an attribute of the connector class, so there were code like:

   1 >>> from launchpadbugs.connector import ConnectBug
   2 >>> Bug = ConnectBug()
   3 >>> try:
   4 ...     b = Bug(url="https://bugs.launchpad.net/someinvalidproduct/+bug/1")
   5 ... except Bug.Error.LPUrlError, e:
   6 ...     print e
   7 ... 
   8 'Page not found (url: https://bugs.launchpad.net/someinvalidproduct/+bug/1)'
   9 >>> 

This now changed to something like:

   1 >>> from launchpadbugs.connector import ConnectBug
   2 >>> from launchpadbugs.exceptions import LaunchpadError
   3 >>> Bug = ConnectBug()
   4 >>> try:
   5 ...     b = Bug(url="https://bugs.launchpad.net/someinvalidproduct/+bug/1")
   6 ... except LaunchpadError, e:
   7 ...     print e
   8 ... 
   9 
  10     * message: Page not found
  11     * url: https://bugs.launchpad.net/someinvalidproduct/+bug/1
  12 >>> 

Filtering BugList-objects

In the past BugList-objects had a method called filter() for filter purposes. This method has now been removed, please use the buildin filter() function instead.

In the past filtering of buglists looked like:

   1 >>> from launchpadbugs.connector import ConnectBugList
   2 >>> BugList = ConnectBugList()
   3 >>> l = BugList("https://bugs.launchpad.net/ubuntu/+source/bughelper/+bugs") 
   4 >>> BugList.set_filter(minbug=100000, filterbug="117701,109628", status="New")
   5 >>> l = l.filter()
   6 >>> print l
   7     #.... [output]

This has now been replaced by:

   1 >>> from launchpadbugs.connector import ConnectBugList
   2 >>> BugList = ConnectBugList()
   3 >>> l = BugList("https://bugs.launchpad.net/ubuntu/+source/bughelper/+bugs")
   4 >>> print l
   5 BugList([<BugInfo 239007>,<BugInfo 129341>,<BugInfo 88102>,<BugInfo 150887>])
   6 >>> filter(lambda x: int(x) > 100000 and int(x) not in (117701, 109628) and x.status == "New", l)
   7 [<BugInfo 129341>]
   8 >>> 

In python-launchpad-bugs 0.3 it is also possible to filter bugs during the fetching process, for more information on this please visit ["BugHelper/Dev/python-launchpad-bugs/BugList"]

BugHelper/Dev/python-launchpad-bugs/changes_0.3 (last edited 2008-08-28 00:31:47 by c-24-21-234-111)