mirror of
https://git.launchpad.net/~ubuntu-release/britney/+git/britney2-ubuntu
synced 2025-02-23 19:31:55 +00:00
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>
This commit is contained in:
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…
x
Reference in New Issue
Block a user