launchpadlib should implement __eq__ and __ne__

Bug #264098 reported by Francis J. Lacoste
2
Affects Status Importance Assigned to Milestone
launchpadlib
Fix Released
High
Leonard Richardson

Bug Description

Currently:

>>> launchpad.people['salgado'] == launchpad.people['salgado']
False

I think that should be True. We could probably implement __eq__ to look at the resource type URL and the object Etag and return True when they are equals.

For collection, we could probably return True whenever the identify URL is equals.

Changed in launchpadlib:
importance: Undecided → Medium
status: New → Triaged
Revision history for this message
Markus Korn (thekorn) wrote :

I think this is fixed in the attached branch:
------------------------------------------------------------
revno: 33
committer: Markus Korn <email address hidden>
branch nick: fix.264098.eq.ne
timestamp: Fri 2009-01-16 20:41:57 +0100
message:
  * launchpadlib/resource.py: changed order of checks in HostedFile.__eq__(),
    this avoids calling open() for this resource of this does not look like a
    file and does not have the same url.
------------------------------------------------------------
revno: 32
committer: Markus Korn <email address hidden>
branch nick: fix.264098.eq.ne
timestamp: Fri 2009-01-16 20:29:20 +0100
message:
  * launchpadlib/resource.py: Implemented __eq__ and __ne__ for Ressources,
    Collections and HostedFiles, with following rules:
     - two ressources are equal if the values of their 'self_link' and
       'http_etag' attributes are equal
     - two collections are equal if the value of their 'self_link' attributes
       are equal
     - two hosted files are equal if the values of their 'url' and
       'last_modified' attributes are equal
     - __ne__ always returns always the revers of __eq__
     - __eq__ always returns False if any error occurs

Revision history for this message
Gary Poster (gary) wrote :

While fixing this is not an inherently high task, merging the community contributed branch is.

Changed in launchpadlib:
importance: Medium → High
assignee: nobody → Leonard Richardson (leonardr)
Changed in launchpadlib:
status: Triaged → Fix Committed
Changed in launchpadlib:
status: Fix Committed → Fix Released
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.