Implement __eq__(), __ne__(), and __hash__()
This commit is contained in:
parent
f20f77836f
commit
cc76e91afc
@ -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}')"
|
||||||
|
Loading…
x
Reference in New Issue
Block a user