Implement CoverArtImage.__hash__

This make CoverArtImage objects hashable
This commit is contained in:
Antonio Larrosa
2017-03-07 10:19:29 +01:00
parent 42dad8031a
commit fdb3ae4e44

View File

@@ -70,6 +70,9 @@ class DataHash:
def __eq__(self, other):
return self._hash == other._hash
def hash(self):
return self._hash
def delete_file(self):
if self._filename:
try:
@@ -211,6 +214,11 @@ class CoverArtImage:
else:
return False
def __hash__(self):
if self.datahash is None:
return 0
return hash(self.datahash.hash())
def set_data(self, data):
"""Store image data in a file, if data already exists in such file
it will be re-used and no file write occurs