From cc76e91afc848487617b86a77d2535c0f275a24d Mon Sep 17 00:00:00 2001 From: Eric Torres Date: Mon, 22 Apr 2019 21:09:49 -0700 Subject: [PATCH] Implement __eq__(), __ne__(), and __hash__() --- rbackup/struct/hierarchy.py | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/rbackup/struct/hierarchy.py b/rbackup/struct/hierarchy.py index 4f9dd72..026940d 100644 --- a/rbackup/struct/hierarchy.py +++ b/rbackup/struct/hierarchy.py @@ -46,9 +46,18 @@ class Hierarchy(PathLike): self.path.mkdir(DIRMODE, parents=True, exist_ok=True) + def __eq__(self, other): + return self._path == other.path + def __fspath__(self): return str(self._path) + def __hash__(self): + return hash(self._path) + + def __ne__(self, other): + return self._path != other.path + def __repr__(self): """Return a string representation of this Hierarchy.""" return f"{self.__class__.__name__}('{self._path}')"