diff options
author | A. Lopes <ajtluser@openmailbox.com> | 2016-04-08 23:00:11 +0100 |
---|---|---|
committer | A. Lopes <ajtluser@openmailbox.com> | 2016-04-08 23:04:47 +0100 |
commit | 5b2f1c8c696beb2c7e2e6d779955d28a77fcec7c (patch) | |
tree | f7535a87a778259c5a3f0eeb529c2d4523dfed8b /ranger | |
parent | 65b9bcea56c80d0b242546600452f9caf934f059 (diff) | |
download | ranger-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.
Diffstat (limited to 'ranger')
-rw-r--r-- | ranger/container/file.py | 9 |
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) |