From fdb3ae4e4437a88a39ba31bb54aa6c83ea2fa6c4 Mon Sep 17 00:00:00 2001 From: Antonio Larrosa Date: Tue, 7 Mar 2017 10:19:29 +0100 Subject: [PATCH] Implement CoverArtImage.__hash__ This make CoverArtImage objects hashable --- picard/coverart/image.py | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/picard/coverart/image.py b/picard/coverart/image.py index 69fdd1157..cb036cd47 100644 --- a/picard/coverart/image.py +++ b/picard/coverart/image.py @@ -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