migrationitem: add support for using items as indexes in to lists

In order to provide the support, items may now be tested for equality
and hashed.  Two items are considered equal if they have the same
unversioned name (and version, if appropriate); hashing is based on
a tuple hash of the name and version.

Signed-off-by: Adam D. Barratt <adam@adam-barratt.org.uk>
debian
Adam D. Barratt 14 years ago
parent 8665dba100
commit 870c939e3f

@ -29,6 +29,19 @@ class MigrationItem:
else:
return self.uvname
def __eq__(self, other):
isequal = False
if self.uvname == other.uvname:
if self.version is None or other.version is None:
isequal = True
else:
isequal = self.version == other.version
return isequal
def __hash__(self):
return hash((self.uvname, self.version))
def _get_name(self):
return self._name

Loading…
Cancel
Save