From 5b2f1c8c696beb2c7e2e6d779955d28a77fcec7c Mon Sep 17 00:00:00 2001 From: "A. Lopes" Date: Fri, 8 Apr 2016 23:00:11 +0100 Subject: Add __eq__, __neq__, and __hash__ to class File Uses the File's path variable for both equality testing and hashing. Fix for issue #483. --- ranger/container/file.py | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/ranger/container/file.py b/ranger/container/file.py index a3db63a5..2c6d8315 100644 --- a/ranger/container/file.py +++ b/ranger/container/file.py @@ -96,3 +96,12 @@ class File(FileSystemObject): return self.fm.previews[self.realpath]['imagepreview'] except KeyError: return False + + def __eq__(self, other): + return isinstance(other, File) and self.path == other.path + + def __neq__(self, other): + return not self.__eq__(other) + + def __hash__(self): + return hash(self.path) -- cgit 1.4.1-2-gfad0