Implement __eq__(), __ne__(), and __hash__()

This commit is contained in:
Eric Torres 2019-04-22 21:09:49 -07:00
parent f20f77836f
commit cc76e91afc

View File

@ -46,9 +46,18 @@ class Hierarchy(PathLike):
self.path.mkdir(DIRMODE, parents=True, exist_ok=True) self.path.mkdir(DIRMODE, parents=True, exist_ok=True)
def __eq__(self, other):
return self._path == other.path
def __fspath__(self): def __fspath__(self):
return str(self._path) return str(self._path)
def __hash__(self):
return hash(self._path)
def __ne__(self, other):
return self._path != other.path
def __repr__(self): def __repr__(self):
"""Return a string representation of this Hierarchy.""" """Return a string representation of this Hierarchy."""
return f"{self.__class__.__name__}('{self._path}')" return f"{self.__class__.__name__}('{self._path}')"