summary refs log tree commit diff stats
diff options
context:
space:
mode:
authorA. Lopes <ajtluser@openmailbox.com>2016-04-08 23:00:11 +0100
committerA. Lopes <ajtluser@openmailbox.com>2016-04-08 23:04:47 +0100
commit5b2f1c8c696beb2c7e2e6d779955d28a77fcec7c (patch)
treef7535a87a778259c5a3f0eeb529c2d4523dfed8b
parent65b9bcea56c80d0b242546600452f9caf934f059 (diff)
downloadranger-5b2f1c8c696beb2c7e2e6d779955d28a77fcec7c.tar.gz
Add __eq__, __neq__, and __hash__ to class File
Uses the File's path variable for both equality testing and hashing.
Fix for issue #483.
-rw-r--r--ranger/container/file.py9
1 files changed, 9 insertions, 0 deletions
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)